From 9f94a4a2fed776c1529613b7288e1f6674b069cc Mon Sep 17 00:00:00 2001
From: soul <soul@se51-99.jinr.ru>
Date: Thu, 1 Dec 2016 10:57:24 +0300
Subject: [PATCH] update to the newer version of FairRoot used in BmnRoot in
 order to use different sources; many corrections to exclude errors concerned
 with this update

---
 CMakeLists.txt                                |  138 +-
 MbsAPI/CMakeLists.txt                         |  142 +-
 MbsAPI/README.md                              |    6 +
 MbsAPI/clnt_buf_def.h                         |   61 -
 MbsAPI/err_mask_def.h                         |   45 -
 MbsAPI/errnum_def.h                           |  163 --
 MbsAPI/fLmd.c                                 |  178 +-
 MbsAPI/fLmd.h                                 |   20 +-
 MbsAPI/f_evcli.c                              | 1840 --------------
 MbsAPI/f_evcli.h                              |   24 -
 MbsAPI/f_evt.c                                |  326 ++-
 MbsAPI/f_evt.h                                |   20 +-
 MbsAPI/f_find_peaks.c                         |  346 ---
 MbsAPI/f_find_peaks.h                         |   38 -
 MbsAPI/f_his_hist.c                           |  697 ------
 MbsAPI/f_his_hist.h                           |   31 -
 MbsAPI/f_his_swpbas.c                         |  122 -
 MbsAPI/f_his_swpbas.h                         |   22 -
 MbsAPI/f_his_toupper.c                        |   72 -
 MbsAPI/f_his_toupper.h                        |   21 -
 MbsAPI/f_mbs_status.c                         |  196 --
 MbsAPI/f_radware.c                            |  114 -
 MbsAPI/f_radware.h                            |   28 -
 MbsAPI/f_stccomm.c                            |   37 +-
 MbsAPI/f_stccomm.h                            |   25 +-
 MbsAPI/f_swaplw.c                             |  108 -
 MbsAPI/f_swaplw.h                             |   20 -
 MbsAPI/f_ut_compress.c                        |  421 ----
 MbsAPI/f_ut_compress.h                        |   27 -
 MbsAPI/f_ut_seg_show.c                        |  411 ---
 MbsAPI/f_ut_status.c                          |  701 ------
 MbsAPI/f_ut_status.h                          |   25 -
 MbsAPI/f_ut_time.c                            |   88 -
 MbsAPI/f_ut_utime.c                           |    2 +-
 MbsAPI/f_ut_wild.c                            |   62 -
 MbsAPI/f_ut_wild.h                            |   15 -
 MbsAPI/gps_sc_def.h                           |  102 -
 MbsAPI/m_histo_conv.c                         |  158 --
 MbsAPI/ml_def.h                               |   24 -
 MbsAPI/mo_def.h                               |   45 -
 MbsAPI/portnum_def.h                          |   20 +-
 MbsAPI/sMbs.h                                 |   20 +-
 MbsAPI/s_bufhe.h                              |   19 +-
 MbsAPI/s_bufhe_swap.h                         |   20 +-
 MbsAPI/s_clnt_filter.h                        |   35 -
 MbsAPI/s_clnt_filter_swap.h                   |   32 -
 MbsAPI/s_clntbuf.h                            |   68 -
 MbsAPI/s_daqst.h                              |  145 --
 MbsAPI/s_daqst_v2.h                           |  146 --
 MbsAPI/s_endian.h                             |   18 -
 MbsAPI/s_errstat.h                            |   34 -
 MbsAPI/s_evhe.h                               |   20 +-
 MbsAPI/s_evhe_swap.h                          |   20 +-
 MbsAPI/s_filhe.h                              |   19 +-
 MbsAPI/s_filhe_swap.h                         |   19 +-
 MbsAPI/s_filter.h                             |   30 -
 MbsAPI/s_flt_descr.h                          |   26 -
 MbsAPI/s_flt_descr_swap.h                     |   27 -
 MbsAPI/s_head.h                               |   74 -
 MbsAPI/s_his_comm.h                           |   46 -
 MbsAPI/s_his_head.h                           |   49 -
 MbsAPI/s_opc1.h                               |   56 -
 MbsAPI/s_pat.h                                |   59 -
 MbsAPI/s_pol_cond.h                           |   35 -
 MbsAPI/s_set_ml.h                             |  102 -
 MbsAPI/s_set_mo.h                             |  105 -
 MbsAPI/s_setup.h                              |  265 --
 MbsAPI/s_spe.h                                |   69 -
 MbsAPI/s_stdint.h                             |   20 +-
 MbsAPI/s_ve10_1.h                             |   20 +-
 MbsAPI/s_ve10_1_swap.h                        |   20 +-
 MbsAPI/s_ves10_1.h                            |   20 +-
 MbsAPI/s_ves10_1_swap.h                       |   20 +-
 MbsAPI/s_win_cond.h                           |   26 -
 MbsAPI/sbs_def.h                              |   52 -
 MbsAPI/sys_def.h                              |   45 -
 MbsAPI/typedefs.h                             |   20 +-
 MbsAPI/typedefs_nt.h                          |   55 -
 base/CMakeLists.txt                           |  222 +-
 base/FairAnaSelector.cxx                      |  317 ---
 base/FairAnaSelector.h                        |   64 -
 base/FairBaseContFact.h                       |   27 -
 base/FairDetector.cxx                         |   93 -
 base/FairDoubleHit.cxx                        |   23 -
 base/FairGenerator.cxx                        |   28 -
 base/FairLink.h                               |   91 -
 base/FairLinkDef.h                            |   30 +
 base/FairMCApplication.cxx                    | 1098 --------
 base/FairMCEventHeader.h                      |  105 -
 base/FairModule.cxx                           |  429 ----
 base/FairModule.h                             |  112 -
 base/FairPrimaryGenerator.cxx                 |  352 ---
 base/FairPrimaryGenerator.h                   |  219 --
 base/FairRootManager.cxx                      | 2229 -----------------
 base/FairRunAna.cxx                           |  922 -------
 base/FairRunIdGenerator.h                     |   34 -
 base/FairRunInfo.h                            |   57 -
 base/FairTimeStamp.cxx                        |   39 -
 base/FairVTrack.cxx                           |  296 ---
 base/FairVTrack.h                             |   47 -
 base/FairVolumeList.h                         |   47 -
 base/FairWriteoutBufferAbsBasis.h             |   25 -
 base/README.md                                |   12 +
 base/event/FairEventBuilder.cxx               |  134 +
 base/event/FairEventBuilder.h                 |  113 +
 base/event/FairEventBuilderManager.cxx        |  231 ++
 base/event/FairEventBuilderManager.h          |  111 +
 base/{ => event}/FairEventHeader.cxx          |    7 +
 base/{ => event}/FairEventHeader.h            |   10 +-
 base/{ => event}/FairFileHeader.cxx           |   22 +-
 base/{ => event}/FairFileHeader.h             |   17 +-
 base/{ => event}/FairFileInfo.cxx             |   16 +-
 base/{ => event}/FairFileInfo.h               |   15 +-
 base/{ => event}/FairHit.cxx                  |   10 +-
 base/{ => event}/FairHit.h                    |   49 +-
 base/{ => event}/FairLink.cxx                 |    9 +-
 base/event/FairLink.h                         |  114 +
 base/{ => event}/FairMCEventHeader.cxx        |    3 +-
 base/event/FairMCEventHeader.h                |  127 +
 base/{ => event}/FairMCPoint.cxx              |   25 +-
 base/{ => event}/FairMCPoint.h                |   63 +-
 base/{ => event}/FairMesh.cxx                 |   18 +-
 base/{ => event}/FairMesh.h                   |   16 +-
 base/{ => event}/FairMultiLinkedData.cxx      |  108 +-
 base/{ => event}/FairMultiLinkedData.h        |   59 +-
 base/event/FairMultiLinkedData_Interface.cxx  |  208 ++
 base/event/FairMultiLinkedData_Interface.h    |  100 +
 base/{ => event}/FairRadLenPoint.cxx          |    7 +
 base/{ => event}/FairRadLenPoint.h            |   14 +-
 base/{ => event}/FairRadMapPoint.cxx          |    7 +
 base/{ => event}/FairRadMapPoint.h            |   14 +-
 base/event/FairRecoEventHeader.cxx            |   29 +
 base/event/FairRecoEventHeader.h              |  114 +
 base/{ => event}/FairRunInfo.cxx              |   49 +-
 base/event/FairRunInfo.h                      |   65 +
 base/event/FairTimeStamp.cxx                  |   49 +
 base/{ => event}/FairTimeStamp.h              |   53 +-
 base/{ => event}/FairTrackParam.cxx           |   43 +-
 base/{ => event}/FairTrackParam.h             |   17 +-
 base/event/README.md                          |    4 +
 base/{ => field}/FairField.cxx                |    9 +-
 base/{ => field}/FairField.h                  |   17 +-
 base/{ => field}/FairFieldFactory.cxx         |    7 +
 base/{ => field}/FairFieldFactory.h           |   11 +-
 base/{ => field}/FairRKPropagator.cxx         |   16 +-
 base/{ => field}/FairRKPropagator.h           |   13 +-
 base/field/README.md                          |    7 +
 base/{ => sim}/FairBaseContFact.cxx           |   26 +
 base/sim/FairBaseContFact.h                   |   34 +
 base/{ => sim}/FairBaseParSet.cxx             |   26 +-
 base/{ => sim}/FairBaseParSet.h               |   50 +-
 base/sim/FairDetector.cxx                     |  135 +
 base/{ => sim}/FairDetector.h                 |   26 +-
 base/sim/FairDoubleHit.cxx                    |   30 +
 base/{ => sim}/FairDoubleHit.h                |    7 +
 base/{ => sim}/FairGeaneApplication.cxx       |   54 +-
 base/{ => sim}/FairGeaneApplication.h         |   19 +-
 base/sim/FairGenerator.cxx                    |   58 +
 base/{ => sim}/FairGenerator.h                |   25 +-
 base/{ => sim}/FairGenericStack.cxx           |  109 +-
 base/{ => sim}/FairGenericStack.h             |   71 +-
 base/sim/FairGeoParSet.cxx                    |   56 +
 base/sim/FairGeoParSet.h                      |   89 +
 base/{ => sim}/FairIon.cxx                    |   27 +-
 base/{ => sim}/FairIon.h                      |   20 +-
 base/sim/FairMCApplication.cxx                | 1394 +++++++++++
 base/{ => sim}/FairMCApplication.h            |   76 +-
 base/sim/FairModule.cxx                       |  662 +++++
 base/sim/FairModule.h                         |  203 ++
 base/{ => sim}/FairParticle.cxx               |   39 +-
 base/{ => sim}/FairParticle.h                 |   19 +-
 base/sim/FairPrimaryGenerator.cxx             |  489 ++++
 base/sim/FairPrimaryGenerator.h               |  270 ++
 base/{ => sim}/FairRunIdGenerator.cxx         |   95 +-
 base/sim/FairRunIdGenerator.h                 |   54 +
 base/{ => sim}/FairVolume.cxx                 |   16 +-
 base/{ => sim}/FairVolume.h                   |   36 +-
 base/{ => sim}/FairVolumeList.cxx             |   54 +-
 base/sim/FairVolumeList.h                     |   53 +
 base/sim/README.md                            |    9 +
 base/source/FairFileSource.cxx                |  875 +++++++
 base/source/FairFileSource.h                  |  194 ++
 base/source/FairLmdSource.cxx                 |  269 ++
 base/source/FairLmdSource.h                   |   68 +
 base/source/FairMbsSource.cxx                 |   66 +
 base/source/FairMbsSource.h                   |   45 +
 base/source/FairMbsStreamSource.cxx           |  162 ++
 base/source/FairMbsStreamSource.h             |   57 +
 base/source/FairMixedSource.cxx               |  840 +++++++
 base/source/FairMixedSource.h                 |  228 ++
 base/source/FairOnlineSource.cxx              |   61 +
 base/source/FairOnlineSource.h                |   57 +
 base/source/FairRemoteSource.cxx              |  101 +
 base/source/FairRemoteSource.h                |   51 +
 base/source/FairSource.cxx                    |   47 +
 base/source/FairSource.h                      |   67 +
 base/source/FairUnpack.cxx                    |   34 +
 base/source/FairUnpack.h                      |   58 +
 base/source/MRevBuffer.cxx                    |  975 +++++++
 base/source/MRevBuffer.h                      |  141 ++
 base/source/README.md                         |   11 +
 base/source/exitCli.c                         |   54 +
 base/source/ptrevcomm.h                       |   48 +
 base/source/ptrevmbsdef.h                     |  106 +
 base/source/rclose.c                          |   93 +
 base/source/swaplw.c                          |   67 +
 base/steer/FairAnaSelector.cxx                |  306 +++
 base/steer/FairAnaSelector.h                  |   94 +
 base/steer/FairLinkManager.cxx                |   85 +
 base/steer/FairLinkManager.h                  |   60 +
 base/{ => steer}/FairRadGridManager.cxx       |   33 +-
 base/{ => steer}/FairRadGridManager.h         |   23 +-
 base/{ => steer}/FairRadLenManager.cxx        |   60 +-
 base/{ => steer}/FairRadLenManager.h          |   14 +-
 base/{ => steer}/FairRadMapManager.cxx        |   82 +-
 base/{ => steer}/FairRadMapManager.h          |   15 +-
 base/{ => steer}/FairRingSorter.cxx           |   29 +-
 base/{ => steer}/FairRingSorter.h             |   29 +-
 base/{ => steer}/FairRingSorterTask.cxx       |   41 +-
 base/{ => steer}/FairRingSorterTask.h         |   20 +-
 base/steer/FairRootManager.cxx                | 1311 ++++++++++
 base/{ => steer}/FairRootManager.h            |  334 ++-
 base/{ => steer}/FairRun.cxx                  |   89 +-
 base/{ => steer}/FairRun.h                    |   87 +-
 base/steer/FairRunAna.cxx                     |  917 +++++++
 base/{ => steer}/FairRunAna.h                 |  185 +-
 base/steer/FairRunAnaProof.cxx                |  434 ++++
 base/steer/FairRunAnaProof.h                  |  110 +
 base/steer/FairRunOnline.cxx                  |  627 +++++
 base/steer/FairRunOnline.h                    |  128 +
 base/{ => steer}/FairRunSim.cxx               |  169 +-
 base/{ => steer}/FairRunSim.h                 |   35 +-
 base/{ => steer}/FairTSBufferFunctional.cxx   |   53 +-
 base/{ => steer}/FairTSBufferFunctional.h     |   48 +-
 base/{ => steer}/FairTask.cxx                 |  121 +-
 base/{ => steer}/FairTask.h                   |   37 +-
 base/{ => steer}/FairTrajFilter.cxx           |   40 +-
 base/{ => steer}/FairTrajFilter.h             |   18 +-
 base/{ => steer}/FairWriteoutBuffer.cxx       |   72 +-
 base/{ => steer}/FairWriteoutBuffer.h         |   64 +-
 base/steer/FairWriteoutBufferAbsBasis.h       |   32 +
 base/steer/README.md                          |   20 +
 bbc/CMakeLists.txt                            |    5 +-
 cmake/CMakeLists.txt                          |    7 +
 cmake/README.md                               |    9 +
 cmake/checks/CMakeLists.txt                   |   71 +-
 cmake/checks/c++11-test-__func__-N2340.cpp    |    8 -
 cmake/checks/c++11-test-nullptr-N2431.cpp     |    5 -
 ...-test-static_assert-N1720_fail_compile.cpp |    5 -
 cmake/checks/cxx11-test-__func__.cpp          |    8 +
 ...est-auto-N2546.cpp => cxx11-test-auto.cpp} |   24 +-
 cmake/checks/cxx11-test-auto_fail_compile.cpp |    7 +
 cmake/checks/cxx11-test-auto_ret_type.cpp     |    8 +
 .../cxx11-test-class_override_final.cpp       |   21 +
 ...test-class_override_final_fail_compile.cpp |   25 +
 ...xpr-N2235.cpp => cxx11-test-constexpr.cpp} |   38 +-
 ... => cxx11-test-constructor-delegation.cpp} |    0
 ...est-cstdint.cpp => cxx11-test-cstdint.cpp} |   21 +-
 ...type-N2343.cpp => cxx11-test-decltype.cpp} |   21 +-
 ...xx11-test-funcptr-to-lambda-conversion.cpp |   26 +
 cmake/checks/cxx11-test-initializer_list.cpp  |   27 +
 ...lambda-N2927.cpp => cxx11-test-lambda.cpp} |   10 +-
 ...ong-N1811.cpp => cxx11-test-long_long.cpp} |   14 +-
 cmake/checks/cxx11-test-nullptr.cpp           |    6 +
 ...pp => cxx11-test-nullptr_fail_compile.cpp} |   11 +-
 cmake/checks/cxx11-test-regex.cpp             |   26 +
 cmake/checks/cxx11-test-rvalue-references.cpp |   57 +
 ...8.cpp => cxx11-test-rvalue_references.cpp} |   30 +-
 cmake/checks/cxx11-test-sharedpointer.cpp     |    8 +
 ...N2253.cpp => cxx11-test-sizeof_member.cpp} |   28 +-
 .../checks/cxx11-test-sizeof_member_fail.cpp  |    9 +
 ...N1720.cpp => cxx11-test-static_assert.cpp} |   10 +-
 .../cxx11-test-static_assert_fail_compile.cpp |    5 +
 ....cpp => cxx11-test-variadic_templates.cpp} |   46 +-
 cmake/checks/demo.cpp                         |   46 +-
 cmake/cuda/FindCUDA.cmake                     |    7 +
 cmake/cuda/FindCUDA/make2cmake.cmake          |    9 +-
 cmake/cuda/FindCUDA/parse_cubin.cmake         |   21 +-
 cmake/cuda/FindCUDA/run_nvcc.cmake            |   32 +-
 cmake/modules/CheckCXX11Features.cmake        |  263 +-
 cmake/modules/CheckCompiler.cmake             |  225 +-
 cmake/modules/CheckFortran.cmake              |    7 +
 cmake/modules/FairMacros.cmake                |  132 +-
 cmake/modules/FindCERNLIB.cmake               |    7 +
 cmake/modules/FindDDS.cmake                   |   50 +
 cmake/modules/FindFairRoot.cmake              |   69 +
 cmake/modules/FindFlatBuffers.cmake           |   36 +
 cmake/modules/FindGEANT4DATA.cmake            |  116 -
 cmake/modules/FindGSL.cmake                   |    7 +
 cmake/modules/FindGo.cmake                    |   54 +
 cmake/modules/FindHEPMC.cmake                 |   11 +
 cmake/modules/FindIWYU.cmake                  |    7 +
 cmake/modules/FindMYSQL.cmake                 |   46 +
 cmake/modules/FindMsgpack.cmake               |   27 +
 cmake/modules/FindOracle.cmake                |    7 +
 cmake/modules/FindPGSQL.cmake                 |   59 +
 cmake/modules/FindPLUTO.cmake                 |   11 +
 cmake/modules/FindProtobuf.cmake              |  248 ++
 cmake/modules/FindPythia6.cmake               |   44 +
 cmake/modules/FindPythia8.cmake               |   20 +
 cmake/modules/FindROOT.cmake                  |  463 +---
 cmake/modules/FindSQLITE.cmake                |   39 +
 cmake/modules/FindSSE.cmake                   |    7 +
 cmake/modules/FindTBB.cmake                   |    7 +
 cmake/modules/FindTDAQ.cmake                  |   63 +
 cmake/modules/FindXML2.cmake                  |   34 +
 cmake/modules/FindZeroMQ.cmake                |   93 +-
 cmake/modules/Findglpk.cmake                  |    7 +
 cmake/modules/Findnanomsg.cmake               |   48 +
 cmake/modules/GenerateVersionInfo.cmake       |   51 +-
 cmake/modules/ROOTMacros.cmake                |  269 +-
 cmake/modules/WriteConfigFile.cmake           |  123 +-
 .../{modules => modules_old}/FindCLHEP.cmake  |    7 +
 .../{modules => modules_old}/FindGEANT3.cmake |   13 +-
 .../{modules => modules_old}/FindGEANT4.cmake |    7 +
 cmake/modules_old/FindGEANT4DATA.cmake        |  169 ++
 .../FindGEANT4VMC.cmake                       |    7 +
 .../FindGENERATORS.cmake                      |    0
 .../FindRuleChecker.cmake                     |    0
 cmake/scripts/CMakeLists.txt_roc              |   34 +-
 cmake/scripts/FairVersion.h.default           |    6 +-
 cmake/scripts/FairVersion.h.tmp               |    6 +-
 cmake/scripts/check_system.csh.in             |   28 +
 cmake/scripts/check_system.sh.in              |    7 +-
 cmake/scripts/check_system_mac.csh.in         |   29 +
 cmake/scripts/check_system_mac.sh.in          |    4 +-
 cmake/scripts/config.csh.in                   |   74 +-
 cmake/scripts/config.sh.in                    |   12 +-
 cmake/scripts/fairroot-config.in              |   84 +
 cmake/scripts/generate_dictionary_root.sh.in  |   14 +
 cmake/scripts/root_macro.sh.in                |   12 +-
 cmake/scripts/root_macro_macos.sh.in          |   46 -
 cmake/scripts/run_binary.sh.in                |    4 +-
 cmake/scripts/set_env.sh.in                   |   49 +-
 cmake/scripts/set_env_macos.sh.in             |    2 +
 config/constants.h                            |    2 +
 config/eventdisplay.xml                       |   23 +
 config/rootmanager.dat                        |    1 +
 cpc/CMakeLists.txt                            |   13 +-
 cuda/CMakeLists.txt                           |    7 +
 cuda/README.md                                |    5 +
 cuda/cuda_imp/CMakeLists.txt                  |    7 +
 cuda/cuda_imp/HitTrk.h                        |    7 +
 cuda/interface/CMakeLists.txt                 |    7 +
 cuda/interface/FairCuda.h                     |    7 +
 cuda/interface/cudaLinkDef.h                  |    7 +
 cuda/macro/cuda_info.C                        |    7 +
 datamatch/CMakeLists.txt                      |   60 +
 datamatch/FairMCDataCrawler.cxx               |  246 ++
 datamatch/FairMCDataCrawler.h                 |   71 +
 datamatch/FairMCEntry.cxx                     |   44 +
 datamatch/FairMCEntry.h                       |   72 +
 datamatch/FairMCList.cxx                      |   29 +
 datamatch/FairMCList.h                        |   64 +
 datamatch/FairMCMatch.cxx                     |  405 +++
 datamatch/FairMCMatch.h                       |  139 +
 datamatch/FairMCMatchCreatorTask.cxx          |  150 ++
 datamatch/FairMCMatchCreatorTask.h            |   85 +
 datamatch/FairMCMatchLinkDef.h                |   26 +
 datamatch/FairMCMatchLoaderTask.cxx           |  141 ++
 datamatch/FairMCMatchLoaderTask.h             |   75 +
 datamatch/FairMCMatchSelectorTask.cxx         |  121 +
 datamatch/FairMCMatchSelectorTask.h           |   93 +
 datamatch/FairMCObject.cxx                    |  102 +
 datamatch/FairMCObject.h                      |  133 +
 datamatch/FairMCResult.cxx                    |   36 +
 datamatch/FairMCResult.h                      |   75 +
 datamatch/FairMCStage.cxx                     |   42 +
 datamatch/FairMCStage.h                       |   94 +
 datamatch/FairMCTrackEnumAssociator.h         |   86 +
 datamatch/README.md                           |   14 +
 dch/CMakeLists.txt                            |    7 +-
 emc/CMakeLists.txt                            |   12 +-
 etof/CMakeLists.txt                           |   14 +-
 etof/MpdEtofHitProducerIdeal.cxx              |    1 +
 eventdisplay/CMakeLists.txt                   |  128 +-
 eventdisplay/EventDisplayLinkDef.h            |   31 +-
 eventdisplay/FairBoxSet.cxx                   |    1 +
 eventdisplay/FairBoxSetDraw.cxx               |   20 +-
 eventdisplay/FairBoxSetEditor.h               |    6 +-
 eventdisplay/FairEventManager.cxx             | 1163 +++++----
 eventdisplay/FairEventManager.h               |  116 +-
 eventdisplay/FairEventManagerEditor.cxx       |  849 +++++--
 eventdisplay/FairEventManagerEditor.h         |   84 +-
 eventdisplay/FairHitPointSetDraw.cxx          |   45 +-
 eventdisplay/FairHitPointSetDraw.h            |   14 +-
 eventdisplay/FairMCPointDraw.cxx              |   34 +-
 eventdisplay/FairMCPointDraw.h                |   13 +-
 eventdisplay/FairMCStack.cxx                  |   47 +-
 eventdisplay/FairMCStack.h                    |   10 +-
 eventdisplay/FairMCTracks.cxx                 |  162 +-
 eventdisplay/FairPointSetDraw.cxx             |   68 +-
 eventdisplay/FairPointSetDraw.h               |   44 +-
 eventdisplay/FairWebScreenshots.cxx           |  668 +++++
 eventdisplay/FairWebScreenshots.h             |   96 +
 eventdisplay/bmn/BmnDigitDraw.cxx             |  191 ++
 eventdisplay/bmn/BmnDigitDraw.h               |   63 +
 eventdisplay/bmn/BmnGlobalTrackDraw.cxx       |  341 +++
 eventdisplay/bmn/BmnGlobalTrackDraw.h         |   81 +
 eventdisplay/bmn/BmnTrackDrawH.cxx            |  239 ++
 eventdisplay/bmn/BmnTrackDrawH.h              |   72 +
 eventdisplay/bmn/BmnTrackDrawP.cxx            |  312 +++
 eventdisplay/bmn/BmnTrackDrawP.h              |   72 +
 eventdisplay/bmn/EventBDLinkDef.h             |   37 +
 eventdisplay/bmn/EventBLinkDef.h              |   34 +
 eventdisplay/bmn/FairMCModuleDraw.cxx         |  130 +
 eventdisplay/bmn/FairMCModuleDraw.h           |   61 +
 eventdisplay/coloring.xsd                     |   46 +
 eventdisplay/mpd/EventMDLinkDef.h             |   31 +
 eventdisplay/mpd/EventMLinkDef.h              |   28 +
 eventdisplay/mpd/MpdEmcTowerDraw.cxx          |  511 ++++
 eventdisplay/mpd/MpdEmcTowerDraw.h            |  134 +
 .../MpdGlobalTrackDraw.cxx}                   |   48 +-
 .../MpdGlobalTrackDraw.h}                     |   20 +-
 eventdisplay/mpd/MpdZdcTowerDraw.cxx          |  349 +++
 eventdisplay/mpd/MpdZdcTowerDraw.h            |   85 +
 eventdisplay/raw/RawDataConverter.cxx         |  272 ++
 eventdisplay/raw/RawDataConverter.h           |   44 +
 eventdisplay/raw/RawDataParser.cxx            |  701 ++++++
 eventdisplay/raw/RawDataParser.h              |   69 +
 eventdisplay/raw/RawMWPCDigitDraw.cxx         |  156 ++
 eventdisplay/raw/RawMWPCDigitDraw.h           |   68 +
 eventdisplay/raw/function_set.h               |  479 ++++
 eventdisplay/tdaq/BmnEventMonitor.cxx         |  230 ++
 eventdisplay/tdaq/BmnEventMonitor.h           |   75 +
 eventdisplay/tdaq/EventDLinkDef.h             |   26 +
 fairtools/CMakeLists.txt                      |   27 +-
 fairtools/FairLogger.cxx                      |  188 +-
 fairtools/FairLogger.h                        |   40 +-
 fairtools/FairMonitor.cxx                     |  735 ++++++
 fairtools/FairMonitor.h                       |  110 +
 fairtools/FairSystemInfo.cxx                  |   86 +
 fairtools/FairSystemInfo.h                    |   33 +
 fairtools/FairToolsLinkDef.h                  |    9 +
 fairtools/README.md                           |    6 +
 ffd/CMakeLists.txt                            |   13 +-
 fsa/CMakeLists.txt                            |    7 +-
 gconfig/basiclibs.C                           |    7 +-
 gconfig/constants.h                           |    5 -
 gconfig/g3libs.C                              |    9 +
 gconfig/rootlogon.C                           |   24 +
 geane/CMakeLists.txt                          |   42 +-
 geane/FairGeane.cxx                           |   36 +-
 geane/FairGeane.h                             |   13 +-
 geane/FairGeanePro.cxx                        |  122 +-
 geane/FairGeanePro.h                          |   25 +-
 geane/GeaneLinkDef.h                          |    7 +
 geane/README.md                               |    4 +
 generators/CMakeLists.txt                     |   55 +-
 generators/FairAsciiGenerator.cxx             |   45 +-
 generators/FairAsciiGenerator.h               |   18 +-
 generators/FairBoxGenerator.cxx               |   96 +-
 generators/FairBoxGenerator.h                 |   19 +-
 generators/FairEvtGenGenerator.cxx            |   66 +-
 generators/FairEvtGenGenerator.h              |   18 +-
 generators/FairIonGenerator.cxx               |   69 +-
 generators/FairIonGenerator.h                 |   14 +-
 generators/FairParticleGenerator.cxx          |   11 +-
 generators/FairParticleGenerator.h            |   12 +-
 generators/FairShieldGenerator.cxx            |   78 +-
 generators/FairShieldGenerator.h              |   18 +-
 generators/FairUrqmdGenerator.cxx             |  220 +-
 generators/FairUrqmdGenerator.h               |   29 +-
 generators/GenLinkDef.h                       |   39 +-
 .../Mpd3fdGenerator.cxx                       |    0
 .../Mpd3fdGenerator.h                         |    0
 .../MpdGetNumEvents.cxx                       |   35 +-
 .../MpdGetNumEvents.h                         |   10 +-
 .../MpdHistoGenerator.cxx                     |    0
 .../MpdHistoGenerator.h                       |    0
 .../MpdHypYPtGenerator.cxx                    |    0
 .../MpdHypYPtGenerator.h                      |    0
 .../MpdLAQGSMGenerator.cxx                    |    9 +-
 .../MpdLAQGSMGenerator.h                      |    9 +-
 .../MpdLAQGSM_light_particles.dat             |    0
 .../MpdMCEventHeader.cxx                      |    0
 .../MpdMCEventHeader.h                        |    0
 .../MpdPHSDGenerator.cxx                      |    0
 .../MpdPHSDGenerator.h                        |    4 +
 .../MpdPlutoGenerator.cxx                     |   41 +-
 .../MpdPlutoGenerator.h                       |    0
 .../MpdRainGenerator.cxx                      |    0
 .../MpdRainGenerator.h                        |    0
 .../MpdUrqmdGenerator.cxx                     |   98 +-
 .../MpdUrqmdGenerator.h                       |   29 +-
 .../MpdVHLLEGenerator.cxx                     |    0
 .../MpdVHLLEGenerator.h                       |    0
 geobase/CMakeLists.txt                        |   29 +-
 geobase/FairGeoAsciiIo.cxx                    |   24 +-
 geobase/FairGeoAsciiIo.h                      |   18 +-
 geobase/FairGeoAssembly.cxx                   |   28 +-
 geobase/FairGeoAssembly.h                     |   19 +-
 geobase/FairGeoBasicShape.cxx                 |   23 +-
 geobase/FairGeoBasicShape.h                   |   21 +-
 geobase/FairGeoBrik.cxx                       |   16 +-
 geobase/FairGeoBrik.h                         |   13 +-
 geobase/FairGeoBuilder.cxx                    |    7 +
 geobase/FairGeoBuilder.h                      |   14 +-
 geobase/FairGeoCompositeVolume.cxx            |   24 +-
 geobase/FairGeoCompositeVolume.h              |   11 +-
 geobase/FairGeoCone.cxx                       |   25 +-
 geobase/FairGeoCone.h                         |   21 +-
 geobase/FairGeoCons.cxx                       |   25 +-
 geobase/FairGeoCons.h                         |   20 +-
 geobase/FairGeoEltu.cxx                       |   25 +-
 geobase/FairGeoEltu.h                         |   19 +-
 geobase/FairGeoInterface.cxx                  |   85 +-
 geobase/FairGeoInterface.h                    |   15 +-
 geobase/FairGeoIo.cxx                         |    7 +
 geobase/FairGeoIo.h                           |   11 +-
 geobase/FairGeoLoader.cxx                     |   23 +-
 geobase/FairGeoLoader.h                       |   10 +-
 geobase/FairGeoMatrix.cxx                     |    7 +
 geobase/FairGeoMatrix.h                       |   13 +-
 geobase/FairGeoMedia.cxx                      |   26 +-
 geobase/FairGeoMedia.h                        |   19 +-
 geobase/FairGeoMedium.cxx                     |   32 +-
 geobase/FairGeoMedium.h                       |   19 +-
 geobase/FairGeoNode.cxx                       |   30 +-
 geobase/FairGeoNode.h                         |   41 +-
 geobase/FairGeoOldAsciiIo.cxx                 |   32 +-
 geobase/FairGeoOldAsciiIo.h                   |   22 +-
 geobase/FairGeoPcon.cxx                       |   34 +-
 geobase/FairGeoPcon.h                         |   19 +-
 geobase/FairGeoPgon.cxx                       |   30 +-
 geobase/FairGeoPgon.h                         |   19 +-
 geobase/FairGeoRootBuilder.cxx                |   39 +-
 geobase/FairGeoRootBuilder.h                  |   12 +-
 geobase/FairGeoRotation.cxx                   |   11 +-
 geobase/FairGeoRotation.h                     |   17 +-
 geobase/FairGeoSet.cxx                        |   82 +-
 geobase/FairGeoSet.h                          |   42 +-
 geobase/FairGeoShapes.cxx                     |   13 +-
 geobase/FairGeoShapes.h                       |   22 +-
 geobase/FairGeoSphe.cxx                       |   41 +-
 geobase/FairGeoSphe.h                         |   19 +-
 geobase/FairGeoTorus.cxx                      |   26 +-
 geobase/FairGeoTorus.h                        |   19 +-
 geobase/FairGeoTransform.cxx                  |    7 +
 geobase/FairGeoTransform.h                    |   18 +-
 geobase/FairGeoTrap.cxx                       |   21 +-
 geobase/FairGeoTrap.h                         |   15 +-
 geobase/FairGeoTrd1.cxx                       |   17 +-
 geobase/FairGeoTrd1.h                         |   15 +-
 geobase/FairGeoTube.cxx                       |   25 +-
 geobase/FairGeoTube.h                         |   19 +-
 geobase/FairGeoTubs.cxx                       |   25 +-
 geobase/FairGeoTubs.h                         |   19 +-
 geobase/FairGeoVector.cxx                     |    7 +
 geobase/FairGeoVector.h                       |   25 +-
 geobase/FairGeoVolume.cxx                     |   23 +-
 geobase/FairGeoVolume.h                       |   24 +-
 geobase/GeoBaseLinkDef.h                      |    7 +
 geobase/README.md                             |    9 +
 geometry/emc_tr_400_3_empty.geo               |   10 +
 input/cbmlogo.gif                             |  Bin 5365 -> 0 bytes
 kalman/CMakeLists.txt                         |    5 +-
 lhetrack/CMakeLists.txt                       |   11 +-
 macro/eventdisplay/eventdisplay.C             |   28 +-
 .../examples/coloring_bmn_detector.xml        |   21 +
 .../examples/coloring_bmn_hierarchy.xml       |   15 +
 .../examples/coloring_default.xml             |   10 +
 .../examples/coloring_mpd_detector.xml        |   23 +
 .../examples/coloring_mpd_hierarchy.xml       |   15 +
 macro/eventdisplay/examples/run_exp_offline.C |    7 +
 macro/eventdisplay/examples/run_exp_online.C  |    6 +
 macro/eventdisplay/examples/run_mc_online.C   |    5 +
 macro/eventdisplay/examples/short_ru.doc      |  Bin 0 -> 36352 bytes
 macro/eventdisplay/www/eventIndex.js          |    1 +
 macro/eventdisplay/www/index.html             |   24 +
 macro/eventdisplay/www/index.js               |   31 +
 macro/eventdisplay/www/mime.types             |   19 +
 macro/eventdisplay/www/style.css              |   11 +
 macro/mpd/geometry_stage1.C                   |    4 +
 macro/mpd/mpdloadlibs.C                       |    1 -
 macro/mpd/reco.C                              |   45 +-
 macro/mpd/runMC.C                             |    1 -
 mcstack/CMakeLists.txt                        |   13 +-
 mpdbase/CMakeLists.txt                        |    3 +-
 mpdbase/MpdHelix.cxx                          |    4 +-
 mpddata/CMakeLists.txt                        |    5 +-
 mpdfield/CMakeLists.txt                       |    7 +-
 mpdfield/MpdMultiField.cxx                    |    2 +-
 mpdgenerators/CMakeLists.txt                  |   57 -
 mpdgenerators/MpdgeneratorsLinkDef.h          |   21 -
 ndet/CMakeLists.txt                           |    7 +-
 parbase/CMakeLists.txt                        |   43 +-
 parbase/FairContFact.cxx                      |   29 +-
 parbase/FairContFact.h                        |   20 +-
 parbase/FairDetParAsciiFileIo.cxx             |   22 +-
 parbase/FairDetParAsciiFileIo.h               |   27 +-
 parbase/FairDetParIo.cxx                      |    7 +
 parbase/FairDetParIo.h                        |   11 +-
 parbase/FairDetParRootFileIo.cxx              |  123 +-
 parbase/FairDetParRootFileIo.h                |   14 +-
 parbase/FairGenericParAsciiFileIo.cxx         |  404 +--
 parbase/FairGenericParAsciiFileIo.h           |   18 +-
 parbase/FairGenericParRootFileIo.cxx          |   11 +
 parbase/FairGenericParRootFileIo.h            |   12 +-
 parbase/FairParAsciiFileIo.cxx                |   43 +-
 parbase/FairParAsciiFileIo.h                  |   18 +-
 parbase/FairParGenericSet.cxx                 |   27 +-
 parbase/FairParGenericSet.h                   |   21 +-
 parbase/FairParIo.cxx                         |   21 +-
 parbase/FairParIo.h                           |   14 +-
 parbase/FairParRootFileIo.cxx                 |   76 +-
 parbase/FairParRootFileIo.h                   |   20 +-
 parbase/FairParSet.cxx                        |   83 +-
 parbase/FairParSet.h                          |   39 +-
 parbase/FairParamList.cxx                     |  282 ++-
 parbase/FairParamList.h                       |   44 +-
 parbase/FairRtdbRun.cxx                       |   29 +-
 parbase/FairRtdbRun.h                         |   31 +-
 parbase/FairRuntimeDb.cxx                     |  265 +-
 parbase/FairRuntimeDb.h                       |   32 +-
 parbase/ParBaseLinkDef.h                      |    8 +-
 parbase/README.md                             |    8 +
 passive/CMakeLists.txt                        |   51 +-
 passive/FairCave.cxx                          |   42 +-
 passive/FairCave.h                            |   11 +-
 passive/FairGeoCave.cxx                       |   29 +-
 passive/FairGeoCave.h                         |   25 +-
 passive/FairGeoMagnet.cxx                     |   11 +
 passive/FairGeoMagnet.h                       |   12 +-
 passive/FairGeoPassivePar.cxx                 |   18 +-
 passive/FairGeoPassivePar.h                   |   15 +-
 passive/FairGeoPipe.cxx                       |   23 +-
 passive/FairGeoPipe.h                         |   13 +-
 passive/FairGeoTarget.cxx                     |   11 +
 passive/FairGeoTarget.h                       |   11 +-
 passive/FairMagnet.cxx                        |   40 +-
 passive/FairMagnet.h                          |   18 +-
 passive/FairPassiveContFact.cxx               |   23 +-
 passive/FairPassiveContFact.h                 |   13 +-
 passive/FairPipe.h                            |   14 +-
 passive/FairTarget.cxx                        |   37 +-
 passive/FairTarget.h                          |   12 +-
 passive/PassiveLinkDef.h                      |    7 +
 physics/femto/CMakeLists.txt                  |   11 +-
 physics/femto/MpdFemtoSHCF.cxx                |   32 +-
 sft/CMakeLists.txt                            |    7 +-
 .../MpdGeneralGenerator/CMakeLists.txt        |    3 +-
 strawECT/CMakeLists.txt                       |   11 +-
 strawendcap/CMakeLists.txt                    |   13 +-
 sts/CMakeLists.txt                            |   15 +-
 stt/CMakeLists.txt                            |    7 +-
 tgem/CMakeLists.txt                           |    7 +-
 tof/CMakeLists.txt                            |   14 +-
 tof/MpdTofHitProducer.cxx                     |    2 +
 tof/MpdTofHitProducerIdeal.cxx                |    1 +
 tpc/CMakeLists.txt                            |   14 +-
 trackbase/CMakeLists.txt                      |   56 +-
 trackbase/FairGeaneUtil.cxx                   |   51 +-
 trackbase/FairGeaneUtil.h                     |   20 +-
 trackbase/FairTrackPar.cxx                    |   34 +-
 trackbase/FairTrackPar.h                      |  160 +-
 trackbase/FairTrackParH.cxx                   |   74 +-
 trackbase/FairTrackParH.h                     |   13 +-
 trackbase/FairTrackParP.cxx                   |  109 +-
 trackbase/FairTrackParP.h                     |   15 +-
 trackbase/README.md                           |    8 +
 trackbase/TrackBaseLinkDef.h                  |    7 +
 zdc/CMakeLists.txt                            |   13 +-
 zdc/MpdZdcDigi.h                              |    1 +
 664 files changed, 35072 insertions(+), 20243 deletions(-)
 create mode 100644 MbsAPI/README.md
 delete mode 100644 MbsAPI/clnt_buf_def.h
 delete mode 100644 MbsAPI/err_mask_def.h
 delete mode 100644 MbsAPI/errnum_def.h
 delete mode 100644 MbsAPI/f_evcli.c
 delete mode 100644 MbsAPI/f_evcli.h
 delete mode 100644 MbsAPI/f_find_peaks.c
 delete mode 100644 MbsAPI/f_find_peaks.h
 delete mode 100644 MbsAPI/f_his_hist.c
 delete mode 100644 MbsAPI/f_his_hist.h
 delete mode 100644 MbsAPI/f_his_swpbas.c
 delete mode 100644 MbsAPI/f_his_swpbas.h
 delete mode 100644 MbsAPI/f_his_toupper.c
 delete mode 100644 MbsAPI/f_his_toupper.h
 delete mode 100644 MbsAPI/f_mbs_status.c
 delete mode 100644 MbsAPI/f_radware.c
 delete mode 100644 MbsAPI/f_radware.h
 delete mode 100644 MbsAPI/f_swaplw.c
 delete mode 100644 MbsAPI/f_swaplw.h
 delete mode 100644 MbsAPI/f_ut_compress.c
 delete mode 100644 MbsAPI/f_ut_compress.h
 delete mode 100644 MbsAPI/f_ut_seg_show.c
 delete mode 100644 MbsAPI/f_ut_status.c
 delete mode 100644 MbsAPI/f_ut_status.h
 delete mode 100644 MbsAPI/f_ut_time.c
 delete mode 100644 MbsAPI/f_ut_wild.c
 delete mode 100644 MbsAPI/f_ut_wild.h
 delete mode 100644 MbsAPI/gps_sc_def.h
 delete mode 100644 MbsAPI/m_histo_conv.c
 delete mode 100644 MbsAPI/ml_def.h
 delete mode 100644 MbsAPI/mo_def.h
 delete mode 100644 MbsAPI/s_clnt_filter.h
 delete mode 100644 MbsAPI/s_clnt_filter_swap.h
 delete mode 100644 MbsAPI/s_clntbuf.h
 delete mode 100644 MbsAPI/s_daqst.h
 delete mode 100644 MbsAPI/s_daqst_v2.h
 delete mode 100644 MbsAPI/s_endian.h
 delete mode 100644 MbsAPI/s_errstat.h
 delete mode 100644 MbsAPI/s_filter.h
 delete mode 100644 MbsAPI/s_flt_descr.h
 delete mode 100644 MbsAPI/s_flt_descr_swap.h
 delete mode 100644 MbsAPI/s_head.h
 delete mode 100644 MbsAPI/s_his_comm.h
 delete mode 100644 MbsAPI/s_his_head.h
 delete mode 100644 MbsAPI/s_opc1.h
 delete mode 100644 MbsAPI/s_pat.h
 delete mode 100644 MbsAPI/s_pol_cond.h
 delete mode 100644 MbsAPI/s_set_ml.h
 delete mode 100644 MbsAPI/s_set_mo.h
 delete mode 100644 MbsAPI/s_setup.h
 delete mode 100644 MbsAPI/s_spe.h
 delete mode 100644 MbsAPI/s_win_cond.h
 delete mode 100644 MbsAPI/sbs_def.h
 delete mode 100644 MbsAPI/sys_def.h
 delete mode 100644 MbsAPI/typedefs_nt.h
 delete mode 100644 base/FairAnaSelector.cxx
 delete mode 100644 base/FairAnaSelector.h
 delete mode 100644 base/FairBaseContFact.h
 delete mode 100644 base/FairDetector.cxx
 delete mode 100644 base/FairDoubleHit.cxx
 delete mode 100644 base/FairGenerator.cxx
 delete mode 100644 base/FairLink.h
 delete mode 100644 base/FairMCApplication.cxx
 delete mode 100644 base/FairMCEventHeader.h
 delete mode 100644 base/FairModule.cxx
 delete mode 100644 base/FairModule.h
 delete mode 100644 base/FairPrimaryGenerator.cxx
 delete mode 100644 base/FairPrimaryGenerator.h
 delete mode 100644 base/FairRootManager.cxx
 delete mode 100644 base/FairRunAna.cxx
 delete mode 100644 base/FairRunIdGenerator.h
 delete mode 100644 base/FairRunInfo.h
 delete mode 100644 base/FairTimeStamp.cxx
 delete mode 100644 base/FairVTrack.cxx
 delete mode 100644 base/FairVTrack.h
 delete mode 100644 base/FairVolumeList.h
 delete mode 100644 base/FairWriteoutBufferAbsBasis.h
 create mode 100644 base/README.md
 create mode 100644 base/event/FairEventBuilder.cxx
 create mode 100644 base/event/FairEventBuilder.h
 create mode 100644 base/event/FairEventBuilderManager.cxx
 create mode 100644 base/event/FairEventBuilderManager.h
 rename base/{ => event}/FairEventHeader.cxx (60%)
 rename base/{ => event}/FairEventHeader.h (72%)
 rename base/{ => event}/FairFileHeader.cxx (59%)
 rename base/{ => event}/FairFileHeader.h (66%)
 rename base/{ => event}/FairFileInfo.cxx (60%)
 rename base/{ => event}/FairFileInfo.h (59%)
 rename base/{ => event}/FairHit.cxx (63%)
 rename base/{ => event}/FairHit.h (63%)
 rename base/{ => event}/FairLink.cxx (66%)
 create mode 100644 base/event/FairLink.h
 rename base/{ => event}/FairMCEventHeader.cxx (97%)
 create mode 100644 base/event/FairMCEventHeader.h
 rename base/{ => event}/FairMCPoint.cxx (50%)
 rename base/{ => event}/FairMCPoint.h (64%)
 rename base/{ => event}/FairMesh.cxx (73%)
 rename base/{ => event}/FairMesh.h (76%)
 rename base/{ => event}/FairMultiLinkedData.cxx (59%)
 rename base/{ => event}/FairMultiLinkedData.h (69%)
 create mode 100644 base/event/FairMultiLinkedData_Interface.cxx
 create mode 100644 base/event/FairMultiLinkedData_Interface.h
 rename base/{ => event}/FairRadLenPoint.cxx (75%)
 rename base/{ => event}/FairRadLenPoint.h (75%)
 rename base/{ => event}/FairRadMapPoint.cxx (77%)
 rename base/{ => event}/FairRadMapPoint.h (77%)
 create mode 100644 base/event/FairRecoEventHeader.cxx
 create mode 100644 base/event/FairRecoEventHeader.h
 rename base/{ => event}/FairRunInfo.cxx (71%)
 create mode 100644 base/event/FairRunInfo.h
 create mode 100644 base/event/FairTimeStamp.cxx
 rename base/{ => event}/FairTimeStamp.h (50%)
 rename base/{ => event}/FairTrackParam.cxx (77%)
 rename base/{ => event}/FairTrackParam.h (78%)
 create mode 100644 base/event/README.md
 rename base/{ => field}/FairField.cxx (73%)
 rename base/{ => field}/FairField.h (74%)
 rename base/{ => field}/FairFieldFactory.cxx (51%)
 rename base/{ => field}/FairFieldFactory.h (60%)
 rename base/{ => field}/FairRKPropagator.cxx (93%)
 rename base/{ => field}/FairRKPropagator.h (66%)
 create mode 100644 base/field/README.md
 rename base/{ => sim}/FairBaseContFact.cxx (61%)
 create mode 100644 base/sim/FairBaseContFact.h
 rename base/{ => sim}/FairBaseParSet.cxx (61%)
 rename base/{ => sim}/FairBaseParSet.h (71%)
 create mode 100644 base/sim/FairDetector.cxx
 rename base/{ => sim}/FairDetector.h (66%)
 create mode 100644 base/sim/FairDoubleHit.cxx
 rename base/{ => sim}/FairDoubleHit.h (72%)
 rename base/{ => sim}/FairGeaneApplication.cxx (61%)
 rename base/{ => sim}/FairGeaneApplication.h (74%)
 create mode 100644 base/sim/FairGenerator.cxx
 rename base/{ => sim}/FairGenerator.h (62%)
 rename base/{ => sim}/FairGenericStack.cxx (55%)
 rename base/{ => sim}/FairGenericStack.h (62%)
 create mode 100644 base/sim/FairGeoParSet.cxx
 create mode 100644 base/sim/FairGeoParSet.h
 rename base/{ => sim}/FairIon.cxx (61%)
 rename base/{ => sim}/FairIon.h (74%)
 create mode 100644 base/sim/FairMCApplication.cxx
 rename base/{ => sim}/FairMCApplication.h (82%)
 create mode 100644 base/sim/FairModule.cxx
 create mode 100644 base/sim/FairModule.h
 rename base/{ => sim}/FairParticle.cxx (85%)
 rename base/{ => sim}/FairParticle.h (77%)
 create mode 100644 base/sim/FairPrimaryGenerator.cxx
 create mode 100644 base/sim/FairPrimaryGenerator.h
 rename base/{ => sim}/FairRunIdGenerator.cxx (77%)
 create mode 100644 base/sim/FairRunIdGenerator.h
 rename base/{ => sim}/FairVolume.cxx (70%)
 rename base/{ => sim}/FairVolume.h (57%)
 rename base/{ => sim}/FairVolumeList.cxx (51%)
 create mode 100644 base/sim/FairVolumeList.h
 create mode 100644 base/sim/README.md
 create mode 100644 base/source/FairFileSource.cxx
 create mode 100644 base/source/FairFileSource.h
 create mode 100644 base/source/FairLmdSource.cxx
 create mode 100644 base/source/FairLmdSource.h
 create mode 100644 base/source/FairMbsSource.cxx
 create mode 100644 base/source/FairMbsSource.h
 create mode 100644 base/source/FairMbsStreamSource.cxx
 create mode 100644 base/source/FairMbsStreamSource.h
 create mode 100644 base/source/FairMixedSource.cxx
 create mode 100644 base/source/FairMixedSource.h
 create mode 100644 base/source/FairOnlineSource.cxx
 create mode 100644 base/source/FairOnlineSource.h
 create mode 100644 base/source/FairRemoteSource.cxx
 create mode 100644 base/source/FairRemoteSource.h
 create mode 100644 base/source/FairSource.cxx
 create mode 100644 base/source/FairSource.h
 create mode 100644 base/source/FairUnpack.cxx
 create mode 100644 base/source/FairUnpack.h
 create mode 100644 base/source/MRevBuffer.cxx
 create mode 100644 base/source/MRevBuffer.h
 create mode 100644 base/source/README.md
 create mode 100644 base/source/exitCli.c
 create mode 100644 base/source/ptrevcomm.h
 create mode 100644 base/source/ptrevmbsdef.h
 create mode 100644 base/source/rclose.c
 create mode 100644 base/source/swaplw.c
 create mode 100644 base/steer/FairAnaSelector.cxx
 create mode 100644 base/steer/FairAnaSelector.h
 create mode 100644 base/steer/FairLinkManager.cxx
 create mode 100644 base/steer/FairLinkManager.h
 rename base/{ => steer}/FairRadGridManager.cxx (75%)
 rename base/{ => steer}/FairRadGridManager.h (73%)
 rename base/{ => steer}/FairRadLenManager.cxx (53%)
 rename base/{ => steer}/FairRadLenManager.h (76%)
 rename base/{ => steer}/FairRadMapManager.cxx (59%)
 rename base/{ => steer}/FairRadMapManager.h (77%)
 rename base/{ => steer}/FairRingSorter.cxx (71%)
 rename base/{ => steer}/FairRingSorter.h (58%)
 rename base/{ => steer}/FairRingSorterTask.cxx (62%)
 rename base/{ => steer}/FairRingSorterTask.h (73%)
 create mode 100644 base/steer/FairRootManager.cxx
 rename base/{ => steer}/FairRootManager.h (50%)
 rename base/{ => steer}/FairRun.cxx (54%)
 rename base/{ => steer}/FairRun.h (57%)
 create mode 100644 base/steer/FairRunAna.cxx
 rename base/{ => steer}/FairRunAna.h (63%)
 create mode 100644 base/steer/FairRunAnaProof.cxx
 create mode 100644 base/steer/FairRunAnaProof.h
 create mode 100644 base/steer/FairRunOnline.cxx
 create mode 100644 base/steer/FairRunOnline.h
 rename base/{ => steer}/FairRunSim.cxx (66%)
 rename base/{ => steer}/FairRunSim.h (83%)
 rename base/{ => steer}/FairTSBufferFunctional.cxx (81%)
 rename base/{ => steer}/FairTSBufferFunctional.h (78%)
 rename base/{ => steer}/FairTask.cxx (53%)
 rename base/{ => steer}/FairTask.h (68%)
 rename base/{ => steer}/FairTrajFilter.cxx (81%)
 rename base/{ => steer}/FairTrajFilter.h (90%)
 rename base/{ => steer}/FairWriteoutBuffer.cxx (65%)
 rename base/{ => steer}/FairWriteoutBuffer.h (60%)
 create mode 100644 base/steer/FairWriteoutBufferAbsBasis.h
 create mode 100644 base/steer/README.md
 create mode 100644 cmake/README.md
 mode change 100755 => 100644 cmake/checks/CMakeLists.txt
 delete mode 100755 cmake/checks/c++11-test-__func__-N2340.cpp
 delete mode 100755 cmake/checks/c++11-test-nullptr-N2431.cpp
 delete mode 100755 cmake/checks/c++11-test-static_assert-N1720_fail_compile.cpp
 create mode 100755 cmake/checks/cxx11-test-__func__.cpp
 rename cmake/checks/{c++11-test-auto-N2546.cpp => cxx11-test-auto.cpp} (93%)
 create mode 100644 cmake/checks/cxx11-test-auto_fail_compile.cpp
 create mode 100644 cmake/checks/cxx11-test-auto_ret_type.cpp
 create mode 100644 cmake/checks/cxx11-test-class_override_final.cpp
 create mode 100644 cmake/checks/cxx11-test-class_override_final_fail_compile.cpp
 rename cmake/checks/{c++11-test-constexpr-N2235.cpp => cxx11-test-constexpr.cpp} (92%)
 rename cmake/checks/{c++11-test-constructor-delegation-N1986.cpp => cxx11-test-constructor-delegation.cpp} (100%)
 rename cmake/checks/{c++11-test-cstdint.cpp => cxx11-test-cstdint.cpp} (87%)
 rename cmake/checks/{c++11-test-decltype-N2343.cpp => cxx11-test-decltype.cpp} (91%)
 create mode 100644 cmake/checks/cxx11-test-funcptr-to-lambda-conversion.cpp
 create mode 100644 cmake/checks/cxx11-test-initializer_list.cpp
 rename cmake/checks/{c++11-test-lambda-N2927.cpp => cxx11-test-lambda.cpp} (93%)
 rename cmake/checks/{c++11-test-long_long-N1811.cpp => cxx11-test-long_long.cpp} (94%)
 create mode 100755 cmake/checks/cxx11-test-nullptr.cpp
 rename cmake/checks/{c++11-test-nullptr-N2431_fail_compile.cpp => cxx11-test-nullptr_fail_compile.cpp} (67%)
 create mode 100644 cmake/checks/cxx11-test-regex.cpp
 create mode 100644 cmake/checks/cxx11-test-rvalue-references.cpp
 rename cmake/checks/{c++11-test-rvalue_references-N2118.cpp => cxx11-test-rvalue_references.cpp} (91%)
 create mode 100755 cmake/checks/cxx11-test-sharedpointer.cpp
 rename cmake/checks/{c++11-test-sizeof_member-N2253.cpp => cxx11-test-sizeof_member.cpp} (71%)
 create mode 100644 cmake/checks/cxx11-test-sizeof_member_fail.cpp
 rename cmake/checks/{c++11-test-static_assert-N1720.cpp => cxx11-test-static_assert.cpp} (82%)
 create mode 100755 cmake/checks/cxx11-test-static_assert_fail_compile.cpp
 rename cmake/checks/{c++11-test-variadic_templates-N2555.cpp => cxx11-test-variadic_templates.cpp} (93%)
 mode change 100755 => 100644 cmake/cuda/FindCUDA/make2cmake.cmake
 mode change 100755 => 100644 cmake/cuda/FindCUDA/run_nvcc.cmake
 create mode 100644 cmake/modules/FindDDS.cmake
 create mode 100644 cmake/modules/FindFairRoot.cmake
 create mode 100644 cmake/modules/FindFlatBuffers.cmake
 delete mode 100644 cmake/modules/FindGEANT4DATA.cmake
 create mode 100644 cmake/modules/FindGo.cmake
 create mode 100644 cmake/modules/FindMYSQL.cmake
 create mode 100644 cmake/modules/FindMsgpack.cmake
 create mode 100644 cmake/modules/FindPGSQL.cmake
 create mode 100644 cmake/modules/FindProtobuf.cmake
 create mode 100644 cmake/modules/FindPythia6.cmake
 create mode 100644 cmake/modules/FindSQLITE.cmake
 create mode 100644 cmake/modules/FindTDAQ.cmake
 create mode 100644 cmake/modules/FindXML2.cmake
 create mode 100644 cmake/modules/Findnanomsg.cmake
 rename cmake/{modules => modules_old}/FindCLHEP.cmake (87%)
 rename cmake/{modules => modules_old}/FindGEANT3.cmake (82%)
 rename cmake/{modules => modules_old}/FindGEANT4.cmake (78%)
 create mode 100644 cmake/modules_old/FindGEANT4DATA.cmake
 rename cmake/{modules => modules_old}/FindGEANT4VMC.cmake (87%)
 rename cmake/{modules => modules_old}/FindGENERATORS.cmake (100%)
 rename cmake/{modules => modules_old}/FindRuleChecker.cmake (100%)
 create mode 100644 cmake/scripts/check_system.csh.in
 create mode 100644 cmake/scripts/check_system_mac.csh.in
 create mode 100644 cmake/scripts/fairroot-config.in
 create mode 100755 cmake/scripts/generate_dictionary_root.sh.in
 delete mode 100644 cmake/scripts/root_macro_macos.sh.in
 create mode 100644 config/constants.h
 create mode 100644 config/eventdisplay.xml
 create mode 100644 config/rootmanager.dat
 create mode 100644 cuda/README.md
 create mode 100644 datamatch/CMakeLists.txt
 create mode 100644 datamatch/FairMCDataCrawler.cxx
 create mode 100644 datamatch/FairMCDataCrawler.h
 create mode 100644 datamatch/FairMCEntry.cxx
 create mode 100644 datamatch/FairMCEntry.h
 create mode 100644 datamatch/FairMCList.cxx
 create mode 100644 datamatch/FairMCList.h
 create mode 100644 datamatch/FairMCMatch.cxx
 create mode 100644 datamatch/FairMCMatch.h
 create mode 100644 datamatch/FairMCMatchCreatorTask.cxx
 create mode 100644 datamatch/FairMCMatchCreatorTask.h
 create mode 100644 datamatch/FairMCMatchLinkDef.h
 create mode 100644 datamatch/FairMCMatchLoaderTask.cxx
 create mode 100644 datamatch/FairMCMatchLoaderTask.h
 create mode 100644 datamatch/FairMCMatchSelectorTask.cxx
 create mode 100644 datamatch/FairMCMatchSelectorTask.h
 create mode 100644 datamatch/FairMCObject.cxx
 create mode 100644 datamatch/FairMCObject.h
 create mode 100644 datamatch/FairMCResult.cxx
 create mode 100644 datamatch/FairMCResult.h
 create mode 100644 datamatch/FairMCStage.cxx
 create mode 100644 datamatch/FairMCStage.h
 create mode 100644 datamatch/FairMCTrackEnumAssociator.h
 create mode 100644 datamatch/README.md
 create mode 100755 eventdisplay/FairWebScreenshots.cxx
 create mode 100755 eventdisplay/FairWebScreenshots.h
 create mode 100644 eventdisplay/bmn/BmnDigitDraw.cxx
 create mode 100644 eventdisplay/bmn/BmnDigitDraw.h
 create mode 100644 eventdisplay/bmn/BmnGlobalTrackDraw.cxx
 create mode 100644 eventdisplay/bmn/BmnGlobalTrackDraw.h
 create mode 100644 eventdisplay/bmn/BmnTrackDrawH.cxx
 create mode 100644 eventdisplay/bmn/BmnTrackDrawH.h
 create mode 100644 eventdisplay/bmn/BmnTrackDrawP.cxx
 create mode 100644 eventdisplay/bmn/BmnTrackDrawP.h
 create mode 100644 eventdisplay/bmn/EventBDLinkDef.h
 create mode 100644 eventdisplay/bmn/EventBLinkDef.h
 create mode 100644 eventdisplay/bmn/FairMCModuleDraw.cxx
 create mode 100644 eventdisplay/bmn/FairMCModuleDraw.h
 create mode 100644 eventdisplay/coloring.xsd
 create mode 100644 eventdisplay/mpd/EventMDLinkDef.h
 create mode 100644 eventdisplay/mpd/EventMLinkDef.h
 create mode 100644 eventdisplay/mpd/MpdEmcTowerDraw.cxx
 create mode 100644 eventdisplay/mpd/MpdEmcTowerDraw.h
 rename eventdisplay/{MpdTrackDraw.cxx => mpd/MpdGlobalTrackDraw.cxx} (86%)
 rename eventdisplay/{MpdTrackDraw.h => mpd/MpdGlobalTrackDraw.h} (79%)
 create mode 100644 eventdisplay/mpd/MpdZdcTowerDraw.cxx
 create mode 100644 eventdisplay/mpd/MpdZdcTowerDraw.h
 create mode 100644 eventdisplay/raw/RawDataConverter.cxx
 create mode 100644 eventdisplay/raw/RawDataConverter.h
 create mode 100644 eventdisplay/raw/RawDataParser.cxx
 create mode 100644 eventdisplay/raw/RawDataParser.h
 create mode 100644 eventdisplay/raw/RawMWPCDigitDraw.cxx
 create mode 100644 eventdisplay/raw/RawMWPCDigitDraw.h
 create mode 100644 eventdisplay/raw/function_set.h
 create mode 100755 eventdisplay/tdaq/BmnEventMonitor.cxx
 create mode 100644 eventdisplay/tdaq/BmnEventMonitor.h
 create mode 100644 eventdisplay/tdaq/EventDLinkDef.h
 create mode 100644 fairtools/FairMonitor.cxx
 create mode 100644 fairtools/FairMonitor.h
 create mode 100644 fairtools/FairSystemInfo.cxx
 create mode 100644 fairtools/FairSystemInfo.h
 create mode 100644 fairtools/README.md
 delete mode 100644 gconfig/constants.h
 create mode 100644 gconfig/rootlogon.C
 create mode 100644 geane/README.md
 rename {mpdgenerators => generators}/Mpd3fdGenerator.cxx (100%)
 rename {mpdgenerators => generators}/Mpd3fdGenerator.h (100%)
 rename {mpdgenerators => generators}/MpdGetNumEvents.cxx (90%)
 rename {mpdgenerators => generators}/MpdGetNumEvents.h (85%)
 rename {mpdgenerators => generators}/MpdHistoGenerator.cxx (100%)
 rename {mpdgenerators => generators}/MpdHistoGenerator.h (100%)
 rename {mpdgenerators => generators}/MpdHypYPtGenerator.cxx (100%)
 rename {mpdgenerators => generators}/MpdHypYPtGenerator.h (100%)
 rename {mpdgenerators => generators}/MpdLAQGSMGenerator.cxx (98%)
 rename {mpdgenerators => generators}/MpdLAQGSMGenerator.h (94%)
 rename {mpdgenerators => generators}/MpdLAQGSM_light_particles.dat (100%)
 rename {mpdgenerators => generators}/MpdMCEventHeader.cxx (100%)
 rename {mpdgenerators => generators}/MpdMCEventHeader.h (100%)
 rename {mpdgenerators => generators}/MpdPHSDGenerator.cxx (100%)
 rename {mpdgenerators => generators}/MpdPHSDGenerator.h (96%)
 rename {mpdgenerators => generators}/MpdPlutoGenerator.cxx (85%)
 rename {mpdgenerators => generators}/MpdPlutoGenerator.h (100%)
 rename {mpdgenerators => generators}/MpdRainGenerator.cxx (100%)
 rename {mpdgenerators => generators}/MpdRainGenerator.h (100%)
 rename {mpdgenerators => generators}/MpdUrqmdGenerator.cxx (79%)
 rename {mpdgenerators => generators}/MpdUrqmdGenerator.h (79%)
 rename {mpdgenerators => generators}/MpdVHLLEGenerator.cxx (100%)
 rename {mpdgenerators => generators}/MpdVHLLEGenerator.h (100%)
 create mode 100644 geobase/README.md
 create mode 100644 geometry/emc_tr_400_3_empty.geo
 delete mode 100644 input/cbmlogo.gif
 create mode 100644 macro/eventdisplay/examples/coloring_bmn_detector.xml
 create mode 100644 macro/eventdisplay/examples/coloring_bmn_hierarchy.xml
 create mode 100644 macro/eventdisplay/examples/coloring_default.xml
 create mode 100644 macro/eventdisplay/examples/coloring_mpd_detector.xml
 create mode 100644 macro/eventdisplay/examples/coloring_mpd_hierarchy.xml
 create mode 100644 macro/eventdisplay/examples/run_exp_offline.C
 create mode 100644 macro/eventdisplay/examples/run_exp_online.C
 create mode 100644 macro/eventdisplay/examples/run_mc_online.C
 create mode 100644 macro/eventdisplay/examples/short_ru.doc
 create mode 100755 macro/eventdisplay/www/eventIndex.js
 create mode 100755 macro/eventdisplay/www/index.html
 create mode 100755 macro/eventdisplay/www/index.js
 create mode 100755 macro/eventdisplay/www/mime.types
 create mode 100755 macro/eventdisplay/www/style.css
 delete mode 100644 mpdgenerators/CMakeLists.txt
 delete mode 100644 mpdgenerators/MpdgeneratorsLinkDef.h
 create mode 100644 parbase/README.md
 create mode 100644 trackbase/README.md

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f78ab6..4378da7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,6 +8,18 @@
 # Check if cmake has the required version
 CMAKE_MINIMUM_REQUIRED(VERSION  2.6.2 FATAL_ERROR)
 
+### CMP0025   Compiler id for Apple Clang is now AppleClang.
+### CMP0042   MACOSX_RPATH is enabled by default.
+
+foreach(p
+  CMP0025 # CMake 3.0
+  CMP0042 # CMake 3.0
+  )
+  if(POLICY ${p})
+  cmake_policy(SET ${p} NEW)
+  endif()
+endforeach()
+
 # Set name of our project to "MPDROOT". Has to be done
 # after check of cmake version                        
 project(MPDROOT)
@@ -37,8 +49,8 @@ Check_Compiler()
 set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
 set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
 
-Option(USE_PATH_INFO "Information from PATH and LD_LIBRARY_PATH are
-used." OFF)
+Option(USE_PATH_INFO "Information from PATH and LD_LIBRARY_PATH are used." ON)
+
 If(USE_PATH_INFO)
   Set(PATH $ENV{PATH})
   If (APPLE)
@@ -49,8 +61,10 @@ If(USE_PATH_INFO)
 EndIf(USE_PATH_INFO)
 
 # Check if the user wants to build the project in the source
+# directory and if the install directory is different from the build
 # directory
 CHECK_OUT_OF_SOURCE_BUILD()
+CHECK_INSTALL_DIRECTORY()
 
 # Check if we are on an UNIX system. If not stop with an error
 # message
@@ -66,61 +80,86 @@ ENDIF(NOT DEFINED ENV{SIMPATH})
 STRING(REGEX MATCHALL "[^:]+" PATH $ENV{PATH})
 SET(SIMPATH $ENV{SIMPATH})
 
+# Check if the external packages are installed into a separate install
+# directory
+CHECK_EXTERNAL_PACKAGE_INSTALL_DIR()
+
 # searches for needed packages
 # REQUIRED means that cmake will stop if this packages are not found
 # For example the framework can run without GEANT4, but ROOT is
 # mandatory
-find_package(ROOT REQUIRED)
-find_package(PLUTO REQUIRED)
-find_package(GENERATORS REQUIRED)
+find_package(ROOT 5.34.28 REQUIRED)
+find_package(Pythia6)
+
+set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules_old" ${CMAKE_MODULE_PATH})
 find_package(GEANT3 REQUIRED)
 find_package(GEANT4)
 find_package(GEANT4DATA)
 find_package(GEANT4VMC)
 find_package(CLHEP)
 find_package(RuleChecker)
-#find_package(Oracle)
-#find_package(CUDA REQUIRED)
-
-  Set(Boost_NO_SYSTEM_PATHS TRUE)
-  Set(Boost_NO_BOOST_CMAKE TRUE)
-#  set(Boost_DEBUG TRUE)
-  If(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
-    set(BOOST_ROOT ${SIMPATH})
-    set(GSL_DIR ${SIMPATH})
-  Else(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
-    set(BOOST_ROOT ${SIMPATH}/basics/boost)
-    set(GSL_DIR ${SIMPATH}/basics/gsl)
-  EndIf(${ROOT_LIBRARY_DIR} MATCHES /lib/root)
-  Message("-- Looking for Boost ...")
-  # If an older version of boost is found both of the variables below are
-  # cached and in a second cmake run, a good boost version is found even
-  # if the version is to old.
-  # To overcome this problem both variables are cleared before checking
-  # for boost.
-  Unset(Boost_INCLUDE_DIR CACHE)
-  Unset(Boost_LIBRARY_DIRS CACHE)
-  find_package(Boost 1.41)
-  If (Boost_FOUND)
-    Set(Boost_Avail 1)
-  Else (Boost_FOUND)
-    Set(Boost_Avail 0)
-  EndIf (Boost_FOUND)
+find_package(SSE)
+find_package(PLUTO REQUIRED)
+find_package(GENERATORS REQUIRED)
+find_package(XML2 REQUIRED)
+find_package(TDAQ)
+
+#find_package(CUDA)
+#find_package(IWYU)
+#find_package(ZeroMQ)
+#find_package(Protobuf)
+#find_package(DDS)
+
+If(FAIRSOFT_EXTERN)
+  set(BOOST_ROOT ${SIMPATH})
+  set(GSL_DIR ${SIMPATH})
+Else(FAIRSOFT_EXTERN)
+  set(BOOST_ROOT ${SIMPATH}/basics/boost)
+  set(GSL_DIR ${SIMPATH}/basics/gsl)
+EndIf(FAIRSOFT_EXTERN)
+
+Set(Boost_NO_SYSTEM_PATHS TRUE)
+Set(Boost_NO_BOOST_CMAKE TRUE)
+Message("-- Looking for Boost ...")
+# If an older version of boost is found both of the variables below are
+# cached and in a second cmake run, a good boost version is found even
+# if the version is to old.
+# To overcome this problem both variables are cleared before checking
+# for boost.
+Unset(Boost_INCLUDE_DIR CACHE)
+Unset(Boost_LIBRARY_DIRS CACHE)
+find_package(Boost 1.41 COMPONENTS thread system timer program_options random filesystem chrono exception regex)
+If (Boost_FOUND)
+  Set(Boost_Avail 1)
+  Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${Boost_LIBRARY_DIR})
+Else (Boost_FOUND)
+  Set(Boost_Avail 0)
+EndIf (Boost_FOUND)
 
 # Set the library version in the main CMakeLists.txt
-SET(FAIRROOT_MAJOR_VERSION 0)
-SET(FAIRROOT_MINOR_VERSION 0)
+SET(FAIRROOT_MAJOR_VERSION 15)
+SET(FAIRROOT_MINOR_VERSION 11)
 SET(FAIRROOT_PATCH_VERSION 0)
 SET(FAIRROOT_VERSION "${FAIRROOT_MAJOR_VERSION}.${FAIRROOT_MINOR_VERSION}.${FAIRROOT_PATCH_VERSION}")
-SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
-    VERSION "${FAIRROOT_VERSION}"
-    SOVERSION "${FAIRROOT_MAJOR_VERSION}"
-    SUFFIX ".so"
-)
-
-SET(FAIRLIBDIR ${CMAKE_BINARY_DIR}/lib)  
-SET(LD_LIBRARY_PATH ${FAIRLIBDIR} ${LD_LIBRARY_PATH})
+
+If(ROOT_FOUND_VERSION LESS 59999)
+  SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
+      VERSION "${FAIRROOT_VERSION}"
+      SOVERSION "${FAIRROOT_MAJOR_VERSION}"
+      SUFFIX ".so"
+  )
+Else()
+  SET(FAIRROOT_LIBRARY_PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES}
+      VERSION "${FAIRROOT_VERSION}"
+      SOVERSION "${FAIRROOT_MAJOR_VERSION}"
+  )
+EndIf()
+
+# Set some useful variables
+SetBasicVariables()
 SET(PATH ${EXECUTABLE_OUTPUT_PATH} ${PATH})
+set(MPDROOT TRUE)
+add_definitions(-DMPDROOT)
 
 # Recurse into the given subdirectories.  This does not actually
 # cause another cmake executable to run.  The same process will walk through
@@ -132,15 +171,17 @@ add_subdirectory (parbase)
 add_subdirectory (generators)
 add_subdirectory (geane)
 add_subdirectory (trackbase)
-#add_subdirectory (cuda)
 add_subdirectory (eventdisplay)
+
 add_subdirectory (MbsAPI)
-add_subdirectory (mpdbase)
+add_subdirectory (datamatch)
+
+#add_subdirectory (cuda)
 add_subdirectory (passive)
-add_subdirectory (mcstack)
-add_subdirectory (mpdfield)
+add_subdirectory (mpdbase)
 add_subdirectory (mpddata)
-add_subdirectory (mpdgenerators)
+add_subdirectory (mpdfield)
+add_subdirectory (mcstack)
 add_subdirectory (lhetrack)
 add_subdirectory (kalman)
 add_subdirectory (macro)
@@ -177,11 +218,10 @@ if(BUILD_DOXYGEN)
 endif(BUILD_DOXYGEN)
 
 if(RULE_CHECKER_FOUND)
-
   ADD_CUSTOM_TARGET(RULES 
      COMMAND ${RULE_CHECKER_SCRIPT1} ${CMAKE_BINARY_DIR} viol > violations.html
      DEPENDS $ENV{ALL_RULES})
-
 endif(RULE_CHECKER_FOUND)
 
 WRITE_CONFIG_FILE(config.sh)
+SET(ROOT_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/include)
diff --git a/MbsAPI/CMakeLists.txt b/MbsAPI/CMakeLists.txt
index 05b17c8..e10558a 100644
--- a/MbsAPI/CMakeLists.txt
+++ b/MbsAPI/CMakeLists.txt
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
@@ -9,102 +16,52 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
    ADD_DEFINITIONS(-DDarwin  -DSYSTEM64  -D_LARGEFILE64_SOURCE)
 endif (CMAKE_SYSTEM_NAME MATCHES Darwin)
 
-set(INCLUDE_DIRECTORIES
-    ${ROOT_INCLUDE_DIR}
-    ${CMAKE_SOURCE_DIR}/MbsAPI
-   )
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/MbsAPI
+)
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR}
+)
 
-set(LINK_DIRECTORIES
-    ${ROOT_LIBRARY_DIR}
-   )
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-link_directories( ${LINK_DIRECTORIES})
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
+)
+
+Link_Directories(${LINK_DIRECTORIES})
 
 # List of source files
-set(MBSAPI_SRCS
-    f_evcli.c
-    f_evt.c
-    f_find_peaks.c
-    fLmd.c
-    f_radware.c
-    f_ut_utime.c
-    f_ut_wild.c
-    m_histo_conv.c
-    f_his_hist.c
-    f_his_swpbas.c
-    f_his_toupper.c
-    f_mbs_status.c
-    f_stccomm.c
-    f_swaplw.c
-    f_ut_compress.c
-    f_ut_seg_show.c
-    f_ut_status.c
-    f_ut_time.c
+Set(MBSAPI_SRCS
+  f_evt.c
+  fLmd.c
+  f_ut_utime.c
+  f_stccomm.c
+)
 
-   )
 # list of header files
-set(MBSAPI_HEADERS
-    clnt_buf_def.h
-    fLmd.h
-    gps_sc_def.h
-    s_clntbuf.h
-    s_evhe.h
-    s_filter.h
-    sMbs.h
-    s_spe.h
-    s_ves10_1_swap.h
-    f_evcli.h
-    f_radware.h
-    mo_def.h
-    s_clnt_filter.h
-    s_evhe_swap.h
-    s_flt_descr.h
-    s_opc1.h
-    s_ve10_1.h
-    s_win_cond.h
-    f_evt.h
-    f_ut_utime.h
-    s_bufhe.h
-    s_clnt_filter_swap.h
-    s_filhe.h
-    s_flt_descr_swap.h
-    s_pat.h
-    s_ve10_1_swap.h
-    f_find_peaks.h
-    f_ut_wild.h
-    s_bufhe_swap.h
-    s_errstat.h
-    s_filhe_swap.h
-    s_head.h
-    s_pol_cond.h
-    s_ves10_1.h
-    err_mask_def.h
-    f_his_hist.h
-    f_his_toupper.h
-    f_swaplw.h
-    f_ut_status.h
-    portnum_def.h
-    s_daqst.h
-    s_endian.h
-    s_his_head.h
-    s_set_mo.h
-    s_stdint.h
-    typedefs.h
-    errnum_def.h
-    f_his_swpbas.h
-    f_stccomm.h
-    f_ut_compress.h
-    ml_def.h
-    sbs_def.h
-    s_daqst_v2.h
-    s_his_comm.h
-    s_set_ml.h
-    s_setup.h
-    sys_def.h
-    typedefs_nt.h
-   )
+Set(MBSAPI_HEADERS
+  fLmd.h
+  s_evhe.h
+  s_evhe_swap.h
+  sMbs.h
+  s_ves10_1.h
+  s_ves10_1_swap.h
+  s_ve10_1.h
+  s_ve10_1_swap.h
+  f_evt.h
+  f_ut_utime.h
+  s_bufhe.h
+  s_bufhe_swap.h
+  s_filhe.h
+  s_filhe_swap.h
+  portnum_def.h
+  s_stdint.h
+  typedefs.h
+  f_stccomm.h
+)
 
 ############### build the library #####################
 add_library(MbsAPI SHARED ${MBSAPI_SRCS})
@@ -112,4 +69,9 @@ target_link_libraries(MbsAPI ${ROOT_LIBRARIES})
 set_target_properties(MbsAPI PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES})
 
 ############### install the library ###################
-install(TARGETS MbsAPI DESTINATION ${CMAKE_BINARY_DIR}/lib)
+
+install(FILES ${MBSAPI_HEADERS}
+        DESTINATION include
+       )
+
+install(TARGETS MbsAPI DESTINATION lib)
diff --git a/MbsAPI/README.md b/MbsAPI/README.md
new file mode 100644
index 0000000..cf2c989
--- /dev/null
+++ b/MbsAPI/README.md
@@ -0,0 +1,6 @@
+MbsAPI
+========
+
+The [Multi Branch System (MBS)](https://www.gsi.de/work/organisation/wissenschaftlich_technologische_abteilungen/experiment_elektronik/datenverarbeitung/datenerfassung/mbs.htm) is the standard Data Acquisition System at GSI. 
+
+The classes in the directory provide interface to this system.
\ No newline at end of file
diff --git a/MbsAPI/clnt_buf_def.h b/MbsAPI/clnt_buf_def.h
deleted file mode 100644
index 02b7499..0000000
--- a/MbsAPI/clnt_buf_def.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// $Id: clnt_buf_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*  CLNT_BUF_DEF.H
- *
- *  definitions MUST be EQUAL for GPS-Server, GPS-Client and SBS-Monitor
- *  modif: 24-Feb-1994 RSM  CLNT__BUFHEAD
- *
- */
-/* +++ length in bytes +++ */
-#define CLNT__OUTBUFHEAD   344                  /* header length (300) inluding
-* CLNT_INFO_CONTROL and
-* CLNT_INFO_CLIENT
-* but without *p_clntoutbuf[2]
-* and *p_client. Data trans-
-* mission starts at l_dlen
-*/
-#define CLNT__INFO_CONTROL  24                    /* len of info from
-* s_control to be copied to
-* s_clntoutbuf
-*/
-#define CLNT__INFO_CLIENT   20                    /* len of info from
-* s_client  to be copied to
-* s_clntoutbuf
-*/
-#define CLNT__SMALLBUF     512                  /* size of smallest buffer
-* to be sent
-*/
-#define CLNT__RESTBUF      168                  /* begin of rest buffer addr
-* is &p_clntoutbuf->
-*    c_buffer[CLNT_RESTBUF]
-* CLNT_RESTBUF =
-  *      CLNT_SMALLBUF -
-  *      CLNT_OUTBUFHEAD
-  */
-#define CLNT__BUFHEAD      336                  /* Header of output/input in
-  * s_clntbuf and
-  * s_clntoutbuf
-  * from l_dlen to
-  *      l_clntoutbuf_fltm
-  */
-#define CLNT__BUFH_LW       11                   /* Header from l_testbit
-  *        to l_msgtyp in LW */
-#define CLNT__MSGLEN       256                   /* Length of message string
-  */
-#define CLNT__REST_LW       11                   /* rest of header after
-  * s_clntbuf.c_message[] to
-  * s_clntbuf.c_buffer[0]
-  */
-
diff --git a/MbsAPI/err_mask_def.h b/MbsAPI/err_mask_def.h
deleted file mode 100644
index c125d9d..0000000
--- a/MbsAPI/err_mask_def.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// $Id: err_mask_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/* ++++++++++++++++++++++++++
- * +++   err_mask_def.h   +++
- * ++++++++++++++++++++++++++
- * RSMayer
- * 08-Feb-1994
- * output mask definitions
- * last update: 10-Feb-1994:RSM, MASK__DEBUG, MASK__VERBOSE
- * last update: 15-Feb-1994:RSM, File renamed to  err_mask_def.h
- */
-
-#define MASK__DEBUG   1               /* output for debug purpose            */
-#define MASK__VERBOSE 2               /* verbose output                      */
-/* */
-#define MASK__PRTNULL 0x0             /* no output, i.e. output suppressed   */
-#define MASK__PRTTERM 0x80000000      /* Terminal output only                */
-#define MASK__PRTSLOG 0x20000000      /* Log file output                     */
-#define MASK__PRTT    0xa0000000      /* Terminal and log file output        */
-#define MASK__PRTGLOG 0x10000000                          /* not implemented */
-#define MASK__PRTPLOG 0x08000000                          /* not implemented */
-#define MASK__PRTCLOG 0x04000000                          /* not implemented */
-#define MASK__PRTERRL 0x40000000                          /* not implemented */
-/* */
-#define MASK__PRTL 0x20000000                             /* not implemented */
-#define MASK__PRTE 0xf0000000                             /* not implemented */
-#define MASK__PRTG 0xb0000000                             /* not implemented */
-/* */
-#define  MASK__PRTNOPAD 0x00000100                        /* not implemented */
-/* */
-#define MASK__PRTOPEN   1                                 /* not implemented */
-#define MASK__PRTCLOSE  2                                 /* not implemented */
-#define MASK__PRTFLUSH  4                                 /* not implemented */
diff --git a/MbsAPI/errnum_def.h b/MbsAPI/errnum_def.h
deleted file mode 100644
index be98597..0000000
--- a/MbsAPI/errnum_def.h
+++ /dev/null
@@ -1,163 +0,0 @@
-// $Id: errnum_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/* ++++++++++++++++++++++
- * +++ errnum_def.h +++
- * ++++++++++++++++++++++
- * RSMayer
- * 07-Feb-1994
- * error numbers
- * last modification:
- *   23-Mar-1994 RSMayer insert EVent_server error numbers
- *   25-Mar-1994 RSMayer ERR__SIGNAL, SETTASK, SETVERB, CLRVERB added.
- *   31-Mar-1994 RSMayer ERR__USBFTY, ERR__NKNBFTY.
- *   12-Jul-1994 RSMayer Error numbers and msg. for Esone Server
- *   16-Feb-1995 RSMayer new error numbers. /RSM
- *   08-Mar-1995 RSMayer some basic error number text modified.
-*/
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-/* !!!! error numbers MUST be changed in s_error.h TOO !!!! */
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-
-/* !!! bit1:0 succes, bit1:1 error, i.e. odd numbers are errors! !!! */
-
-/* +++ UTIlity      error numbers start with   0 +++ */
-#define ERR__SUCCESS  0    /* Normal successfull completion && */
-#define ERR__ERROR    1    /* Error: && */
-/* */
-#define ERR__INFO     2    /* && */ /* only text */
-#define ERR__ERR      3    /* && */ /* only text */
-#define ERR__WARN     4    /* Warning: &&        */
-/* */
-#define ERR__ERRNF    7    /* Error number && not found */
-#define ERR__MSKNF    9    /* Mask && not found */
-#define ERR__MSKNIMPL 11   /* Mask && not implemented */
-#define ERR__FNIMPL   13   /* Feature not implemented. && */
-#define ERR__SYSERR   15   /* System error: && */
-#define ERR__SIGNAL   16   /* Signal: && */
-
-#define ERR__SETTASK  60   /* Set task name &&. */
-#define ERR__SETVERB  62   /* Verbosity flag set: &&. */
-#define ERR__CLRVERB  64   /* Verbosity flag cleared: &&. */
-#define ERR__STS      66   /* errstat &&. */
-#define ERR__INIT     68   /* Using f_ut_error local ctrl structure. */
-#define ERR__INITERR  69   /* Warn: Not specified, using local ctrl structure.*/
-#define ERR__INITGET  70   /* Get f_ut_error ctrl structure. &&.*/
-#define ERR__INITADDR 71   /* Invalid addr:
-Read or write f_ut_error ctrl structure. */
-#define ERR__INITPUT  72   /* Put f_ut_error ctrl structure. &&.*/
-#define ERR__TEST     74   /* Test f_ut_error: &&. */
-#define ERR__ENALOG   76   /* Enable message log: &&. */
-#define ERR__DISLOG   78   /* Disable message log: &&. */
-
-#define ERR__MSG_COMM  80   /* Write command style to f_ut_send_msg */
-#define ERR__MSG_INFO  81   /* Write info style to f_ut_send_msg    */
-#define ERR__MSG_ERROR 82   /* Write error style to f_ut_send_msg   */
-
-
-/* +++ COLlector    error numbers start with 100 +++ */
-#define ERR__COL_HISENA 101 /* Histogramming already enabled. && */
-#define ERR__COL_FIEVT  103 /* first event was not triggertype 14 */
-#define ERR__COL_TRMIS  105 /* trigger type or local event counter mismatch */
-#define ERR__COL_TRTYP  107 /* trigger type is out of range (1-15) */
-#define ERR__COL_BIGEV  109 /* event is bigger than stream capacity */
-#define ERR__COL_DAMIS  111 /* mismatch in pipe data buffers 0,1 */
-
-
-/* +++ RD (Readout) error numbers start with 200 +++ */
-#define ERR__RD_FITRG  201 /* first trigger type was not 14 */
-#define ERR__RD_NORDT  203 /* table readout specified but no readout table */
-/* was loaded */
-#define ERR__RD_LECMIS 205 /* local event counter differs more than 1 count */
-/* compared to previous one (modula 32) */
-#define ERR__RD_TRTYP  207 /* trigger type is out of range (1-15) */
-#define ERR__RD_TRMIS  209 /* trigger type is out of range (1-15) */
-
-
-/* +++ TRansport    error numbers start with 300 +++ */
-#define ERR__MALLOC 301
-#define ERR__SCSI_WRTFILEMARK 303
-#define ERR__SCSI_WRITE 305
-#define ERR__SCSI_REWIND 307
-#define ERR__SCSI_UNLOAD 309
-#define ERR__SCSI_OPEN 311
-#define ERR__SCSI_SETBLKSIZE 313
-#define ERR__SCSI_UNKNMEDIA 315
-#define ERR__SCSI_MSENSE 317
-#define ERR__SCSI_INQUIRY 319
-#define ERR__SCSI_MSELECT 321
-
-
-/* +++ EVent_server error numbers start with 400 +++ */
-#define ERR__EV_CLNOTMR  400  /* Warning: Client not marked. && */
-#define ERR__EV_CLAMRK   402  /* Warning: Client allready marked. && */
-#define ERR__EV_ECLAMRK  403  /* Client allready marked. && */
-#define ERR__EV_CLNOTV   404  /* Warning: Client not valid. && */
-#define ERR__EV_ECLNOTV  405  /* Client not valid. && */
-#define ERR__EV_CLNRDY   406  /* No client ready/active. && */
-#define ERR__EV_FLTNV    407  /* Filter not valid. && */
-#define ERR__EV_WARNFLT  408  /* Warning for filter. && */
-#define ERR__EV_EBFACKN  409  /* Buffer acknoledge. && */
-#define ERR__EV_WBFACKN  410  /* Warning: Buffer acknoledge. && */
-#define ERR__EV_WBACKTO  412  /* Warning: Buffer acknoledge timeout. && */
-#define ERR__EV_WBFPEND  414  /* Buffer pending. && */
-#define ERR__EV_CLNSTS   415  /* Wrong client status. && */
-#define ERR__EV_LSTBUF   416  /* Info: Was last buffer. && */
-#define ERR__EV_WRTBUF   417  /* Error writing buffer. && */
-#define ERR__EV_CLNACC   419  /* Error client accept . && */
-#define ERR__EV_RELSTR   420  /* Release stream: &&. */
-#define ERR__EV_USBFTY   421  /* Unsupported buffer typ: &&. */
-#define ERR__EV_UKNBFTY  423  /* Unknown buffer typ: &&. */
-#define ERR__EV_UKNEVTY  425  /* Unknown event typ: &&. */
-#define ERR__EV_UKNSETY  427  /* Unknown subevent typ: &&. */
-#define ERR__EV_EVTOOBIG 429  /* Event too big for buffer: &&. */
-/* */
-
-/* +++ ESone_server error numbers start with 500 +++ */
-#define ERR__ES_CLNOTMR  500  /* Warning: Client not marked. && */
-#define ERR__ES_CLAMRK   502  /* Warning: Client allready marked. && */
-#define ERR__ES_BFRDTO   514  /* Buffer read timeout. && */
-#define ERR__ES_ERDBUF   515  /* Error reading buffer. && */
-#define ERR__ES_LSTBUF   516  /* Info: Was last buffer. && */
-#define ERR__ES_WRTBUF   517  /* Error writing buffer. && */
-#define ERR__ES_CLNACC   519  /* Error client accept. && */
-#define ERR__ES_MAXCLN   521  /* Maximum number of clients exceeded. && */
-#define ERR__ES_BFSTRD   530  /* Buffer status read: && */
-#define ERR__ES_BFSTWR   532  /* Buffer status write: && */
-#define ERR__ES_BFPROC   534  /* Buffer in process: && */
-#define ERR__ES_EESONE   537  /* Error in Esone call: && */
-/* */
-
-/* +++ Histogram_manager error numbers start with 600 +++ */
-#define ERR__HIS_SPNFND  601  /* Error: Histogram && not found */
-#define ERR__HIS_EOFSPN  602  /* Warn: End of histogram list. && */
-#define ERR__HIS_RANGES  603  /* Error: Value out of range. && */
-#define ERR__HIS_WRNGNO  605  /* Error: Wrong number typed */
-#define ERR__HIS_EANAL   607  /* Error in analysis: && */
-#define ERR__HIS_NFREEM  609  /* Error: Can't get the memory */
-#define ERR__HIS_NOPENF  611  /* Error: Can't open the file */
-#define ERR__HIS_INVHIS  613  /* Error: Invalid histogram name or too long */
-#define ERR__HIS_NALFNO  615  /* Error: Only alphanumeric symbols allowed */
-#define ERR__HIS_NOMEMR  617  /* Error: No memory allocated */
-#define ERR__HIS_HALREX  619  /* Histogram && already exists */
-#define ERR__HIS_NFREDP  621  /* No free memory in data pool && */
-#define ERR__HIS_HTABFU  623  /* Histogram table full && */
-#define ERR__HIS_EWPAR   625  /* Wrong parameter && */
-#define ERR__HIS_SKIPEVT 626  /* Skip event &&. */
-#define ERR__HIS_SKIPSEV 628  /* Skip subevent &&. */
-#define ERR__HIS_NBASATT 629  /* No Base attached. &&*/
-#define ERR__HIS_BASATT  630  /* Base && already attached. */
-#define ERR__HIS_NHISBAS 631  /* Base && is not a histogram base. */
-#define ERR__HIS_DBLOCK  633  /* Base locked by another user. && */
-/* */
diff --git a/MbsAPI/fLmd.c b/MbsAPI/fLmd.c
index 44c128a..809f525 100644
--- a/MbsAPI/fLmd.c
+++ b/MbsAPI/fLmd.c
@@ -1,16 +1,10 @@
-// $Id: fLmd.c 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include <stdlib.h>
 #include <fcntl.h>
 #include <string.h>
@@ -46,13 +40,14 @@
 #define fseeko64 fseek
 #define fpos64_t fpos_t
 
+#ifndef _HAS_CLOCK_REALTIME
 /* just some dummies for compilation, we will never write lmd with time header in go4*/
 #define CLOCK_REALTIME 1
 int clock_gettime(int clockid, struct timespec* tp)
 {
   return 0;
 }
-
+#endif
 #endif
 
 
@@ -147,8 +142,12 @@ uint32_t fLmdPutOpen(
 
   pLmdControl->pMbsFileHeader->iType=LMD__TYPE_FILE_HEADER_101_1;
   pLmdControl->pMbsFileHeader->iEndian=1;
-  strcpy(pLmdControl->cFile,Filename);
-
+  size_t len=strlen(Filename);
+  if (len < sizeof(pLmdControl->cFile)) {
+    strncpy(pLmdControl->cFile,Filename, len);
+  } else {
+    strncpy(pLmdControl->cFile,Filename, sizeof(pLmdControl->cFile)-1);
+  }
   // optionally allocate buffer
   if(iBytes > 0) {
     pLmdControl->pBuffer=(int16_t*)malloc(iBytes);
@@ -302,8 +301,8 @@ uint32_t fLmdPutBuffer(
 uint32_t fLmdPutClose(
   sLmdControl* pLmdControl)
 {
-  int32_t iReturn,i;
-  lmdoff_t current,c;
+  int32_t iReturn;//,i;
+//  lmdoff_t current,c;
 
   if(pLmdControl->iBufferWords > pLmdControl->iLeftWords) { // write last buffer
     iReturn=fLmdWriteBuffer(pLmdControl, (char*)pLmdControl->pBuffer,
@@ -378,15 +377,20 @@ uint32_t fLmdConnectMbs(
     fLmdCleanup(pLmdControl);
     return(LMD__FAILURE);
   }
-  strcpy(pLmdControl->cFile,Nodename);
-  if(iBufferBytes == LMD__GET_EVENTS) { // use internal buffer for fLmdGetMbsEvent
-    pLmdControl->pBuffer = (int16_t*) malloc(sMbs.iMaxBytes);
-    pLmdControl->iBufferWords=sMbs.iMaxBytes/2;
-    pLmdControl->iInternBuffer=1;
-  } else {
-    *iBufferBytes=sMbs.iMaxBytes;
-  }
-  return(LMD__SUCCESS);
+    size_t len=strlen(Nodename);
+    if (len < sizeof(pLmdControl->cFile)) {
+      strncpy(pLmdControl->cFile,Nodename, len);
+    } else {
+      strncpy(pLmdControl->cFile,Nodename, sizeof(pLmdControl->cFile)-1);
+    }
+    if(iBufferBytes == LMD__GET_EVENTS) { // use internal buffer for fLmdGetMbsEvent
+      pLmdControl->pBuffer = (int16_t*) malloc(sMbs.iMaxBytes);
+      pLmdControl->iBufferWords=sMbs.iMaxBytes/2;
+      pLmdControl->iInternBuffer=1;
+    } else {
+      *iBufferBytes=sMbs.iMaxBytes;
+    }
+    return(LMD__SUCCESS);
 }
 //===============================================================
 uint32_t fLmdInitMbs(
@@ -399,12 +403,17 @@ uint32_t fLmdInitMbs(
   uint32_t iTimeout)
 {
 
-  int32_t stat;
+//  int32_t stat;
 
   if(iBuffers > 1) {printf("fLmdInitMbs: Event spanning not supported!\n"); return(LMD__FAILURE);}
   if(iStreams > 0) {printf("fLmdInitMbs: MBS not in DABC mode!\n"); return(LMD__FAILURE);}
   pLmdControl->iPort=iPort;
-  strcpy(pLmdControl->cFile,Nodename);
+  size_t len=strlen(Nodename);
+  if (len < sizeof(pLmdControl->cFile)) {
+    strncpy(pLmdControl->cFile,Nodename, len);
+  } else {
+    strncpy(pLmdControl->cFile,Nodename, sizeof(pLmdControl->cFile)-1);
+  }
   if(pLmdControl->pBuffer == NULL) { pLmdControl->pBuffer= (int16_t*) malloc(iMaxBytes); }
   pLmdControl->iBufferWords=iMaxBytes/2;
   pLmdControl->iInternBuffer=1;
@@ -422,6 +431,10 @@ uint32_t fLmdCloseMbs(sLmdControl* pLmdControl)
   // send request buffer for stream server
   if(pLmdControl->iPort == PORT__STREAM) {
     stat=f_stc_write(cClose,12,pLmdControl->iTCP);
+    if(stat != STC__SUCCESS)
+    {
+      printf("fLmdCloseMbs: Error writing CLOSE with f_stc_write!\n");
+    }
   }
   stat=f_stc_close(pLmdControl->pTCP);
   pLmdControl->pMbsFileHeader = NULL; // was reference only
@@ -461,9 +474,9 @@ uint32_t fLmdGetMbsBuffer(
   uint32_t* iBytesUsed)
 {
 
-  sMbsHeader* pm;
+//  sMbsHeader* pm;
   sMbsBufferHeader* pBuf;
-  uint32_t* ps, *pd, i,ii, elem=0, size=0, usedBytes=0,leftBytes=0;
+  uint32_t usedBytes=0,leftBytes=0;//, *ps, *pd, i,ii, elem=0, size=0;
   int32_t iReturn;
   const char cRequest[12] = "GETEVT";
 
@@ -478,20 +491,24 @@ uint32_t fLmdGetMbsBuffer(
     return(LMD__FAILURE);
   }
   if(leftBytes < sizeof(sMbsBufferHeader)) {
-    printf("fLmdGetMbsBuffer: %s buffer size %d too small for %d bytes\n",
+    printf("fLmdGetMbsBuffer: %s buffer size %d too small for %lx bytes\n",
            pLmdControl->cFile,leftBytes,sizeof(sMbsBufferHeader));
     return(LMD__FAILURE);
   }
   // send request buffer for stream server
   if(pLmdControl->iPort == PORT__STREAM) {
     iReturn=f_stc_write(cRequest,12,pLmdControl->iTCP);
+    if(iReturn != STC__SUCCESS)
+    {
+      return(LMD__FAILURE);
+    }
   }
   iReturn=f_stc_read((int32_t*)pBuf,sizeof(sMbsBufferHeader),pLmdControl->iTCP,pLmdControl->iTcpTimeout);
   if(iReturn == STC__TIMEOUT) { return(LMD__TIMEOUT); }
   if(iReturn != STC__SUCCESS) { return(LMD__FAILURE); }
   if(pLmdControl->iSwap) { fLmdSwap4((uint32_t*)pBuf,sizeof(sMbsBufferHeader)/4); }
   if(leftBytes < (sizeof(sMbsBufferHeader)+2*pBuf->iUsedWords)) {
-    printf("fLmdGetMbsBuffer: %s buffer size %d too small for %d bytes\n",
+    printf("fLmdGetMbsBuffer: %s buffer size %d too small for %lx bytes\n",
            pLmdControl->cFile,leftBytes,sizeof(sMbsBufferHeader)+2*pBuf->iMaxWords);
     return(LMD__FAILURE);
   }
@@ -522,8 +539,8 @@ uint32_t fLmdGetOpen(
 {
 
   int32_t iReturn;
-  uint32_t l=0,i,bufferBytes=0,h[12];
-  lmdoff_t to;
+  uint32_t bufferBytes=0;//,l=0,i,h[12];
+//  lmdoff_t to;
 
   memset(pLmdControl,0,sizeof(sLmdControl));
   if(pBuffHead == LMD__INTERNAL_HEADER) {
@@ -536,12 +553,18 @@ uint32_t fLmdGetOpen(
   memset(pLmdControl->pMbsFileHeader,0,sizeof(sMbsFileHeader));
 
   // copy file name to control structure
-  strcpy(pLmdControl->cFile,Filename);
+  size_t len=strlen(Filename);
+  if ( len < sizeof(pLmdControl->cFile)) {
+    strncpy(pLmdControl->cFile, Filename, len);
+  } else {
+    strncpy(pLmdControl->cFile, Filename, sizeof(pLmdControl->cFile)-1);
+  }
   if((pLmdControl->fFile=(FILE*)fopen64(Filename,"r"))== NULL) {
-    printf("fLmdGetOpen: File not found: %d\n",Filename);
+    printf("fLmdGetOpen: File not found: %s\n",Filename);
     fLmdCleanup(pLmdControl);
     return(GETLMD__NOFILE);
   }
+
   /* read header */
   iReturn=fLmdReadBuffer(pLmdControl,
                          (char*)pLmdControl->pMbsFileHeader,
@@ -578,7 +601,7 @@ uint32_t fLmdGetOpen(
 
   pLmdControl->iBytes+=iReturn;
   // more of header?
-  if(pLmdControl->pMbsFileHeader->iUsedWords > 0) {
+  if( (pLmdControl->pMbsFileHeader->iUsedWords > 0) && (pLmdControl->pMbsFileHeader->iUsedWords < UINT32_MAX/2) ) {
     // Read this additional information without swapping.
     // Could be mostly strings. Caller must know.
     pLmdControl->cHeader=malloc(pLmdControl->pMbsFileHeader->iUsedWords*2);
@@ -592,7 +615,7 @@ uint32_t fLmdGetOpen(
   }
 
   bufferBytes=iBytes;
-  if(bufferBytes < pLmdControl->pMbsFileHeader->iMaxWords*2) {
+  if(bufferBytes < pLmdControl->pMbsFileHeader->iMaxWords*2 && (pLmdControl->pMbsFileHeader->iMaxWords < UINT32_MAX/2) ) {
     bufferBytes=pLmdControl->pMbsFileHeader->iMaxWords*2;
   }
   fLmdPrintFileHeader(1,pLmdControl->pMbsFileHeader);
@@ -615,7 +638,7 @@ uint32_t fLmdGetBuffer(
 {
 
   sMbsHeader* pm;
-  uint32_t* ps, *pd, i,ii, elem=0, size=0, leftBytes=0, used, elem_sz;
+  uint32_t elem=0,leftBytes=0, used, elem_sz;//, *ps, *pd, i,ii, size=0;
   int32_t iReturn;
 
   if(iBytes < pLmdControl->pMbsFileHeader->iMaxWords) {
@@ -724,7 +747,7 @@ uint32_t fLmdGetBuffer(
 uint32_t fLmdGetElement(sLmdControl* pLmdControl, uint32_t iEvent, sMbsHeader** event)
 {
   sMbsHeader* pM;
-  uint32_t* ps, *pd, i, evsz;
+  uint32_t i, evsz;//, *ps, *pd;
   int32_t iReturn;
   *event=NULL;
 
@@ -732,10 +755,26 @@ uint32_t fLmdGetElement(sLmdControl* pLmdControl, uint32_t iEvent, sMbsHeader**
     if(pLmdControl->pBuffer==NULL) { return(GETLMD__NOBUFFER); } // internal buffer needed
     if(pLmdControl->pMbsFileHeader->iElements==0) { return(GETLMD__NOMORE); }
 
+    if (pLmdControl->pMbsHeader == 0)
+    {
+      // second, try to read more bytes
+
+      iReturn = fLmdReadBuffer(pLmdControl,
+                               (char*)(pLmdControl->pBuffer+pLmdControl->iLeftWords),
+                               (pLmdControl->iBufferWords-pLmdControl->iLeftWords)*2);
+
+      if(iReturn <= 0) { printf("fLmdGetElement: EOF\n"); return(GETLMD__EOFILE); }
+
+      if(pLmdControl->iSwap) { fLmdSwap4((uint32_t*)(pLmdControl->pBuffer+pLmdControl->iLeftWords),iReturn/4); }
+
+      pLmdControl->iBytes += iReturn;
+      pLmdControl->pMbsHeader=(sMbsHeader*)pLmdControl->pBuffer;
+      pLmdControl->iLeftWords += iReturn/2;
+    }
     // check if we need to read extra data
-    if ((pLmdControl->iLeftWords < 4) ||
-        (pLmdControl->pMbsHeader == 0) ||
-        (pLmdControl->pMbsHeader->iWords+4 > pLmdControl->iLeftWords)) {
+    else if((pLmdControl->iLeftWords < 4) ||
+            (pLmdControl->pMbsHeader->iWords+4 > pLmdControl->iLeftWords))
+    {
       // first copy old data, if it exists
       if (pLmdControl->iLeftWords > 0) {
         memmove(pLmdControl->pBuffer, pLmdControl->pMbsHeader, pLmdControl->iLeftWords*2);
@@ -778,7 +817,11 @@ uint32_t fLmdGetElement(sLmdControl* pLmdControl, uint32_t iEvent, sMbsHeader**
   // get indexed event
   if(pLmdControl->iOffsetEntries) {
     if(iEvent >= pLmdControl->iOffsetEntries) { return(GETLMD__OUTOF_RANGE); }
-    fseeko64(pLmdControl->fFile,fLmdOffsetGet(pLmdControl,iEvent-1)*4,SEEK_SET);
+    int val = fseeko64(pLmdControl->fFile,fLmdOffsetGet(pLmdControl,iEvent-1)*4,SEEK_SET);
+    if(0 != val)
+    {
+      return(GETLMD__EOFILE);
+    }
     i=(fLmdOffsetGet(pLmdControl,iEvent)-fLmdOffsetGet(pLmdControl,iEvent-1));
     iReturn=fLmdReadBuffer(pLmdControl,(char*)pLmdControl->pBuffer,i*4);
     if(iReturn <= 0) {printf("fLmdGetElement: EOF\n"); return(GETLMD__EOFILE);}
@@ -938,7 +981,13 @@ uint32_t fLmdOffsetRead(sLmdControl* pLmdControl)
   sMbsHeader* pTableHead;
 
   pTableHead=(sMbsHeader*)malloc(16);  // header with 8 bytes data for future use.
-  fseeko64(pLmdControl->fFile,(lmdoff_t)pLmdControl->pMbsFileHeader->iTableOffset*4,SEEK_SET);
+  
+  int val = fseeko64(pLmdControl->fFile,(lmdoff_t)pLmdControl->pMbsFileHeader->iTableOffset*4,SEEK_SET);
+  if(0 != val)
+  {
+    free(pTableHead);
+    return(GETLMD__NOLMDFILE);
+  }
   iReturn=fLmdReadBuffer(pLmdControl, (char*)pTableHead,16);
   if(iReturn!=16) {
     printf("fLmdGetBuffer: LMD read error: unexpected EOF: %s\n",pLmdControl->cFile);
@@ -962,7 +1011,6 @@ uint32_t fLmdOffsetRead(sLmdControl* pLmdControl)
   if(iReturn!=pLmdControl->iOffsetEntries*pLmdControl->iOffsetSize) {
     printf("fLmdOffsetTable: LMD format error: no index table: %s\n",pLmdControl->cFile);
     pLmdControl->iOffsetEntries=0;
-    free(pTableHead);
     return(GETLMD__NOLMDFILE);
   }
   if(pLmdControl->iSwap) {
@@ -972,7 +1020,11 @@ uint32_t fLmdOffsetRead(sLmdControl* pLmdControl)
     }
   }
   // go back behing header
-  fseeko64(pLmdControl->fFile,(lmdoff_t)sizeof(sMbsFileHeader),SEEK_SET);
+  val = fseeko64(pLmdControl->fFile,(lmdoff_t)sizeof(sMbsFileHeader),SEEK_SET);
+  if(0 != val)
+  {
+    return(GETLMD__NOLMDFILE);
+  }
   // use small table
   if(pLmdControl->iOffsetSize == 4) {
     pLmdControl->pOffset4= (uint32_t*)pLmdControl->pOffset8;
@@ -1008,8 +1060,9 @@ uint32_t fLmdOffsetWrite(sLmdControl* pLmdControl)
   }
   if(current/4 != pLmdControl->pMbsFileHeader->iTableOffset) {
     printf("Table offset mismatch: current:%lld calculated:%lld, cur-cal %lld\n",
-           current/4,pLmdControl->pMbsFileHeader->iTableOffset,
-           current/4-pLmdControl->pMbsFileHeader->iTableOffset);
+           (long long int)(current/4),
+           (long long int)(pLmdControl->pMbsFileHeader->iTableOffset),
+           (long long int)(current/4-pLmdControl->pMbsFileHeader->iTableOffset));
     return(LMD__FAILURE);
   }
   if(iReturn != (pLmdControl->iElements+1)*pLmdControl->iOffsetSize) {
@@ -1021,7 +1074,7 @@ uint32_t fLmdOffsetWrite(sLmdControl* pLmdControl)
 //===============================================================
 uint32_t fLmdOffsetSet(sLmdControl* pLmdControl, uint32_t lwords)
 {
-  int32_t iReturn;
+//  int32_t iReturn;
   if(pLmdControl->iElements >= pLmdControl->iOffsetEntries) { fLmdOffsetResize(pLmdControl,0); }
   if(pLmdControl->pOffset8) {
     *(pLmdControl->pOffset8+pLmdControl->iElements)=
@@ -1059,24 +1112,33 @@ void fLmdOffsetResize(sLmdControl* pLmdControl, uint32_t firstValue)
     if(pLmdControl->pOffset8) {
       memcpy(new,pLmdControl->pOffset8,oldEntries*pLmdControl->iOffsetSize);
       free(pLmdControl->pOffset8);
-      pLmdControl->pOffset8=new;
+      //pLmdControl->pOffset8=new;
+      pLmdControl->pOffset8 = (lmdoff_t*)malloc(newEntries*pLmdControl->iOffsetSize);
+      memcpy(pLmdControl->pOffset8,new,newEntries*pLmdControl->iOffsetSize);
     }
     if(pLmdControl->pOffset4) {
       memcpy(new,pLmdControl->pOffset4,oldEntries*pLmdControl->iOffsetSize);
       free(pLmdControl->pOffset4);
-      pLmdControl->pOffset4=(uint32_t*)new;
+      //pLmdControl->pOffset4=(uint32_t*)new;
+      pLmdControl->pOffset4 =(uint32_t*)malloc(newEntries*pLmdControl->iOffsetSize);
+      memcpy(pLmdControl->pOffset4,new,newEntries*pLmdControl->iOffsetSize);
     }
   } else { // table was new
     //printf("Create table %d entries, first offset %d\n",newEntries,firstValue);
     if(pLmdControl->iOffsetSize==8) {
-      pLmdControl->pOffset8=new;
+      //pLmdControl->pOffset8=new;
+      pLmdControl->pOffset8 = (lmdoff_t*)malloc(newEntries*pLmdControl->iOffsetSize);
+      memcpy(pLmdControl->pOffset8,new,newEntries*pLmdControl->iOffsetSize);
       *pLmdControl->pOffset8=(lmdoff_t)firstValue;
     }
     if(pLmdControl->iOffsetSize==4) {
-      pLmdControl->pOffset4=(uint32_t*)new;
+      //pLmdControl->pOffset4=(uint32_t*)new;
+      pLmdControl->pOffset4 =(uint32_t*)malloc(newEntries*pLmdControl->iOffsetSize);
+      memcpy(pLmdControl->pOffset4,new,newEntries*pLmdControl->iOffsetSize);
       *pLmdControl->pOffset4=firstValue;
     }
   }
+  free(new);
   pLmdControl->iOffsetEntries=newEntries;
 }
 //===============================================================
@@ -1108,7 +1170,7 @@ void fLmdPrintFileHeader(uint32_t iVerbose, sMbsFileHeader* pMbsFileHeader)
              pMbsFileHeader->iTimeSpecSec,
              pMbsFileHeader->iTimeSpecNanoSec/1000,
              pMbsFileHeader->iMaxWords,
-             pMbsFileHeader->iTableOffset,
+             (long long unsigned int)(pMbsFileHeader->iTableOffset),
              pMbsFileHeader->iOffsetSize);
     }
   }
@@ -1145,7 +1207,7 @@ void fLmdPrintControl(uint32_t iVerbose, sLmdControl* pLmdControl)
            pLmdControl->cFile,
            pLmdControl->iBufferWords,
            pLmdControl->iLeftWords,
-           pLmdControl->iBytes,
+           (long long int)(pLmdControl->iBytes),
            pLmdControl->iElements
           );
     fLmdPrintFileHeader(iVerbose,pLmdControl->pMbsFileHeader);
@@ -1172,7 +1234,7 @@ void fLmdSwap4(uint32_t* array, uint32_t items)
 void fLmdSwap8(uint64_t* array, uint32_t items)
 {
   uint64_t* pp;
-  uint32_t i,x;
+  uint32_t i;//,x;
   pp=array;
   for(i=0; i<items; i++) {
     //printf("Swap 8 %016llx ",*pp);
diff --git a/MbsAPI/fLmd.h b/MbsAPI/fLmd.h
index 7dd917f..770fcea 100644
--- a/MbsAPI/fLmd.h
+++ b/MbsAPI/fLmd.h
@@ -1,16 +1,10 @@
-// $Id: fLmd.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef MbsLmdStruct
 #define MbsLmdStruct
 
diff --git a/MbsAPI/f_evcli.c b/MbsAPI/f_evcli.c
deleted file mode 100644
index b86ee0a..0000000
--- a/MbsAPI/f_evcli.c
+++ /dev/null
@@ -1,1840 +0,0 @@
-// $Id: f_evcli.c 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_evcli                                           */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : f_evcli_xxx()                                */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     :  API for GOOSY - Event - Server or    */
-/*                 SBS - Event - Server .     */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*2+Description***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Client for test purpose GOOSY - PAW - Server and    */
-/*                SBS - Event - Server.                               */
-/*                (for detailed information see PC_CLIPAW)            */
-/*                                                                    */
-/*2+Implementation**********+******************************************/
-/*                                                                    */
-/*+ PROCEDURES  : see f_evcli_proc                                         */
-/*                                                                    */
-/*+ File name   : f_evcli.c                                         */
-/*                                                                    */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer, H.Essel                                          */
-/*+ Last Update : 28-feb-2000                                         */
-/*                                                                    */
-/*2+Internals***************+******************************************/
-/*                                                                    */
-/*+ Utility     :                                                     */
-/*+ File name   : m_evcli.c                                         */
-/*+ Home direct.: LEA$SRC                                         */
-/*+ Created     : 28-feb-2000                                         */
-/*                                                                    */
-/*2+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*1- C Procedure *************+*********************************************/
-
-/* ++++++++++++++ !!!! IMPLEMENTATION !!!! +++++++++++++++++++++++++++++++ */
-#include "typedefs.h"
-
-
-#define F__SWAP(ps,l,pd) f_swaplw((int *)ps,(int)l,(int *)pd)
-#ifdef VMS        /* ++++++++++++++ VMS ++++++++++++++++++++++++++++ */
-#define UNIXENV 0                           /* switch UNIX or VMS          */
-
-/* standard headers ----- */
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <types.h>
-#include <string.h>
-#include <stdlib.h>
-#endif /* VMS */
-
-#ifdef Lynx      /* ++++++++++++++++ Lynx +++++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#endif /* Lynx */
-
-#ifdef HPUX      /* +++++++++++++++++ HPUX ++++++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#define _HPUX_SOURCE                    /* this stuff is needed before    */
-#define _POSIX_SOURCE                   /*   any include is done          */
-#endif /* HPUX */
-
-#ifdef Linux     /* +++++++++++++++++ Linux ++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#endif
-
-#ifdef Solaris    /* +++++++++++++++++ Solaris ++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#endif
-
-#ifdef Darwin     /* +++++++++++++++++ Max OS X ++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#endif
-
-
-#ifdef GSI__WINNT  /* +++++++++++++++++ Windows NT ++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#define _ALL_SOURCE                     /* for types.h typedef u_char...  */
-#define _POSIX_SOURCE                   /*   any include is done          */
-#endif
-
-
-#ifdef _AIX      /* +++++++++++++++++ AIX ++++++++++++++++++++++++++ */
-#define UNIXENV 1                           /* switch UNIX or VMS          */
-#define _ALL_SOURCE                     /* for types.h typedef u_char...  */
-#define _POSIX_SOURCE                   /*   any include is done          */
-#define IN_AIX 1
-#else
-#define IN_AIX 0
-#endif /* !_AIX */
-
-/* ++++++++++++++++ include UNIX standard headers +++++++++++++++++++++++++ */
-#if UNIXENV == 1
-#include <sys/types.h>
-#ifdef GSI__WINNT
-#include <sys/timeb.h>
-#else
-#include <sys/time.h>                   /* ?  <time.h> */
-#include <netdb.h>
-#endif
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#endif                                  /* UNIXENV */
-
-/* ++++++++++++++++++++++ goopaw include files ++++++++++++++++++++++++++ */
-#include "gps_sc_def.h"                 /* must be first */
-#include "s_filter.h"
-#include "clnt_buf_def.h"
-#include "s_clntbuf.h"
-
-// DABC
-#include "fLmd.h"
-// --DABC
-
-#include "f_evcli.h"
-#include "f_swaplw.h"
-
-#include "s_filter.h"
-
-#if MBS_ENDIAN == 1
-#include "s_flt_descr_swap.h"
-#include "s_clnt_filter_swap.h"
-#else
-#include "s_flt_descr.h"
-#include "s_clnt_filter.h"
-#endif
-
-#include "s_opc1.h"
-#include "s_pat.h"
-
-#include "gps_sc_def.h"
-
-void f_clnup(long [], int*);
-void f_clnup_save(long [], int*);
-int f_fltdscr(struct s_clnt_filter*);
-int f_read_server(s_evt_channel*, int*, int, int);
-int f_send_ackn(int, int);
-
-unsigned short* pi_inbuf;
-unsigned int* pl_inbuf;
-unsigned int l_len_w;
-int swapw(unsigned short*, unsigned short*, unsigned int);
-int swapl(unsigned int*, unsigned int*, unsigned int);
-static int i_debug = 0;                  /* message level (0-3) */
-
-#define EVT_MAX 1000
-#define TCP__TIMEOUT 3000                /* TCP timeout reading buffer   */
-#define FLUSH__TIME 3                    /* flush time interval for MBS event server */
-#define STDOUT_BUFIO_ 1
-
-struct s_clnt_filter*  p_clnt_filter;
-struct s_clntbuf*      p_clntbuf;
-struct s_opc1*         p_opc1;
-
-static int unsigned  lf_swap = 0;                  /* save swap on RX     */
-static int unsigned  l_endian_serv;                /* save endian server  */
-static int           l_len_lw1 = CLNT__BUFH_LW;    /* len for first swap  */
-int                  l_len_lw2;                    /* len for 2nd   swap  */
-int                   i_channel;                    /* TCP/IP channel      */
-int unsigned         l_clnt_sts;                   /* status for ackn.    */
-int         l_status, l_sts;
-static char           c_modnam[] = "f_evcli";
-short         if_typevt, i_sign = 1, i_len;
-int                  l_timeout;
-int         l_retval;
-static struct s_tcpcomm s_tcpcomm_ec = {0,0,0};
-static struct {
-  int                l_ack_buf;          /* read client buff received  */
-  int                l_ack_bytes;        /* read client bytes received */
-  int unsigned       l_clnt_sts;         /* client sts 1:o.k. 8:lst buf*/
-}  s_ackn;
-
-/* ++ vectors of pointer and devices for cleanup */
-long          v_mem_clnup[8];
-/***************************************************************************/
-int f_evcli_con(s_evt_channel* ps_chan, char* pc_node, int l_aport, int l_aevents, int l_asample)
-/***************************************************************************/
-{
-  short                 i, i_h, i_m, i_s;
-  char                  arg[80], c_hms[16], c_help[4];
-  int                  l_evtecho,*pl;
-  char                  c_node[32], c_name[32], c_retmsg[256];
-  int                  l_port;
-
-  v_mem_clnup[0] = 0;
-
-  /* +++ allocate filter structure +++ */
-  p_clnt_filter = (struct s_clnt_filter*) malloc( sizeof(struct s_clnt_filter) );
-  if (p_clnt_filter == NULL) {
-    printf("E-%s: calloc(,...s_clnt_filter) failed!\n", c_modnam);
-    printf("F-%s: aborting program execution!\n",c_modnam);
-    f_clnup(v_mem_clnup, NULL);
-    return(-1);
-  }
-  ps_chan->pc_evt_buf=(char*) p_clnt_filter;
-  /* save value for clnup */
-  f_clnup_save(v_mem_clnup, (int*) p_clnt_filter);
-  memset( (void*) p_clnt_filter, 0, sizeof(struct s_clnt_filter) );
-
-  p_clnt_filter->l_testbit = GPS__ENV_TESTBIT;   /* set testbit              */
-  p_clnt_filter->l_endian  = GPS__ENV_ENDIAN;    /* set endian               */
-  p_clnt_filter->l_numb_of_evt = l_aevents;
-  p_opc1 = (struct s_opc1*) &p_clnt_filter->filter[0].l_opcode;
-  p_opc1->b1_evtsev = 1;
-  p_opc1->b1_selflt = 1;
-  p_opc1->b1_selwrt = 1;
-  p_opc1->b3_opc    = 0;
-  p_opc1->b1_lnkf1  = 0;
-  p_opc1->b1_lnkf2  = 0;
-  p_opc1->h_fltspec = 0;
-  p_opc1->h_next_fltblk = 1;
-  p_opc1->h_flt_len     = 1;
-
-  l_status = f_fltdscr(p_clnt_filter);
-  /*
-  printf("evtsev: %d selflt: %d selwrt: %d opc: %d lnk1: %d lnk2: %d fltspec: %d next: %d len: %d\n"
-  ,p_opc1->b1_evtsev
-  ,p_opc1->b1_selflt
-  ,p_opc1->b1_selwrt
-  ,p_opc1->b3_opc
-  ,p_opc1->b1_lnkf1
-  ,p_opc1->b1_lnkf2
-  ,p_opc1->h_fltspec
-  ,p_opc1->h_next_fltblk
-  ,p_opc1->h_flt_len);
-  */
-  if ((l_status & 1) == 0) {
-    printf("E-%s: Severe Error in f_fltdscr! Status:%d\n",
-           c_modnam,
-           l_status);
-    f_clnup(v_mem_clnup, NULL);
-    return(-1);
-  }
-  p_clnt_filter->l_sample_rate = l_asample;
-  p_clnt_filter->l_flush_rate = FLUSH__TIME;
-
-  l_timeout = TCP__TIMEOUT ;
-  strcpy(c_node,pc_node);
-  l_port = l_aport;
-
-  l_status = (int) f_stc_connectserver(c_node,
-                                       l_port,
-                                       &i_channel,
-                                       &s_tcpcomm_ec);
-  if ((l_status & 1) != STC__SUCCESS) {
-    printf("E-%s: Error connecting node:%s, port:%d. Msg:\n",
-           c_modnam,
-           c_node,
-           l_port);
-    f_stc_disperror((int) l_status,c_retmsg, 0);
-    f_stc_close(&s_tcpcomm_ec);
-    return(l_status);
-  }
-  ps_chan->l_channel_no=i_channel;
-  /* + buffer flushing time + */
-  i_h = p_clnt_filter->l_flush_rate / 3600;      /* hours                 */
-  i_s = p_clnt_filter->l_flush_rate - i_h * 3600;
-  i_m = i_s / 60;                     /* minutes               */
-  i_s = i_s - i_m * 60;             /* seconds               */
-
-  /* +++++++++++++++++++++++++++++++++ */
-  /* +++ send these data to server +++ */
-  /* +++++++++++++++++++++++++++++++++ */
-  /* len to transm [bytes] = 3 LW + filter + 1LW  */
-  l_status = (int) f_stc_write( (char*) p_clnt_filter,
-                                GPS__CLNT_SNDFLT,
-                                i_channel);
-  if (l_status != STC__SUCCESS) {
-    printf("E-%s: Error in f_write_tcp(p_flt,...)! Status:%d. Msg:\n",
-           c_modnam,
-           l_status);
-    f_stc_disperror((int) l_status,c_retmsg, 0);
-    f_stc_close(&s_tcpcomm_ec);
-    return(l_status);
-  }
-  /* + + + + + + + + + + + + + + */
-  /* +++ alloc input buffer  +++ */
-  /* + + + + + + + + + + + + + + */
-  p_clntbuf = (struct s_clntbuf*) malloc(sizeof(struct s_clntbuf));
-  if (p_clntbuf == NULL) {
-    printf("E-%s: malloc(p_clntbuf) failed!\n", c_modnam);
-    printf("F-%s: aborting program execution!\n",c_modnam);
-    f_stc_close(&s_tcpcomm_ec);
-    return(-1);
-  }
-  /* save value for clnup */
-  f_clnup_save(v_mem_clnup, (int*) p_clntbuf);
-
-  ps_chan->pc_io_buf = (char*) p_clntbuf;
-  ps_chan->l_io_buf_size = GPS__OUTBUFSIZ + CLNT__OUTBUFHEAD;
-  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-  /* ++++ first read on server, get machine type & swap  ++++ */
-  /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-  memset(p_clntbuf,0, sizeof(struct s_clntbuf));      /* clear memory  */
-  l_status = f_read_server(ps_chan,
-                           &l_retval,
-                           l_timeout,
-                           i_channel);
-  if (l_status != TRUE) {
-    printf("E-%s: Error reading 1st buffer: f_read_server()!\n", c_modnam);
-    f_stc_close(&s_tcpcomm_ec);
-    return(l_status);
-  }
-
-  /* ++++++++++++++++++++++++++++++++++++ */
-  /* +++ check if a LW swap is needed +++ */
-  /* ++++++++++++++++++++++++++++++++++++ */
-  lf_swap       = (p_clntbuf->l_testbit == GPS__ENV_TESTBIT) ? 0 : 1;
-  l_endian_serv = p_clntbuf->l_endian;
-
-  if (lf_swap)
-    /* + + + + + + + + + + + + + + + + + */
-    /* +++ swap after every receive  +++ */
-    /* + + + + + + + + + + + + + + + + + */
-  {
-    l_sts     = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW,0);
-
-    l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
-    l_sts     = F__SWAP(&p_clntbuf->l_inbuf_read_cnt, l_len_lw2, 0);
-
-    if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT) { /* <T> */
-      printf("F-%s: Error swapping first buffer from client\n",
-             c_modnam);
-      f_stc_close(&s_tcpcomm_ec);
-      return(-1);
-    }
-  }
-
-  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
-  /* +++ first buffer should be a message buffer!  +++ */
-  /* + + + + + + + + + + + + + + + + + + + + + + + + + */
-  if (p_clntbuf->l_buffertype & 16) {
-  }
-
-  if (p_clntbuf->l_buffertype & 2) {
-    /* buffer contains message   */
-    /*
-         switch (p_clntbuf->l_msgtyp & 15)
-         {
-            case 1:
-            case 2:  printf("MSG-type:W:  %s\n", p_clntbuf->c_message);  break;
-            case 4:  printf("MSG-type:E:  %s\n", p_clntbuf->c_message);  break;
-            case 8:  printf("MSG-type:F:  %s\n", p_clntbuf->c_message);  break;
-            default: printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
-         }
-    */
-  }
-  return(STC__SUCCESS);
-} /* f_evcli_con */
-
-/***************************************************************************/
-int f_evcli_buf(s_evt_channel* ps_chan)
-/***************************************************************************/
-{
-  s_ve10_1* ps_ve10_1;
-  int ii;
-  char* ps_buf;
-  /* ++++++++++++++++++++++++++++++ */
-  /* +++ send acknowledge buffer +++ */
-  /* ++++++++++++++++++++++++++++++ */
-  l_status = f_send_ackn(1, ps_chan->l_channel_no);
-  if (l_status != TRUE) {
-    printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
-    f_stc_close(&s_tcpcomm_ec);
-    return(l_status);
-  }
-  /* +++++++++++++++++++++++++ */
-  /* +++ read input buffer +++ */
-  /* +++++++++++++++++++++++++ */
-  p_clntbuf =  (struct s_clntbuf*) ps_chan->pc_io_buf;
-  ps_buf=ps_chan->pc_io_buf; /* save for comparison */
-  memset(p_clntbuf,0, ps_chan->l_io_buf_size);
-  l_status = f_read_server(ps_chan,
-                           &l_retval,
-                           l_timeout,
-                           ps_chan->l_channel_no);
-  /* in case pc_io_buf has been reallocated */
-  if(ps_buf != ps_chan->pc_io_buf) {
-    f_clnup(v_mem_clnup, NULL); /* free all old buffers */
-    p_clntbuf =  (struct s_clntbuf*) ps_chan->pc_io_buf;
-    f_clnup_save(v_mem_clnup, (int*) p_clntbuf);
-  }
-  if (l_status != TRUE) {
-    printf("E-%s: Error reading buffer: f_read_server()!\n", c_modnam);
-    f_stc_close(&s_tcpcomm_ec);
-    return(l_status);
-  }
-  l_clnt_sts = 0;                                                /* reset */
-
-  /* +++++++++++++++++++++++++++++++++ */
-  /* +++ swap every buffer in loop +++ */
-  /* +++++++++++++++++++++++++++++++++ */
-  if (lf_swap) {
-    l_sts     = F__SWAP(&p_clntbuf->l_testbit,CLNT__BUFH_LW, 0);
-    l_len_lw2 = CLNT__REST_LW + p_clntbuf->l_dlen/4; /* <N> !!! */
-
-    /*  4 byte swap */
-    pl_inbuf = &p_clntbuf->l_inbuf_read_cnt;
-    l_sts = F__SWAP(pl_inbuf, l_len_lw2, 0);
-  }
-  /* printf("Buffer %8d bytes, dlen %8d events %6d\n",l_retval,p_clntbuf->l_dlen,p_clntbuf->l_events);
-         ps_ve10_1=(s_ve10_1 *)&p_clntbuf->c_buffer[0];
-          for(ii=0;ii<p_clntbuf->l_events;ii++)
-    {printf("Event %2d, t/s %3d %2d, len %d\n",ii+1,ps_ve10_1->i_type,ps_ve10_1->i_subtype,ps_ve10_1->l_dlen);
-    ps_ve10_1 = (s_ve10_1 *) ((short *)ps_ve10_1 + ps_ve10_1->l_dlen + 4); }
-  */
-  /* ++++++++++++++++++++++++ */
-  /* +++ message handling +++ */
-  /* ++++++++++++++++++++++++ */
-  l_sts=STC__SUCCESS;
-  if (p_clntbuf->l_buffertype & 2) {
-    /* buffer contains message   */
-    switch (p_clntbuf->l_msgtyp & 15) {
-    case 1:
-    case 2:
-      if((strstr(p_clntbuf->c_message,"no event data") == NULL)&
-          (strstr(p_clntbuf->c_message,"flushed") == NULL)) {
-        printf("MSG-type:W:  %s\n", p_clntbuf->c_message);
-      }
-      break;
-    case 4:
-      printf("MSG-type:E:  %s\n", p_clntbuf->c_message);
-      break;
-    case 8:
-      printf("MSG-type:F:  %s\n", p_clntbuf->c_message);
-      break;
-    default:
-      printf("Unknown MSG-type:%d:\n%s\n",p_clntbuf->l_msgtyp,p_clntbuf->c_message);
-    }
-    l_sts=STC__TIMEOUT; /* buffer without events */
-  } else {
-    if(p_clntbuf->l_events == 0) {
-      l_sts=STC__TIMEOUT;
-    }
-  }
-  ps_chan->pc_evt_buf = (char*)&p_clntbuf->c_buffer[0];
-  ps_chan->l_evt_buf_posi = 1; /* number of events */
-  ps_ve10_1 = (s_ve10_1*) ps_chan->pc_evt_buf;
-  return(l_sts);
-}  /*  end f_evcli_buf  */
-
-/***************************************************************************/
-int f_evcli_evt(s_evt_channel* ps_chan)
-/***************************************************************************/
-{
-  int* ps_int;
-  s_ve10_1* ps_ve10_1;
-
-  p_clntbuf =  (struct s_clntbuf*) ps_chan->pc_io_buf;
-  if(ps_chan->l_evt_buf_posi < p_clntbuf->l_events) {
-    ps_chan->l_evt_buf_posi++;
-    ps_ve10_1 = (s_ve10_1*) ps_chan->pc_evt_buf;
-    ps_int   = (int*) ps_chan->pc_evt_buf;
-    ps_int += ps_ve10_1->l_dlen/2 + 2;
-    ps_chan->pc_evt_buf = (char*) ps_int;
-    return(STC__SUCCESS);
-  } else { return(-1); }
-}
-/***************************************************************************/
-int f_evcli_close(s_evt_channel* ps_chan)
-/***************************************************************************/
-{
-  /* ++++++++++++++++++++++++++++++ */
-  /* +++ send acknowledge buffer +++ */
-  /* ++++++++++++++++++++++++++++++ */
-  l_status = f_send_ackn(8, ps_chan->l_channel_no);
-  if (l_status != TRUE) {
-    printf("E-%s: Error sending acknowledge: f_send_ackn()!\n", c_modnam);
-    return(l_status);
-  }
-  f_clnup(v_mem_clnup, NULL);
-  f_stc_discclient(ps_chan->l_channel_no);
-  f_stc_close(&s_tcpcomm_ec);
-  return(STC__SUCCESS);
-}
-
-
-/*2+F_FLTDSCR***+******************************************************/
-/*                                                                    */
-/*+ Module      : F_FLTDSCR                                           */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_fltdscr(p_clnt_filter)                      */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read and check the event filter and construct the   */
-/*                filter descriptor.                                  */
-/*                                                                    */
-/*+ ARGUMENTS   : p_clnt_filter: Pointer to structure s_clnt_filter   */
-/*                                                                    */
-/*+ FUNCTION    : Read and check the event filter and construct the   */
-/*                filter descriptor.  Output via "printf".            */
-/*                See also I$PS_FLTDSC_PRTCL                          */
-/*                                                                    */
-/*+ Return type : int (32 bit)                                       */
-/*+ Status codes: bit 0: success                                      */
-/*                bit 1: warning                                      */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-int f_fltdscr(p_clnt_filter)           /* read filter, check and         */
-/* constr. flt_descriptor         */
-struct s_clnt_filter* p_clnt_filter;
-{
-  static char               c_modnam[] = "f_fltdscr";
-  struct s_filter*    p_filter;
-  struct s_opc1*      p_opc1;
-  struct s_flt_descr* p_flt_descr;
-  struct s_pat1*      p_pat1;
-  struct s_pat2*      p_pat2;
-  struct s_pat3*      p_pat3;
-
-  short              i_fltdescnt = 0;
-  short              i_fltcnt = 0;
-  short              i_fltblkcnt = 0;
-  short              i, i_flt_len,
-                     i_fltblkbeg, i_fltblkend, j;
-  short              if_newfltblk = 1;
-  short              i_next_fltblk = 0; // SL 16.11.2009 add initialization to 0
-  short              i_descr;        /* test */
-  int               l_evtdescr, *pl_evtdescr, *pl_sev1descr, *pl_sev2descr;
-  short              i_lasevtflt, i_1stsevflt;
-
-  int unsigned      l_status, l_sts;
-  int unsigned      l_retsts = 0;
-
-  /* +++ action +++ */
-  if (i_debug == 2) {
-    printf("--->D-%s: addr_filter p:%d\n", c_modnam, p_clnt_filter);
-  }
-
-  /* init pointer */
-  p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[0];
-
-  /* +++ loop over all filter block descriptors +++ */
-  for (i = 0; i < GPS__MAXFLT; i++) {
-    p_filter    = (struct s_filter*)    &p_clnt_filter->filter[i];
-    p_opc1      = (struct s_opc1*)      &p_filter->l_opcode;
-
-    if (i_debug == 2)
-      printf("D-%s: i:%d opc:%x flt_len:%d\n",
-             c_modnam,
-             i,
-             p_filter->l_opcode,
-             p_opc1->h_flt_len);
-
-    if (i == i_next_fltblk) {
-      if_newfltblk = 1;
-    }
-
-    if (p_opc1->h_flt_len == 0) {
-      i_fltcnt = i;
-      p_opc1->h_next_fltblk    = 0;    /* no next descriptor              */
-      p_flt_descr->h_nextdescr = 0;    /* no next descriptor              */
-      break;              /* no more filter                  */
-    } /* if (p_opc1->h_next_fltblk == 0) */
-
-    /*      if (p_opc1->b3_opc == 0) {
-     *        printf("I-%s: b3_opc == 0. Take all events!\n",
-     *           c_modnam);
-     *        }
-     */
-
-    if (if_newfltblk) {
-      if_newfltblk = 0;
-      i_fltblkcnt++;
-      i_flt_len     = p_opc1->h_flt_len;
-      i_next_fltblk = i + i_flt_len;
-      i_fltblkbeg   = i;
-      i_fltblkend   = i_next_fltblk - 1;
-
-      if (p_opc1->b1_selwrt == 1) {
-        /* write block               */
-
-        p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[0];
-        i_descr = 0;         /* test */
-
-        if (p_flt_descr->hf_wrtdescr == 1 &&
-            p_clnt_filter->flt_descr[0].i_descriptors <= 0) {
-          printf("W-%s: >1 write blocks, previous one(s) ignored!\n",
-                 c_modnam);
-          l_retsts = l_retsts | 2;
-        }
-
-        p_flt_descr->hf_wrtdescr = 1;
-        p_flt_descr->hf_fltdescr = 0;
-        p_flt_descr->h_fltblkbeg = i_fltblkbeg;
-        p_flt_descr->h_fltblkend = i_fltblkend;
-        p_flt_descr->h_nextdescr = 1;
-
-        /* save write block values */
-        p_clnt_filter->if_wrtevt = (p_opc1->b1_evtsev == 1) ? 1 : 0;
-        p_clnt_filter->if_wrtsev = (p_opc1->b1_evtsev != 1) ? 1 : 0;
-      } /* if (p_opc1->b1_selwrt == 1) */
-
-      if (p_opc1->b1_selflt == 1) {
-        /* filter block              */
-        if (i_fltdescnt == 0) {
-          i_fltdescnt++;
-        }
-        i_descr = i_fltdescnt;              /* test */
-        p_flt_descr = (struct s_flt_descr*)
-                      &p_clnt_filter->flt_descr[i_fltdescnt];
-        p_flt_descr->hf_wrtdescr = 0;
-        p_flt_descr->hf_fltdescr = 1;
-        p_flt_descr->h_fltblkbeg = i_fltblkbeg;
-        p_flt_descr->h_fltblkend = i_fltblkend;
-        p_flt_descr->h_nextdescr = ++i_fltdescnt;
-        /* save write block values */
-        if (p_opc1->b1_evtsev == 1) {
-          p_clnt_filter->if_fltevt = 1;
-        } else {
-          p_clnt_filter->if_fltsev = 1;
-        }
-      }    /* if (p_opc1->b1_selflt == 1) */
-
-    } /* if (if_newfltblk) */
-
-    /* identical values for the whole flt blk */
-    p_opc1->h_flt_len     = i_flt_len;
-    p_opc1->h_next_fltblk = i_next_fltblk;
-
-    /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-    /* ++++ build pattern and offset values from h_fltspec ++++ */
-    /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-    /* ++++ check if Filter specification is valid ++++ */
-    if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
-      printf("E-%s: Filter specification %d invalid for events\n",
-             c_modnam,
-             p_opc1->h_fltspec);
-      return(FALSE);                /* abort with error                */
-    }
-    if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
-      printf("E-%s: Filter specification %d invalid for subevents\n",
-             c_modnam,
-             p_opc1->h_fltspec);
-      return(FALSE);                /* abort with error                */
-    }
-
-
-
-    switch (p_opc1->h_fltspec) {
-    case 0:                       /* ++++ take all ++++ */
-      if (p_opc1->b3_opc != 0) {
-        printf("W-%s: Take all. Set opcode to 0, next time\n",
-               c_modnam);
-        p_opc1->b3_opc = 0;
-        l_retsts = l_retsts | 2;
-      }
-      break;
-
-    case 1:                       /* ++++ trigger  ++++ */
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = -5; /* trigger = event + 5 W        */
-      p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
-      break;
-
-    case 2:                       /* ++++ pattern and offset ++++ */
-      break;
-
-    case 4:                /* W ++++ type ++++ */
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = -2; /* type = evt(sev) + 2 W        */
-      p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
-
-      break;
-
-    case 8:                       /* W ++++ subtype ++++ */
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = -3; /* subtype = evt(sev) + 3 W     */
-      p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
-
-      break;
-
-    case 12:                     /* LW ++++ type and subtype ++++ */
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = 1; /* type-subtype = evt(sev) + 1 LW*/
-
-      break;
-
-    case 16:                     /* W ++++ procid ++++ */
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = -4; /* procid = sev + 4 W        */
-      p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
-
-      break;
-
-    case 32:               /* W ++++ subcrate,contr ++++*/
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = -5; /* subcrate,contr = sev + 5 W */
-      p_filter->l_pattern = p_filter->l_pattern & 0xFFFF;
-
-      break;
-
-    case 48:               /* LW ++++procid,subcr,contr ++++*/
-      /*       if (p_filter->l_offset >= 0)
-       */
-      p_filter->l_offset = 2; /* procid,subc,ctrl = sev + 2 LW */
-
-      break;
-
-    default:
-      printf("W-%s: FLTSPEC %d NOT FOUND\n",
-             c_modnam,
-             p_opc1->h_fltspec);
-      l_retsts = l_retsts | 2;
-    }                            /* switch case  */
-
-
-
-  }    /* for */
-
-  p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[0];
-  if (p_flt_descr->hf_wrtdescr != 1) {
-    printf("E-%s: The write filter is missing! Filter is invalid!\n",
-           c_modnam);
-    return(FALSE);
-  }
-
-  if (!(p_clnt_filter->if_fltevt || p_clnt_filter->if_fltsev)) {
-    printf("E-%s: The filter itself is missing! Filter is invalid!\n",
-           c_modnam);
-    return(FALSE);
-  }
-
-  /*   printf(
-   *     "I-%s: p_clnt:%d: found %d flts in %d blks with %d descript.\n",
-   *         c_modnam,
-   *         p_clnt_filter,
-   *         i_fltcnt,
-   *         i_fltblkcnt,
-   *         i_fltdescnt);
-   */
-
-  if ( (p_clnt_filter->if_fltevt == 1) && (p_clnt_filter->if_fltsev == 1) ) {
-m_sort_descr:;                      /* sort event and subevent filter  */
-    i_lasevtflt = 0;           /* last event filter     init      */
-    i_1stsevflt = i_fltdescnt;     /* first subevent filter init        */
-    /* sort filter blocks: flt event should come before flt sev */
-    for (i = 1; i < i_fltdescnt; i++) {
-      p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[i];
-      p_filter    = (struct s_filter*)
-                    &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
-      p_opc1      = (struct s_opc1*)      &p_filter->l_opcode;
-
-      if ( (p_opc1->b1_selflt == 1) && (p_opc1->b1_evtsev == 1) ) {
-        i_lasevtflt = i;  /* save last evt flt found         */
-      }
-
-      if ( (p_opc1->b1_selflt == 1) &&
-           (p_opc1->b1_evtsev == 0) &&
-           (i_1stsevflt == i_fltdescnt) ) {
-        i_1stsevflt = i;  /* save last evt flt found         */
-      }
-
-      if (i_1stsevflt < i_lasevtflt) { /* evt flt after sev flt           */
-        printf(
-          "W-%s 1stsevflt:%d lastevtflt:%d. Evt flt should come first\n",
-          c_modnam,
-          i_1stsevflt,
-          i_lasevtflt);
-        l_retsts = l_retsts | 2;
-        /* copy first LW from evt descr */
-        pl_evtdescr = (int*) &p_clnt_filter->flt_descr[i_lasevtflt];
-        l_evtdescr  = *pl_evtdescr;
-        /* shift the subevent descriptors */
-        for (j = i_lasevtflt; j > i_1stsevflt; j--) {
-          pl_sev1descr  = (int*) &p_clnt_filter->flt_descr[j-1];
-          pl_sev2descr  = (int*) &p_clnt_filter->flt_descr[j];
-          *pl_sev2descr = *pl_sev1descr;
-        }
-        pl_evtdescr  = (int*) &p_clnt_filter->flt_descr[i_1stsevflt];
-        *pl_evtdescr = l_evtdescr;
-        goto m_sort_descr;            /* until descr is in right order   */
-      }    /* if */
-
-    }    /* for */
-
-  }    /* if (...if_fltevt... && ...if_fltsev...) */
-
-  /* + + + Max number of descriptors + + + */
-  p_clnt_filter->flt_descr[0].i_descriptors = i_fltdescnt;
-
-  /* ++++ check the subevent filter blocks                       ++++ */
-  /*    + the first filter in the sev flt blk identifies the sev +    */
-  /*    + normaly Procid or Procid + Subcrate                    +    */
-  if (p_clnt_filter->if_fltsev == 1) {
-    for (i = 1; i < p_clnt_filter->flt_descr[0].i_descriptors; i++) {
-      p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[i];
-      /* ++ addr of the first filter in the flt blk ++ */
-      p_filter    = (struct s_filter*)
-                    &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
-      p_opc1      = (struct s_opc1*)      &p_filter->l_opcode;
-
-    } /* for */
-  } /* if (p_clnt_filter->if_fltsev... */
-
-  return(l_retsts | 1);
-
-} /* end f_fltdscr */
-
-
-
-
-
-/*2+F_FLTRD***+********************************************************/
-/*                                                                    */
-/*+ Module      : F_FLTRD                                             */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_fltrd(p_clnt_filter, c_file)                */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Reads filter specification from a file              */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+    p_clnt_filter: Pointer to structure s_clnt_filter              */
-/*+    c_file       : Pointer to file name string                     */
-/*                                                                    */
-/*+ FUNCTION    : Opens the file and reads filter specification       */
-/*                                                                    */
-/*+ Return type : int (32 bit)                                       */
-/*+ Status codes: -                                                   */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*-               25-Jan-1994 : problems with sscanf removed (RSM)    */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-int f_fltrd(p_clnt_filter, c_file)
-struct s_clnt_filter* p_clnt_filter;
-char*                 c_file;                     /* ptr to file name        */
-{
-
-  /* ++++ declaration ++++ */
-  FILE*               infile;
-
-  static char        c_modnam[] = "f_fltrd";
-  struct s_filter*    p_filter;
-  struct s_opc1*      p_opc1;
-  struct s_flt_descr* p_flt_descr;
-  struct s_pat1*      p_pat1;
-  struct s_pat2*      p_pat2;
-  struct s_pat3*      p_pat3;
-
-  char               c_retmsg[256];
-  char               c_line[80], c_comment[80], *c_fsts, *p_com, *p_minus;
-  short              i_fltblklen = 0;
-  short         i_currflt = 0;
-  short              i, j;
-  int               l, l_scan=0;
-
-  int unsigned      l_pattern;
-  int               l_offset;
-
-  short              i_evtsev,i_selflt,i_selwrt,i_opc,i_lnkf1,
-                     i_lnkf2,i_fltspec;
-  short              if_hex, if_comment;
-
-  char*               fgets( char *str, int maxchar, FILE *file_ptr);
-
-  /* +++ action +++ */
-
-  if ( (infile = fopen(c_file,"r"))  == 0) {
-    /* open file for data input   */
-    sprintf(c_retmsg,"E-%s: fopen(File=%s) ",
-            c_modnam,
-            c_file);
-    perror(c_retmsg);
-    fclose(infile);
-    return(FALSE);
-  }
-
-  printf("Filter definition from file %s\n", c_file);
-  printf("=======================================\n");
-
-  while (l_scan != EOF && i_fltblklen < GPS__MAXFLT) {
-m_read_nxtblklen:
-    ;
-
-    memset(c_line,0,sizeof(c_line));
-
-    if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0) {
-      if (i_debug == 2)
-        printf("D-%s: File=%s: Last input line.\n",
-               c_modnam,
-               c_file);
-      break;
-    }
-
-    if_comment = 0;                      /* reset flag                    */
-    p_com = strpbrk(c_line,"!/*");       /* find position of comment      */
-    if (p_com != NULL) {
-      /* found a comment               */
-      if_comment = 1;                   /* set flag                      */
-      strcpy(c_comment,p_com);          /* copy comment                  */
-      *p_com = '\0';                    /* mark end of str at beg of comm*/
-      if (i_debug == 2) {
-        printf(" - D: comment:%s", c_comment);
-      }
-
-    }
-
-    l_scan = sscanf(c_line, "%hd", &i_fltblklen);
-    if (if_comment && (l_scan < 1) ) {
-      goto m_read_nxtblklen;
-    }
-
-    if (l_scan == EOF || l_scan == 0 || c_fsts == NULL) {
-      if (i_debug == 2) {
-        printf("D-%s: Last input line.\n",c_file);
-      }
-      break;
-    }
-
-    if (i_fltblklen + i_currflt >= GPS__MAXFLT) {
-      printf("E-%s: too long. Last filter block ignored\n",
-             c_modnam);
-      fclose(infile);
-      return(3);
-    }
-    if (i_debug == 2) {
-      printf("D-%s: Fltblklen:%d\n", c_modnam, i_fltblklen);
-    }
-
-    for (i = i_currflt; i < i_fltblklen + i_currflt; i++) {
-m_read_nxtline:
-      ;
-
-      memset(c_line,0,sizeof(c_line));
-
-      if ( (c_fsts = fgets(c_line, sizeof(c_line), infile)) == 0) {
-        sprintf(c_retmsg,"E-%s: Error reading:fgets(File=%s) ",
-                c_modnam,
-                c_file);
-        perror(c_retmsg);
-        fclose(infile);
-        return(FALSE);
-      }
-
-      if (i_debug == 2) {
-        printf("D-%s: line:%s", c_modnam, c_line);
-      }
-
-      if_comment = 0;                   /* reset flag                    */
-      p_com = strpbrk(c_line,"!/*");    /* find position of comment      */
-      if (p_com != NULL) {
-        /* found a comment               */
-        if_comment = 1;                /* set flag                      */
-        strcpy(c_comment,p_com);       /* copy comment                  */
-        *p_com = '\0';                 /* mark end of str at beg of comm*/
-        if (i_debug == 2) {
-          printf(" - D: comment:%s", c_comment);
-        }
-
-      }
-
-      l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %ld %ld",
-                      &i_evtsev,
-                      &i_selflt,
-                      &i_selwrt,
-                      &i_opc,
-                      &i_lnkf1,
-                      &i_lnkf2,
-                      &i_fltspec,
-                      &l_pattern,
-                      &l_offset);
-      if_hex = 0;                           /* set flag null             */
-      if (l_scan == 9) {
-        goto m_ok_assign;
-      }
-
-      if_hex = 1;                           /* set flag null             */
-      p_minus = strchr(c_line,'-');         /* find minus sign in offset */
-
-      if (p_minus != 0) {                   /* found minus sign          */
-        *p_minus = ' ';  /* replace minus with blank  */
-      }
-
-      l_scan = sscanf(c_line,"%hd %hd %hd %hd %hd %hd %hd %lx %lx",
-                      &i_evtsev,
-                      &i_selflt,
-                      &i_selwrt,
-                      &i_opc,
-                      &i_lnkf1,
-                      &i_lnkf2,
-                      &i_fltspec,
-                      &l_pattern,
-                      &l_offset);
-
-      l_offset = (p_minus != NULL) ? -l_offset : l_offset;
-
-      if (l_scan < 9) {
-        if (if_comment) {
-          goto m_read_nxtline;
-        }
-
-        printf(
-          "E-%s: scanned only %d(of 9) var., last 2 must be dec or hexa\n",
-          c_modnam,
-          l_scan);
-        fclose(infile);
-        return(FALSE);
-      }
-
-m_ok_assign:
-      if (i_debug == 2) {
-        sprintf( c_retmsg,
-                 "%s es:%d f:%d w:%d opc:%d lf1:%d lf2:%d flt:%d p:%x o:%x",
-                 (if_hex) ? "HEX:" : "DEC:",
-                 i_evtsev,
-                 i_selflt,
-                 i_selwrt,
-                 i_opc,
-                 i_lnkf1,
-                 i_lnkf2,
-                 i_fltspec,
-                 l_pattern,
-                 l_offset);
-        printf("D-%s: %s\n", c_modnam, c_retmsg);
-      }
-
-      p_filter    = (struct s_filter*)    &p_clnt_filter->filter[i];
-      p_opc1      = (struct s_opc1*)      &p_filter->l_opcode;
-
-      p_opc1->h_next_fltblk = (char) i_fltblklen + i_currflt;
-      p_opc1->h_flt_len     = (char) i_fltblklen;
-
-      p_filter->l_pattern   = l_pattern;
-      p_filter->l_offset    = l_offset;
-
-      p_opc1->b1_evtsev =        i_evtsev;
-      p_opc1->b1_selflt =        i_selflt;
-      p_opc1->b1_selwrt =        i_selwrt;
-      p_opc1->b3_opc    =        i_opc;
-      p_opc1->b1_lnkf1  =        i_lnkf1;
-      p_opc1->b1_lnkf2  =        i_lnkf2;
-      p_opc1->h_fltspec = (char) i_fltspec;
-
-    } /* for */
-
-    i_currflt = (short) p_opc1->h_next_fltblk;
-
-  } /* while */
-
-  fclose(infile);
-
-  return(TRUE);
-}
-
-
-
-/*2+F_TYPFLT***+*******************************************************/
-/*                                                                    */
-/*+ Module      : F_TYPFLT                                            */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_typflt(p_clnt_filter)                       */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Type the filter conditions.                         */
-/*                                                                    */
-/*+ ARGUMENTS   : p_clnt_filter: Pointer to s__clnt_filter            */
-/*                                                                    */
-/*+ FUNCTION    : Type the filter conditions. Output via "printf".    */
-/*                See also I$PS_TYPFLT_PRTCL.                         */
-/*                                                                    */
-/*+ Return type : int (32 bit) 1: success   0: fault                 */
-/*+ Status codes: -                                                   */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*-               12-Jan-1994 : Bug removed in subcrate,control (RSM) */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-int f_typflt(p_clnt_filter)
-struct s_clnt_filter* p_clnt_filter;
-{
-  static char               c_modnam[] = "f_typflt";
-  struct s_filter*    p_filter;
-  struct s_opc1*      p_opc1;
-  struct s_flt_descr* p_flt_descr;
-  struct s_pat1*      p_pat1;
-  struct s_pat2*      p_pat2;
-  struct s_pat3*      p_pat3;
-
-  short              i_fltdescnt, j, i;
-
-  /* +++ action +++ */
-
-  /* + + + Max number of descriptors + + + */
-  i_fltdescnt = p_clnt_filter->flt_descr[0].i_descriptors;
-
-  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-  /* + + + Output filter conditions for Write and Filter     + + + */
-  /* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-  /*   printf("Explanation: object OPCODE mask\n===========\n");
-   */
-  if ( (i_debug == 1) || (i_debug == 2) )
-    printf(
-      "Write:%s %s   Filter:%s %s         object OPCODE mask",
-      (p_clnt_filter->if_wrtevt > 0) ? "EVENT" : "",
-      (p_clnt_filter->if_wrtsev > 0) ? "SUBEVENT" : "",
-      (p_clnt_filter->if_fltevt > 0) ? "EVENT" : "",
-      (p_clnt_filter->if_fltsev > 0) ? "SUBEVENT" : "");
-  for (i = 0; i < i_fltdescnt; i++) {
-    p_flt_descr = (struct s_flt_descr*) &p_clnt_filter->flt_descr[i];
-    p_filter    = (struct s_filter*)
-                  &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
-    p_opc1      = (struct s_opc1*)      &p_filter->l_opcode;
-
-    if ( (i_debug == 1) || (i_debug == 2) ) {
-      if (i > 1) {
-        printf("\n<<%s>>\n", (p_opc1->b1_lnkf2 == 1) ? "A_N_D" : "O_R" );
-      }
-      printf("\n=>>FILTER set %d :",i);
-      printf(" Select:%s Filter:%s Write:%s    Filter[%d:%d]:\n",
-             (p_opc1->b1_evtsev == 1) ? "EVENT" : "SUBEVENT",
-             (p_opc1->b1_selflt == 1) ? "ON" : "OFF",
-             (p_opc1->b1_selwrt == 1) ? "ON" : "OFF",
-             p_flt_descr->h_fltblkbeg,
-             p_flt_descr->h_fltblkend );
-    }
-
-    /* +++ subevt flt blk id +++ */
-    if (p_opc1->b1_evtsev == 0 && p_opc1->b1_selflt == 1) {
-      p_filter = (struct s_filter*)
-                 &p_clnt_filter->filter[p_flt_descr->h_fltblkbeg];
-      if ( (i_debug == 1) || (i_debug == 2) )
-        printf(
-          "   Filter set id is fltspec:%d == mask:H%x  (see 1st filt. below)\n",
-          p_opc1->h_fltspec,
-          p_filter->l_pattern);
-    }
-
-
-    /* +++ loop over all filters in this filter block +++ */
-    for (j =  p_flt_descr->h_fltblkbeg;
-         j <= p_flt_descr->h_fltblkend;
-         j++) {
-      p_filter = (struct s_filter*) &p_clnt_filter->filter[j];
-      p_opc1 = (struct s_opc1*) &p_filter->l_opcode;
-      if ( (j > p_flt_descr->h_fltblkbeg) &&
-           (p_opc1->b1_selflt == 1)       &&
-           ( (i_debug == 1) || (i_debug == 2) ) ) {
-        printf("  <%s>\n", (p_opc1->b1_lnkf1 == 1) ? "A_N_D" : "O_R" );
-      }
-      if ( (i_debug == 1) || (i_debug == 2) ) {
-        printf("  =>%2d: opcode: ", i + 1);
-      }
-
-      switch (p_opc1->b3_opc) {
-      case 0:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("!! (ALL)   ");
-        }
-        break;
-      case 1:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("== (IDENT) ");
-        }
-        break;
-
-      case 2:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("&& (ANY)   ");
-        }
-        break;
-
-      case 3:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("&= (INCL)  ");
-        }
-        break;
-
-      case 4:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("^= (EXCL)  ");
-        }
-        break;
-
-      case 5:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("<  (LT)    ");
-        }
-        break;
-
-      case 6:
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf(">= (GE)    ");
-        }
-        break;
-
-      default:
-        printf("W-OPCODE %d NOT FOUND\n",p_opc1->b3_opc);
-      }
-
-      switch (p_opc1->h_fltspec) {
-      case 0:                       /* ++++ take all ++++ */
-        if (p_opc1->b3_opc != 0) {
-          p_opc1->b3_opc = 0;
-          printf("W-%s: Take all. Opcode is %d\n",
-                 c_modnam,
-                 p_opc1->b3_opc);
-        }
-        break;
-
-      case 1:                       /* ++++ trigger  ++++ */
-        p_pat1 = (struct s_pat1*) &p_filter->l_pattern;
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("trigger:%2d",p_pat1->i_trigger);
-          printf(" (mask:%d offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 2:                       /* ++++ pattern and offset ++++ */
-        if ( (i_debug == 1) || (i_debug == 2) )
-          printf("mask:H%x offset:%d %s\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ?
-                 "LW" : "W" );
-        break;
-
-      case 4:                /* W ++++ type ++++ */
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("type:%d ",
-                 p_filter->l_pattern);
-          printf(" (mask:%d offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 8:                       /* W ++++ subtype ++++ */
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("subtype:%d ",
-                 p_filter->l_pattern);
-          printf(" (mask:%d offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 12:                     /* W ++++ type and subtype ++++ */
-        p_pat3 = (struct s_pat3*) &p_filter->l_pattern;
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("type:%d subtype:%d",
-                 p_pat3->i_type,
-                 p_pat3->i_subtype);
-          printf(" (mask:H%x offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 16:               /* ++++ procid ++++*/
-        p_pat2 = (struct s_pat2*) &p_filter->l_pattern;
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("procid:%d ",
-                 p_pat2->i_procid);
-          printf(" (mask:%d offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 32:               /* W ++++ subcrate,contr ++++*/
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("subcrate:%d control:%d",
-                 p_filter->l_pattern & 0x00FF,
-                 ((unsigned) (p_filter->l_pattern & 0xFF00)) >> 8);
-          printf(" (mask:H%x offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      case 48:               /* LW ++++procid,subcr,contr ++++*/
-        p_pat2 = (struct s_pat2*) &p_filter->l_pattern;
-        if ( (i_debug == 1) || (i_debug == 2) ) {
-          printf("procid:%2d subcr:%d contr:%d",
-                 p_pat2->i_procid,
-                 p_pat2->h_subcrate,
-                 p_pat2->h_control);
-          printf(" (mask:H%x offs:%d %s)\n",
-                 p_filter->l_pattern,
-                 (p_filter->l_offset >= 0) ?
-                 p_filter->l_offset : -p_filter->l_offset,
-                 (p_filter->l_offset >= 0) ? "LW" : "W");
-        }
-        break;
-
-      default:
-        printf("W-FLTSPEC %d NOT FOUND\n",p_opc1->h_fltspec);
-      }                            /* switch case  */
-
-      /* ++++ check if Filter specification is valid ++++ */
-      if ((p_opc1->h_fltspec > 15) && (p_opc1->b1_evtsev == 1)) {
-        printf("E-%s: Filter specification %d invalid for events\n",
-               c_modnam,
-               p_opc1->h_fltspec);
-        return(FALSE);                /* abort with error                */
-      }
-      if ((p_opc1->h_fltspec < 2) && (p_opc1->b1_evtsev != 1)) {
-        printf("E-%s: Filter specification %d invalid for subevents\n",
-               c_modnam,
-               p_opc1->h_fltspec);
-        return(FALSE);                /* abort with error                */
-      }
-
-    } /* for (j... */
-
-  } /* for (i... */
-  if ( (i_debug == 1) || (i_debug == 2) ) {
-    printf("\n\n");
-  }
-
-  return(TRUE);
-} /* end f_typflt */
-
-
-
-
-/*2+F_READ_SERVER***+**************************************************/
-/*                                                                    */
-/*+ Module      : F_READ_SERVER                                       */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_read_server(p_clntbuf,                      */
-/*                                       p_bytrd,                     */
-/*                                       l_timeout,                   */
-/*                                       i_chan)                      */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read a buffer from the server                       */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+    p_clntbuf: Pointer to structure s_clntbuf                      */
-/*+    p_bytrd  : Pointer to (int) Number of read bytes              */
-/*+    l_timeout: (int) Timeout in seconds                           */
-/*+    i_chan   : (int) channel number                                */
-/*                                                                    */
-/*+ FUNCTION    : Read a buffer of the type s_clntbuf from the        */
-/*                server.                                             */
-/*                                                                    */
-/*+ Return type : int (32 bit)                                       */
-/*+ Status codes: 1: success                                          */
-/*                0: fault                                            */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*-               26-Jan-1994 : Swap inserted (RSM)                   */
-/*-               24-Feb-1994 : Bug removed (RSM)                     */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-int        f_read_server(ps_chan, p_bytrd, l_timeout, i_chan)
-s_evt_channel* ps_chan;
-int*             p_bytrd;
-int             l_timeout;
-int              i_chan;
-{
-  /* ++++ declarations ++++ */
-  int             l_maxbytes;
-  int            l_status,ii,im,*pl;                              /* !!! */
-  int           l_bytrec, l_2ndbuf_byt;
-  int           l_buftord, l_buffertype;
-  static char    c_modnam[] = "f_read_server";
-  char           c_retmsg[256];
-  char* pc;
-  int* pl_d,*pl_s;
-  s_ve10_1* ps_ve10_1;
-
-  /* ++++ action       ++++ */
-
-  p_clntbuf =  (struct s_clntbuf*) ps_chan->pc_io_buf;
-  l_maxbytes=ps_chan->l_io_buf_size;
-  /* + + + + + + + + + + + + + + + */
-  /* + + + read first buffer + + + */
-  /* + + + + + + + + + + + + + + + */
-  if (i_debug == 2)
-    printf(
-      "D-%s: **Rd 1st Buf: at %8x to %8x = %d bytes\n",
-      c_modnam,
-      (char*) p_clntbuf,
-      ((char*) p_clntbuf) + (CLNT__SMALLBUF - 1),
-      CLNT__SMALLBUF);
-
-
-  *p_bytrd = CLNT__SMALLBUF;
-  l_status = f_stc_read( (char*) p_clntbuf,
-                         (int) CLNT__SMALLBUF,
-                         i_chan,
-                         l_timeout);
-
-  if (l_status != STC__SUCCESS) {
-    printf("E-%s: Error reading first buffer. Msg follows:",c_modnam);
-    f_stc_disperror(l_status,c_retmsg, 0);
-    return(FALSE);
-  }
-
-  /* +++ copy the relevant length values +++ */
-  l_buftord    = p_clntbuf->l_numbuftosnd;
-  l_bytrec     = p_clntbuf->l_bytestosnd;
-  l_buffertype = p_clntbuf->l_buffertype;
-
-  /* +++ test for byte swap +++ */
-  if (p_clntbuf->l_testbit != GPS__ENV_TESTBIT) {
-    if (i_debug == 2)
-      printf("D-%s: Need swap to receive from %s to %s ENDIAN\n",
-             c_modnam,
-             (p_clntbuf->l_endian == 0) ? "LITTLE" : "BIG",
-             (GPS__ENV_ENDIAN     == 0) ? "LITTLE" : "BIG");
-
-    l_status = F__SWAP(&l_buftord, 1, 0);
-    if (l_status != 0) { printf("E-%s: Error swapping l_buftord. l_sts:%d\n", c_modnam,l_status); }
-    l_status = F__SWAP(&l_bytrec , 1, 0);
-    if (l_status != 0) { printf("E-%s: Error swapping l_bytrec l_sts:%d\n", c_modnam,l_status); }
-    l_status = F__SWAP(&l_buffertype, 1, 0);
-    if (l_status != 0) { printf("E-%s: Error swapping l_buffertype l_sts:%d\n", c_modnam,l_status); }
-    if (i_debug == 2)
-      printf("D-%s: buffers:%d, bytes:%d, buffertype:%d\n",
-             c_modnam,
-             l_buftord,
-             l_bytrec,
-             l_buffertype);
-
-  }
-  if (l_buftord == 1) {
-    if (l_bytrec  > CLNT__SMALLBUF) {
-      printf("E-%s: Buffer sent:%d Bytes_to_rd:%d > %d\n",
-             c_modnam,
-             l_buftord,
-             l_bytrec,
-             CLNT__SMALLBUF);
-      return(FALSE);
-    }
-    goto m_snd_ackn;
-  }
-
-  l_2ndbuf_byt = l_bytrec - CLNT__SMALLBUF;     /* rest of bytes in 2nd buffer*/
-
-  /* + + + + + + + + + + + + + + */
-  /* + + + read 2nd buffer + + + */
-  /* + + + + + + + + + + + + + + */
-  if (i_debug == 2) {
-    short  j;
-    int*  pl;
-    printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
-    pl = (int*) &p_clntbuf->c_buffer[148];
-    for (j=0; j<5; j++) {
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-
-      printf("\n");
-    }
-    printf("D-%s: **Rd 2nd Buf: at %8x (buf[%d]) to %8x = %d b\n",
-           c_modnam,
-           (char*) &p_clntbuf->c_buffer[CLNT__RESTBUF],
-           CLNT__RESTBUF,
-           ((char*) &p_clntbuf->c_buffer[CLNT__RESTBUF]) + (l_2ndbuf_byt - 1),
-           l_2ndbuf_byt);
-  }
-  *p_bytrd += l_2ndbuf_byt;
-  l_buftord = 2;
-  /* check if buffer if big enough, reallocate if not */
-  /* old buffer is freed by caller */
-  if(l_bytrec > l_maxbytes) {
-    im=l_bytrec;
-    l_bytrec=(int)(1.2*(float)l_bytrec);
-    l_bytrec=((l_bytrec>>12)+1);
-    l_bytrec=(l_bytrec<<12);
-    /*      printf("reallocate for %d (%d) bytes\n",im,l_bytrec);fflush(stdout);*/
-    pc =  (char*) malloc(l_bytrec);
-    pl_d=(int*)pc;
-    for(ii=0; ii<l_bytrec/4; ii++) { *pl_d++ = 0; }
-    pl_d=(int*)pc;
-    pl_s=(int*)ps_chan->pc_io_buf;
-    for(ii=0; ii<CLNT__SMALLBUF/4; ii++) { *pl_d++ = *pl_s++; }
-    ps_chan->pc_io_buf = pc;
-    ps_chan->l_io_buf_size = l_bytrec;
-    p_clntbuf = (struct s_clntbuf*) pc;
-  }
-  pl = (int*) &p_clntbuf->c_buffer[CLNT__RESTBUF];
-  im=l_2ndbuf_byt/16384;
-  l_2ndbuf_byt=l_2ndbuf_byt%16384;
-  for(ii=0; ii<im; ii++) {
-    l_status = f_stc_read( pl,16384,i_chan,l_timeout);
-    pl+=4096;
-    if(l_status != STC__SUCCESS) { break; }
-  }
-  if(l_2ndbuf_byt > 0) {
-    l_status = f_stc_read( pl,l_2ndbuf_byt,i_chan,l_timeout);
-  }
-  if (l_status != STC__SUCCESS) {
-    printf("E-%s: Error reading second buffer. Msg follows:",c_modnam);
-    f_stc_disperror(l_status,c_retmsg, 0);
-    return(FALSE);
-  }
-
-  if (i_debug == 2) {
-    short  j;
-    int*  pl;
-    printf("D-%s: begin of c_buffer[148] in LW (all hex)\n", c_modnam);
-    pl = (int*) &p_clntbuf->c_buffer[148];
-    for (j=0; j<5; j++) {
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-      printf("%8x:%8x ",pl,*(pl));
-      pl++;
-
-      printf("\n");
-    }
-  }
-
-m_snd_ackn:;                             /* +++ set and send 12 bytes ackn */
-  /* ++++++++++++++++++++++++++++++++++ */
-  /* + + + send acknowledge buffer + + + */
-  /* ++++++++++++++++++++++++++++++++++ */
-  s_ackn.l_ack_buf   = l_buftord;
-  s_ackn.l_ack_bytes = *p_bytrd;
-  s_ackn.l_clnt_sts  = 1;                    /* success                      */
-
-  if ((l_buffertype & 8) != 0) {
-    s_ackn.l_clnt_sts = s_ackn.l_clnt_sts | 8;  /* set bit for last buffer  */
-  }
-
-  return(TRUE);
-}
-
-
-/*2+F_SEND_ACKN*****+**************************************************/
-/*                                                                    */
-/*+ Module      : F_SEND_ACKN                                         */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_send_ackn(l_clnt_sts, i_chan)               */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Send acknowledge buffer to the server                */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+   l_clnt_sts: Status. Status bits will be set in addition to the  */
-/*                status  bits set by f_read_server in s_ackn struct. */
-/*+    i_chan   : (int) channel number                                */
-/*                                                                    */
-/*+ FUNCTION    : Send the acknowledge buffer. Set additional bits in  */
-/*                the status word, i.e. "last buffer" etc.            */
-/*                                                                    */
-/*+ Return type : int (32 bit)                                       */
-/*+ Status codes: 1: success                                          */
-/*                0: fault                                            */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 11-Apr-1994                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-int        f_send_ackn(l_clnt_sts, i_chan)
-int             l_clnt_sts;
-int              i_chan;
-{
-  /* ++++ declarations ++++ */
-  int            l_status;                              /* !!! */
-  static char    c_modnam[] = "f_send_ackn";
-  char           c_retmsg[256];
-
-  if (i_debug == 2)
-    printf("I-%s s_ackn.l_clnt_sts:%d l_clnt_sts:%d\n",
-           c_modnam,
-           s_ackn.l_clnt_sts,
-           l_clnt_sts);
-
-  /* +++++++++++++++++++++++++++++++ */
-  /* +++ set status of ackn buf  +++ */
-  /* +++++++++++++++++++++++++++++++ */
-  s_ackn.l_clnt_sts  = s_ackn.l_clnt_sts | l_clnt_sts; /* success            */
-
-  /* ++++++++++++++++++++++++++++++ */
-  /* +++ send acknowledge buffer +++ */
-  /* ++++++++++++++++++++++++++++++ */
-  l_status = f_stc_write( (char*) &s_ackn,
-                          12,
-                          i_chan);
-
-  if (l_status != STC__SUCCESS) {
-    printf("E-%s: Error in f_stc_write(&s_ackn,...)! Msg follows:",
-           c_modnam);
-    f_stc_disperror(l_status,c_retmsg, 0);
-    return(FALSE);
-  }
-
-  return(TRUE);
-}
-
-
-/*2+F_STRTOUPPER***+***************************************************/
-/*                                                                    */
-/*+ Module      : F_STRTOUPPER                                        */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_strtoupper(u, l)                            */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Converts a '\0' terminated string to upper case.    */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+    u        : Pointer to upper case string (result)               */
-/*+    l        : Pointer to lower case string (argument)             */
-/*                                                                    */
-/*+ FUNCTION    : Converts a '\0' terminated string to upper case.    */
-/*                                                                    */
-/*+ Return type : int (32 bit)                                       */
-/*+ Status codes: -                                                   */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-void f_strtoupper(u, l)
-char* u, *l;
-{
-  for ( ; *l != '\0'; ++l, ++u) {
-    *u = toupper(*l);
-  }
-
-  *u = '\0';
-  return;
-}
-
-
-/*2+F_CLNUP ***+*******************************************************/
-/*                                                                    */
-/*+ Module      : F_CLNUP                                             */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : f_clnup(v_mem, p_keyb)                              */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Cleanup allocated memory and dealloc devices        */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+    v_mem[]  : (int) [0]:maxidx=n [1:n]:ptr to allocated memory   */
-/*+    p_keyb   : Pointer to s_keyb or NULL.                          */
-/*                                                                    */
-/*+ FUNCTION    : Cleanup allocated memory and dealloc devices        */
-/*                Calls free(v_mem[i]) and f_ttydass(p_keyb)          */
-/*                                                                    */
-/*                                                                    */
-/*+ Return type : void                                                */
-/*+ Status codes: -                                                   */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 14-JUN-1993                                         */
-/*+ Object libr.: GOOSHRLIB                                           */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*-               14-Jan-94 : prototype TTYSTUFF(f_ttydass()) (RSM)   */
-/*-               08-Apr-94 : Accept NULL pointer for p_keyb. /HE     */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-void f_clnup(v_mem, p_keyb)
-long v_mem[];
-int* p_keyb;
-/* cleanup: free allocated memory and dealloc allocated device(s) */
-{
-  /* ++++ declaration ++++ */
-  static char     c_modnam[] = "f_clnup";
-  short    i;
-  int     l_status;
-
-  for (i = 1; i <= v_mem[0]; i++) {
-    /*    printf("free %d of %d: %8x",i,v_mem[0],v_mem[i]);fflush(stdout);*/
-    if(v_mem[i] != 0) { free((int*) v_mem[i]); }
-    /*     printf(" done\n");fflush(stdout);*/
-    v_mem[i]=0;
-  }
-  v_mem[0]=0;
-}
-/*******************************************************************/
-void f_clnup_save(v_mem, p_keyb)
-long v_mem[];
-int* p_keyb;
-/* cleanup: free allocated memory and dealloc allocated device(s) */
-{
-  /* ++++ declaration ++++ */
-  static char     c_modnam[] = "f_clnup";
-  short    i;
-  int     l_status;
-
-  /*  printf("all  %d:",v_mem[0]);fflush(stdout);*/
-  v_mem[++v_mem[0]] = (long) p_keyb; /* was (int) before JA */
-
-  /*  printf("  %d: %8x\n",v_mem[0],(int)p_keyb);fflush(stdout);*/
-}
-/* ------------------------------------------------------------------------- */
diff --git a/MbsAPI/f_evcli.h b/MbsAPI/f_evcli.h
deleted file mode 100644
index d55f6f7..0000000
--- a/MbsAPI/f_evcli.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// $Id: f_evcli.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_EVCLI
-#define F_EVCLI
-
-#include "f_evt.h"
-
-int f_evcli_con(s_evt_channel* ps_chan, char* pc_node, int l_aport, int l_aevents, int l_asample);
-int f_evcli_buf(s_evt_channel* ps_chan);
-int f_evcli_evt(s_evt_channel* ps_chan);
-int f_evcli_close(s_evt_channel* ps_chan);
-
-#endif
diff --git a/MbsAPI/f_evt.c b/MbsAPI/f_evt.c
index 862238f..0e7a6eb 100644
--- a/MbsAPI/f_evt.c
+++ b/MbsAPI/f_evt.c
@@ -1,16 +1,10 @@
-// $Id: f_evt.c 640 2010-06-17 09:00:52Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "typedefs.h"
 #include "f_stccomm.h"
 
@@ -163,9 +157,9 @@
 #include "fLmd.h"
 // -- DABC
 
-#include "gps_sc_def.h"
+//#include "gps_sc_def.h"
 #include "f_evt.h"
-#include "f_evcli.h"
+//#include "f_evcli.h"
 #include "portnum_def.h"
 
 INTS4 f_evt_get_newbuf(s_evt_channel*);
@@ -177,7 +171,7 @@ INTS4 f_ut_utime(INTS4, INTS4, CHARS*);
 static struct s_tcpcomm s_tcpcomm_st_evt;
 static CHARS c_temp[MAX_BUF_LGTH];
 static int l_gl_rev_port = PORT__EVENT_SERV;
-static int l_gl_evt_check = 0;
+//static int l_gl_evt_check = 0;
 
 /*1+ C Procedure *************+****************************************/
 /*                                                                    */
@@ -239,7 +233,7 @@ INTS4 f_evt_get_subevent(s_ve10_1* ps_ve10_1, INTS4 l_subevent, INTS4** pl_se, I
 {
   s_ves10_1* ps_ves10_1;
   INTS4      l_total,l_sub,l_sum;
-  INTS4      l,ll,l_status,*pl_next;
+  INTS4      /*l,*/ll,/*l_status,*/*pl_next;
 
   if(ps_ve10_1 == NULL) { return(GETEVT__FAILURE); }
   pl_next = (INTS4*) (ps_ve10_1 + 1);
@@ -301,9 +295,9 @@ INTS4 f_evt_type(s_bufhe* ps_bufhe,s_evhe* ps_evhe, INTS4 l_subid,INTS4 l_long,I
   s_ves10_1* ps_ves10_1;
   s_ve10_1*  ps_ve10_1;
   s_filhe* ps_filhe;
-  INTS2*     pi_data;
+//  INTS2*     pi_data;
   INTS4*     pl_data;
-  INTS4      l_mode,l_s;
+  INTS4      /*l_mode,*/l_s;
   INTS4      l,ll,l_status,l_ldata,l_used;
   CHARS c_line[132];
   CHARS c_full[132];
@@ -322,6 +316,13 @@ INTS4 f_evt_type(s_bufhe* ps_bufhe,s_evhe* ps_evhe, INTS4 l_subid,INTS4 l_long,I
     if(ll%512 > 0) { ll += 512-ll%512; }
     /* file header */
     l_status = f_ut_utime(ps_bufhe->l_time[0],ps_bufhe->l_time[1],c_time);
+
+#ifdef VMS
+    if(1 != l_status) printf("f_evt_type: error in f_ut_utime!");
+#else
+    if(0 != l_status) printf("f_evt_type: error in f_ut_utime!");
+#endif
+ 
     if(ps_bufhe->i_type == 2000) {
       ps_filhe=(s_filhe*)ps_bufhe;
       sprintf(c_line,"File header info:");
@@ -516,15 +517,29 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
 {
 
   INTS4 l_swap, l_swap_head, l_is_goosybuf, l_filehead=0, l_size, l_size_head, l_dummy, l_header_size;
-  INTS2* pi;
+//  INTS2* pi;
   CHARS c_file[256], *pc_temp;
   s_filhe* ps_filhe;
   struct s_varstr {
     INTS2 i_varstr;
     CHARS c_varstr[128];
-  } s_varstr_file;
-  INTS4 l_status,ll;
-
+  }/* s_varstr_file*/;
+  INTS4 l_status;//,ll;
+  int val;
+
+// P.-A. Loizeau, 2015/11/26:
+//    In case of STREAM mode, catch the case where the user provided
+//    a nonstandard stream port, extract the value and clean the server
+//    name. Usefull with DABC MBS streams where the port can be user set.
+   INTS4 i_streamport = PORT__STREAM_SERV;
+   if( (GETEVT__STREAM == l_mode ) && ( (pc_temp=strchr(pc_server,':')) != NULL )) {
+//      printf("input string: %s!\n", pc_server);
+      pc_server = strtok( pc_server, ":");
+      CHARS* pc_streamport  = strtok( NULL, ":");
+
+      i_streamport = atoi(pc_streamport);
+//      printf("output string: %s! Port: %s %i\n", pc_server, pc_streamport, i_streamport);
+   }
 
 #ifndef GSI__WINNT
 // disable automatic detection of RFIO on Windows while file name can contain ":"
@@ -544,10 +559,12 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
   if(ps_info != NULL) { *ps_info=NULL; }
   // when timeout is already set by f_evt_timeout(), do not overwrite
   if(ps_chan->l_timeout==0) { ps_chan->l_timeout=-1; } /* no timeout */
-  strcpy(ps_chan->c_channel,pc_server);
+
+  strncpy(ps_chan->c_channel,pc_server,sizeof(ps_chan->c_channel));
   switch(l_mode) {
   case GETEVT__FILE :
-    strcpy(c_file,pc_server);
+
+    strncpy(c_file,pc_server,sizeof(c_file));
     if(strlen(c_file) < 5) { strcat(c_file,".lmd"); }
     else {
       pc_temp = (CHARS*) &c_file[strlen(c_file)-4];
@@ -587,7 +604,11 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
 
     /* read file header and first buffer and check for goosy header */
     if(l_filehead == 1) {
-      lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+      val = lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+      if(-1 == val)
+      {
+        return(GETEVT__FAILURE);
+      }
       l_header_size=l_size_head;
       if(((s_filhe*)c_temp)->filhe_dlen > MAX__DLEN) {
         l_header_size=((s_filhe*)c_temp)->filhe_used*2+48;
@@ -613,7 +634,11 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
       }
     }/* check buffer behind header */
     ps_chan->l_buf_size=l_size_head;
-    lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+    val = lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+    if(-1 == val)
+    {
+      return(GETEVT__FAILURE);
+    }
     if(ps_info != NULL) { *ps_info=NULL; }
     /* found file header */
     if(l_filehead == 1) {
@@ -653,7 +678,12 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
     break;
   case GETEVT__STREAM :
     /* initialize connection with stream server                  */
-    if(f_stc_connectserver(pc_server,PORT__STREAM_SERV,&ps_chan->l_channel_no,
+// P.-A. Loizeau, 2015/11/26:
+//    In case of STREAM mode, catch the case where the user provided
+//    a nonstandard stream port, extract the value and clean the server
+//    name. Usefull with DABC MBS streams where the port can be user set.
+//    if(f_stc_connectserver(pc_server,PORT__STREAM_SERV,&ps_chan->l_channel_no,
+    if(f_stc_connectserver(pc_server,i_streamport,&ps_chan->l_channel_no,
                            &s_tcpcomm_st_evt)!=STC__SUCCESS) {
       return(GETEVT__NOSERVER);
     }
@@ -710,15 +740,16 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
 // -- DABC
     break;
   case GETEVT__REVSERV  :
-    if(f_evcli_con(ps_chan, pc_server, l_gl_rev_port, -1, l_sample)!=STC__SUCCESS) {
-      return(GETEVT__NOSERVER);
-    }
+//    if(f_evcli_con(ps_chan, pc_server, l_gl_rev_port, -1, l_sample)!=STC__SUCCESS) {
+//      return(GETEVT__NOSERVER);
+//    }
     break;
   case GETEVT__EVENT  :
-    if(f_evcli_con(ps_chan, pc_server, l_gl_rev_port, -1, l_sample)!=STC__SUCCESS) {
-      return(GETEVT__NOSERVER);
-    }
+//    if(f_evcli_con(ps_chan, pc_server, l_gl_rev_port, -1, l_sample)!=STC__SUCCESS) {
+//      return(GETEVT__NOSERVER);
+//    }
     break;
+#ifdef RFIO
   case GETEVT__RFIO   :
     ps_chan->l_channel_no=-1;
     ps_chan->l_channel_no=RFIO_open(pc_server,GET__OPEN_FLAG,0);
@@ -740,7 +771,11 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
     }
     /* read file header and first buffer and check for goosy header */
     if(l_filehead == 1) {
-      RFIO_lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+      val = RFIO_lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+      if(-1 == val)
+      {
+        return(GETEVT__FAILURE);
+      }
       if(RFIO_read(ps_chan->l_channel_no,c_temp,l_size_head)!=l_size_head) {
         printf("LMD format error: no LMD file: %s\n",pc_server);
         RFIO_close(ps_chan->l_channel_no);
@@ -761,7 +796,11 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
       }
     }/* check buffer behind header */
     ps_chan->l_buf_size=l_size_head;
-    RFIO_lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+    val = RFIO_lseek(ps_chan->l_channel_no, 0, SEEK_SET);  /* rewind file */
+    if(-1 == val)
+    {
+      return(GETEVT__FAILURE);
+    }
     if(ps_info != NULL) { *ps_info=NULL; }
     /* found file header */
     if(l_filehead == 1) {
@@ -795,6 +834,7 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
     }/* file header */
     ps_chan->l_io_buf_size=ps_chan->l_buf_size;
     break;
+#endif
   default             :
     if(ps_info != NULL) { *ps_info=NULL; }
     return(GETEVT__NOSERVER);
@@ -844,9 +884,9 @@ INTS4 f_evt_get_open(INTS4 l_mode, CHARS* pc_server, s_evt_channel* ps_chan,
 /*1- C Main ****************+******************************************/
 INTS4 f_evt_get_event(s_evt_channel* ps_chan, INTS4** ppl_buffer, INTS4** ppl_goobuf)
 {
-  INTS4 l_temp,l_prev_ok=1, l_stat, l_used;
+  INTS4 l_temp,l_prev_ok=1, l_stat=LMD__SUCCESS, l_used;
   s_bufhe* ps_bufhe_cur;
-  s_ve10_1* ps_ve10_1;
+//  s_ve10_1* ps_ve10_1;
   sMbsHeader* pevt;
 
 // DABC
@@ -857,6 +897,8 @@ INTS4 f_evt_get_event(s_evt_channel* ps_chan, INTS4** ppl_buffer, INTS4** ppl_go
       l_stat=fLmdGetMbsEvent(ps_chan->pLmd, &pevt);
     } else if(ps_chan->l_server_type == GETEVT__FILE) {
       l_stat=fLmdGetElement(ps_chan->pLmd,LMD__NO_INDEX, &pevt);
+    } else {
+      pevt = NULL;
     }
 
 // any error, then pointer is null
@@ -877,16 +919,16 @@ INTS4 f_evt_get_event(s_evt_channel* ps_chan, INTS4** ppl_buffer, INTS4** ppl_go
     return(GETEVT__SUCCESS);
   }
 // -- DABC
-  if((ps_chan->l_server_type == GETEVT__EVENT)|(ps_chan->l_server_type == GETEVT__REVSERV)) {
-    *ppl_goobuf = NULL;
-    if(f_evcli_evt(ps_chan) != STC__SUCCESS) { /* no more event, get new buffer */
-      l_stat=f_evcli_buf(ps_chan);
-      if(l_stat == STC__TIMEOUT) { return(GETEVT__TIMEOUT); }
-      if(l_stat != STC__SUCCESS) { return(GETEVT__FAILURE); }
-    }
-    *ppl_buffer = (INTS4*) ps_chan->pc_evt_buf;
-    return(GETEVT__SUCCESS);
-  }
+//  if((ps_chan->l_server_type == GETEVT__EVENT)|(ps_chan->l_server_type == GETEVT__REVSERV)) {
+//    *ppl_goobuf = NULL;
+//    if(f_evcli_evt(ps_chan) != STC__SUCCESS) { /* no more event, get new buffer */
+//      l_stat=f_evcli_buf(ps_chan);
+//      if(l_stat == STC__TIMEOUT) { return(GETEVT__TIMEOUT); }
+//      if(l_stat != STC__SUCCESS) { return(GETEVT__FAILURE); }
+//    }
+//    *ppl_buffer = (INTS4*) ps_chan->pc_evt_buf;
+//    return(GETEVT__SUCCESS);
+//  }
 
   /* e.g. read_buffer is 16384, GOOSY buffer may be only 2048,   *
    * this ps_chan->l_io_buf_posi indicats when the read_buffer is finished */
@@ -1024,7 +1066,7 @@ INTS4 f_evt_get_event(s_evt_channel* ps_chan, INTS4** ppl_buffer, INTS4** ppl_go
 INTS4 f_evt_get_close(s_evt_channel* ps_chan)
 {
   INTS4 l_close_failure;
-  INTS4 l_status;
+//  INTS4 l_status;
 
 // DABC
   if(ps_chan->pLmd != NULL) {
@@ -1046,7 +1088,7 @@ INTS4 f_evt_get_close(s_evt_channel* ps_chan)
       break;
     case GETEVT__STREAM :
       /* disconnect with stream server                              */
-      f_stc_write("CLOSE", 12, ps_chan->l_channel_no);
+      f_stc_write("CLOSE", 6, ps_chan->l_channel_no);
       if(f_stc_discclient(ps_chan->l_channel_no)!=STC__SUCCESS) { l_close_failure=1; }
       if(f_stc_close(&s_tcpcomm_st_evt)!=STC__SUCCESS) { l_close_failure=1; }
       if(ps_chan->pc_io_buf  != NULL) { free(ps_chan->pc_io_buf); }
@@ -1061,7 +1103,7 @@ INTS4 f_evt_get_close(s_evt_channel* ps_chan)
       break;
     case GETEVT__REVSERV  :
     case GETEVT__EVENT  :
-      if(f_evcli_close(ps_chan)!=STC__SUCCESS) { l_close_failure=1; }
+//      if(f_evcli_close(ps_chan)!=STC__SUCCESS) { l_close_failure=1; }
       break;
     case GETEVT__RFIO :
       RFIO_close(ps_chan->l_channel_no);
@@ -1116,7 +1158,7 @@ INTS4 f_evt_put_open(CHARS* pc_file, INTS4 l_size, INTS4 l_stream,
 {
   s_filhe* ps_file_head;
   INTS4 l_write_size;
-  INTS4 l_status,ll;
+  INTS4 l_status;//,ll;
   time_t s_timet;
   struct timeb s_timeb;
   /* because "timeb" is not "typedef", so we must use "struct" */
@@ -1125,7 +1167,7 @@ INTS4 f_evt_put_open(CHARS* pc_file, INTS4 l_size, INTS4 l_stream,
   struct s_varstr {
     INTS2 i_varstr;
     CHARS c_varstr[128];
-  } s_varstr_file;
+  }/* s_varstr_file*/;
 
 // DABC
   ps_chan->pLmd=NULL;
@@ -1149,7 +1191,12 @@ INTS4 f_evt_put_open(CHARS* pc_file, INTS4 l_size, INTS4 l_stream,
     exit(2);
   }
 
-  strcpy(c_file,pc_file);
+  size_t len=strlen(pc_file);
+  if (len < sizeof(c_file)) {
+    strncpy(c_file,pc_file, len);
+  } else {
+    strncpy(c_file,pc_file, sizeof(c_file)-1);
+  }
   if(strlen(c_file) < 5) { strcat(c_file,".lmd"); }
   else {
     pc_temp = (CHARS*) &c_file[strlen(c_file)-4];
@@ -1172,7 +1219,7 @@ INTS4 f_evt_put_open(CHARS* pc_file, INTS4 l_size, INTS4 l_stream,
         memcpy(ps_file_head, ps_filhe,ps_chan->l_buf_size );
       } else {
         memset( ps_file_head, '\0', ps_chan->l_buf_size);
-        sprintf(ps_file_head->filhe_run, "Pid %d\0", getpid());
+        sprintf(ps_file_head->filhe_run, "Pid %d", getpid());
         ps_file_head->filhe_run_l=strlen(ps_file_head->filhe_run);
       }
       ps_file_head->filhe_dlen=ps_chan->l_buf_size/2;
@@ -1184,7 +1231,16 @@ INTS4 f_evt_put_open(CHARS* pc_file, INTS4 l_size, INTS4 l_stream,
       ps_file_head->filhe_free[0]=1;
       ps_file_head->filhe_file_l=strlen(c_file);/* not include \0 */
       strcpy(ps_file_head->filhe_file, c_file);
-      strcpy(ps_file_head->filhe_user, getenv("USER"));/* user name */
+      char* username = getenv("USER");
+      if (username) {
+        size_t len = strlen(username);
+        // maximum length for user array in s_filhe is 30
+        if (len < sizeof(ps_file_head->filhe_user) ) {
+          strncpy(ps_file_head->filhe_user, username, len);/* user name */
+        } else {
+          strncpy(ps_file_head->filhe_user, username, sizeof(ps_file_head->filhe_user)-1);/* user name */
+        }  
+      }
       ps_file_head->filhe_user_l=strlen(ps_file_head->filhe_user);
       time(&s_timet);/* get calendar time */
       strcpy(c_mode, ctime(&s_timet));
@@ -1360,9 +1416,9 @@ INTS4 f_evt_put_event(s_evt_channel* ps_chan, INTS4* pl_evt_buf)
 
 INTS4 f_evt_put_buffer(s_evt_channel* ps_chan, s_bufhe* ps_bufhe)
 {
-  INTS4 l_write_size, l_temp, l_free;
+  INTS4 l_write_size;//, l_temp, l_free;
   INTS4 l_status;
-  CHARS* pc_addr;
+//  CHARS* pc_addr;
 
 // DABC
   if(ps_chan->pLmd != NULL) {
@@ -1406,7 +1462,7 @@ INTS4 f_evt_put_close(s_evt_channel* ps_chan)
 {
   INTS4 l_write_size, l_temp, l_temp2;
   INTS4 l_status;
-  CHARS* pc_addr;
+//  CHARS* pc_addr;
 
 // DABC
   if(ps_chan->pLmd != NULL) {
@@ -1631,7 +1687,7 @@ INTS4 f_evt_get_buffer(s_evt_channel* ps_chan, INTS4* ps_buffer)
     break;
   case GETEVT__STREAM :
     if(ps_chan->l_stream_bufs == 0)
-      if(f_stc_write("GETEVT", 12, ps_chan->l_channel_no)!=STC__SUCCESS) {
+      if(f_stc_write("GETEVT", 7, ps_chan->l_channel_no)!=STC__SUCCESS) {
         return(GETEVT__FAILURE);
       }
 
@@ -1683,7 +1739,7 @@ INTS4 f_evt_skip_buffer(s_evt_channel* ps_chan, INTS4 l_buffer)
 {
   INTS4 l_temp;
   CHARS* pc_temp;
-  INTS4 l_status,ii;
+//  INTS4 l_status,ii;
 
   pc_temp=(CHARS*)ps_chan->pc_io_buf;
   switch(ps_chan->l_server_type) {
@@ -1791,7 +1847,7 @@ INTS4 f_evt_swap(CHARS* pc_source, INTS4 l_length)
 /*1- C Procedure ***********+******************************************/
 INTS4 f_evt_swap_filhe(s_bufhe* ps_bufhe)
 {
-  CHARS* p_s, * p_d;
+//  CHARS* p_s, * p_d;
   INTS4 ii;
   INTS2* pi;
   s_filhe* ps_filhe;
@@ -1866,7 +1922,7 @@ INTS4 f_evt_get_newbuf(s_evt_channel* ps_chan)
     } /* end of while(1) */
     break;
   case GETEVT__STREAM :
-    if(f_stc_write("GETEVT", 12, ps_chan->l_channel_no)!=STC__SUCCESS) {
+    if(f_stc_write("GETEVT", 7, ps_chan->l_channel_no)!=STC__SUCCESS) {
       return(GETEVT__FAILURE);
     }
 
@@ -2104,15 +2160,17 @@ INTS4 f_evt_tag_filter(s_ve10_1* ps_ve10_1)
 INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
 {
   INTS4 ii,l_take_it,l_temp,l_chan,l_out,l_file_pos=0,l_bufnr=0,l_events=0;
-  INTS4 l_firste,*pl,l_len,l_last=-1,l_lin=0,l_fragsize, la_head[2];
+  INTS4 l_firste,*pl,l_len,l_last=-1,l_lin=0,l_fragsize;//, la_head[2];
   INTS4 l_swap, l_swap_head, l_is_goosybuf, l_filehead=0, l_size, l_size_head, l_dummy, l_evsize,l_evt_buf_size=0;
-  INTS2* pi;
+//  INTS2* pi;
   INTU4* ps,*pd;
-  CHARS c_lmd[128], c_tag[128], *pc_temp,*pc_evt_buf=NULL;
+  CHARS /*c_lmd[128], c_tag[128], *pc_temp,*/*pc_evt_buf=NULL;
   s_ve10_1* ps_ve10_1;
   s_bufhe* ps_bufhe;
   s_taghe s_taghe;
+  memset(&s_taghe, 0, sizeof(s_taghe));
   s_tag s_tag;
+  int val;
 
   ps_bufhe = (s_bufhe*)c_temp;
   printf("LMD file %s, TAG file %s\n",pc_lmd,pc_tag);
@@ -2132,7 +2190,12 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
   }
   /* read file header and first buffer and check for goosy header */
   if(l_filehead == 1) {
-    lseek(l_chan, 0, SEEK_SET);  /* rewind file */
+    val = lseek(l_chan, 0, SEEK_SET);  /* rewind file */
+    if(-1 == val)
+    {
+      close(l_chan);
+      return(GETEVT__FAILURE);
+    }
     if(read(l_chan,c_temp,l_size_head)!=l_size_head) {
       close(l_chan);
       return(GETEVT__RDERR);
@@ -2148,8 +2211,17 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
       return(GETEVT__NOLMDFILE);
     }
   }/* check buffer behind header */
+  else {
+    l_size = 0;
+    l_swap = 0;
+  }
 
-  lseek(l_chan, 0, SEEK_SET);  /* rewind file */
+  val = lseek(l_chan, 0, SEEK_SET);  /* rewind file */
+  if(-1 == val)
+  {
+    close(l_chan);
+    return(GETEVT__FAILURE);
+  }
 
   printf("Buffer swap %d, File header %d, LMD buffer %d, size %d[b]\n",l_swap,l_filehead,l_is_goosybuf,l_size);
 
@@ -2164,11 +2236,21 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
   }
 
   /* Open and create tag file */
-  if((l_out=open(pc_tag,PUT__CRT_FLAG,DEF_FILE_ACCE))== -1) { return(GETEVT__NOFILE); }
-  write(l_out,(CHARS*)&s_taghe,sizeof(s_taghe));
+  if((l_out=open(pc_tag,PUT__CRT_FLAG,DEF_FILE_ACCE))== -1)
+  {
+    close(l_chan);
+    return(GETEVT__NOFILE);
+  }
+  ssize_t wcount = write(l_out,(CHARS*)&s_taghe,sizeof(s_taghe));
+  if(wcount != sizeof(s_taghe))
+  {
+    close(l_chan);
+    close(l_out);
+    return(GETEVT__TAGWRERR);
+  }
 
   /* Initialize filter function */
-  if(e_filter != NULL) { ii=(*e_filter)(NULL); }
+  //if(e_filter != NULL) { ii=(*e_filter)(NULL); }
 
   while(read(l_chan,c_temp,l_size)==l_size) {
     l_file_pos=l_bufnr*l_size;
@@ -2232,6 +2314,11 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
             l_evt_buf_size=l_evsize*2;
             pc_evt_buf=(CHARS*)malloc(l_evt_buf_size);
           }
+          if(NULL == pc_evt_buf)
+          {
+            l_evt_buf_size=l_evsize*2;
+            pc_evt_buf=(CHARS*)malloc(l_evt_buf_size);
+          }
           /* copy event fragment to buffer */
           ps=(INTU4*)ps_ve10_1;
           pd=(INTU4*)pc_evt_buf;
@@ -2253,7 +2340,16 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
           ps_ve10_1->l_dlen=l_evsize-4;
           /* rewind last buffer, will be read again by while loop */
           l_bufnr--;
-          lseek(l_chan, -l_size, SEEK_CUR);
+          val = lseek(l_chan, -l_size, SEEK_CUR);
+          if(-1 == val)
+          {
+            free(pc_evt_buf);
+            ps_ve10_1 = NULL;
+            pd = NULL;
+            close(l_chan);
+            close(l_out);
+            return(GETEVT__FAILURE);
+          }
         }
         s_tag.l_offset=-l_file_pos;
         /* printf("Event %10d pos %10d Buffer -%6d\n",ps_ve10_1->l_count, l_file_pos,l_bufnr);*/
@@ -2281,7 +2377,13 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
     l_bufnr++;
     /*      if(l_bufnr > 3) break; */
   }
-  lseek(l_out, 0, SEEK_SET);  /* rewind file */
+  val = lseek(l_out, 0, SEEK_SET);  /* rewind file */
+  if(-1 == val)
+  {
+    close(l_chan);
+    close(l_out);
+    return(GETEVT__FAILURE);
+  }
   s_taghe.l_endian   = 1;
   s_taghe.l_version  = 1;
   s_taghe.l_bufsize  = l_size;
@@ -2339,7 +2441,7 @@ INTS4 f_evt_cre_tagfile(CHARS* pc_lmd, CHARS* pc_tag,INTS4 (*e_filter)())
 /*1- C Main ****************+******************************************/
 INTS4 f_evt_get_tagopen(s_evt_channel* ps_chan,CHARS* pc_tag,CHARS* pc_lmd, CHARS** ps_head, INTS4 l_prihe)
 {
-  INTS4 l_temp,ii;
+  INTS4 /*l_temp,*/ii;
   s_bufhe* ps_bufhe;
 
   ps_chan->ps_tag = NULL; /* tagfile buffer */
@@ -2376,6 +2478,11 @@ INTS4 f_evt_get_tagopen(s_evt_channel* ps_chan,CHARS* pc_tag,CHARS* pc_lmd, CHAR
     close(ps_chan->l_tagfile_no);
     return(GETEVT__TAGRDERR);
   }
+  if(NULL == ps_chan->ps_taghe)
+  {
+    close(ps_chan->l_tagfile_no);
+    return(GETEVT__TAGRDERR);
+  }
   if(ps_chan->ps_taghe->l_endian != 1) { ps_chan->l_tagswap=1; }
   if(ps_chan->l_tagswap) { f_evt_swap((CHARS*)ps_chan->ps_taghe,sizeof(s_taghe)); }
   if(l_prihe) {
@@ -2396,25 +2503,31 @@ INTS4 f_evt_get_tagopen(s_evt_channel* ps_chan,CHARS* pc_tag,CHARS* pc_lmd, CHAR
   }
   /* read buffer header to check if we have to swap */
   ps_bufhe  = (s_bufhe*)c_temp;
-  if(read(ps_chan->l_channel_no,c_temp,ps_chan->ps_taghe->l_bufsize)!=ps_chan->ps_taghe->l_bufsize) {
-    if(ps_chan->ps_taghe != NULL) { free(ps_chan->ps_taghe); }
-    ps_chan->ps_taghe = NULL;
-    if(ps_chan->ps_tag != NULL) { free(ps_chan->ps_tag); }
-    ps_chan->ps_tag = NULL;
-    close(ps_chan->l_tagfile_no);
-    close(ps_chan->l_channel_no);
-    return(GETEVT__RDERR);
-  }
-  if(ps_chan->ps_taghe->l_linear == 0) {
-    ps_chan->ps_tag = (s_tag*)malloc(ps_chan->ps_taghe->l_filesize);
-    if(read(ps_chan->l_tagfile_no,(CHARS*)ps_chan->ps_tag,ps_chan->ps_taghe->l_filesize)!=ps_chan->ps_taghe->l_filesize) {
+  if (ps_chan->ps_taghe->l_bufsize >=0 && ps_chan->ps_taghe->l_bufsize < sizeof(c_temp)) {
+    if(read(ps_chan->l_channel_no,c_temp,ps_chan->ps_taghe->l_bufsize)!=ps_chan->ps_taghe->l_bufsize) {
       if(ps_chan->ps_taghe != NULL) { free(ps_chan->ps_taghe); }
       ps_chan->ps_taghe = NULL;
       if(ps_chan->ps_tag != NULL) { free(ps_chan->ps_tag); }
       ps_chan->ps_tag = NULL;
       close(ps_chan->l_tagfile_no);
       close(ps_chan->l_channel_no);
-      return(GETEVT__TAGRDERR);
+      return(GETEVT__RDERR);
+    }
+  }
+  if(ps_chan->ps_taghe != NULL) {
+    if(ps_chan->ps_taghe->l_linear == 0) {
+      if (ps_chan->ps_taghe->l_filesize >=0 && ps_chan->ps_taghe->l_filesize < sizeof(s_tag)) {
+        ps_chan->ps_tag = (s_tag*)malloc(ps_chan->ps_taghe->l_filesize);
+        if(read(ps_chan->l_tagfile_no,(CHARS*)ps_chan->ps_tag,ps_chan->ps_taghe->l_filesize)!=ps_chan->ps_taghe->l_filesize) {
+          if(ps_chan->ps_taghe != NULL) { free(ps_chan->ps_taghe); }
+          ps_chan->ps_taghe = NULL;
+          if(ps_chan->ps_tag != NULL) { free(ps_chan->ps_tag); }
+          ps_chan->ps_tag = NULL;
+          close(ps_chan->l_tagfile_no);
+          close(ps_chan->l_channel_no);
+          return(GETEVT__TAGRDERR);
+        }
+      }
     }
   }
   if(ps_bufhe->l_free[0] != 1) { ps_chan->l_lmdswap=1; }
@@ -2455,7 +2568,7 @@ INTS4 f_evt_get_tagopen(s_evt_channel* ps_chan,CHARS* pc_tag,CHARS* pc_lmd, CHAR
 /*1- C Main ****************+******************************************/
 INTS4 f_evt_get_tagnext(s_evt_channel* ps_chan,INTS4 l_skip, INTS4** pl_event)
 {
-  INTS4 ii,*pl,kk;
+  INTS4 ii = 0,*pl=NULL,kk;
   /* no tagfile */
   /*=============================================*/
   if(ps_chan->ps_taghe == NULL) {
@@ -2501,15 +2614,15 @@ INTS4 f_evt_get_tagnext(s_evt_channel* ps_chan,INTS4 l_skip, INTS4** pl_event)
 /*1- C Main ****************+******************************************/
 INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INTS4** pl_event)
 {
-  INTS4 l_temp,l_chan,l_tag,ii,kk,lb,l_tagbufs,l_tagrest,l_evt,l_off,l_typ,l_val,l_evsize,l_fragsize;
+  INTS4 /*l_temp,l_chan,l_tag,*/ii,kk,/*lb,l_tagbufs,l_tagrest,*/l_evt,l_off,l_typ,l_val,l_evsize,l_fragsize;
   INTS4 la_head[2],*pl;
   CHARS* pc;
   s_ve10_1* ps_ve10_1;
   s_bufhe* ps_bufhe;
   s_tag* ps_tag;
   s_tag s_tag_l;
-  s_filhe* ps_filhe;
-  s_evt_channel s_chan_i;
+//  s_filhe* ps_filhe;
+//  s_evt_channel s_chan_i;
 
   l_typ=l_type;
   l_val=l_value;
@@ -2553,7 +2666,11 @@ INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INT
     }
     if(l_val == 0) { l_val=1; }
     ps_tag=(s_tag*)&s_tag_l;
-    lseek(ps_chan->l_tagfile_no, (l_val-1)*sizeof(s_tag)+sizeof(s_taghe), SEEK_SET);  /* set file offset*/
+    int val = lseek(ps_chan->l_tagfile_no, (l_val-1)*sizeof(s_tag)+sizeof(s_taghe), SEEK_SET);  /* set file offset*/
+    if(-1 == val)
+    {
+      return(GETEVT__TAGRDERR);
+    }
     if(read(ps_chan->l_tagfile_no,(CHARS*)ps_tag,sizeof(s_tag))!=sizeof(s_tag)) {
       return(GETEVT__TAGRDERR);
     }
@@ -2576,9 +2693,14 @@ INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INT
   if(l_off < 0) { l_off=((-l_off)/ps_chan->ps_taghe->l_bufsize)*ps_chan->ps_taghe->l_bufsize; }
   l_evt=ps_tag->l_event;
   /* full event in buffer, read */
+  int val;
   if(ps_tag->l_offset > 0) {
     ps_ve10_1 = (s_ve10_1*)c_temp;
-    lseek(ps_chan->l_channel_no, l_off, SEEK_SET);  /* set file offset*/
+    val = lseek(ps_chan->l_channel_no, l_off, SEEK_SET);  /* set file offset*/
+    if(-1 == val)
+    {
+      return(GETEVT__TAGRDERR);
+    }
     if(read(ps_chan->l_channel_no,c_temp,8)!=8) { return(GETEVT__RDERR); }
     if(ps_chan->l_lmdswap) { f_evt_swap(c_temp,8); }
     if(read(ps_chan->l_channel_no,(CHARS*)&c_temp[8],ps_ve10_1->l_dlen*2)!=ps_ve10_1->l_dlen*2) { return(GETEVT__RDERR); }
@@ -2587,7 +2709,11 @@ INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INT
   } else
     /* spanning event begin, read to event buffer */
   {
-    lseek(ps_chan->l_channel_no, l_off, SEEK_SET);  /* set file offset to buffer begin */
+    val = lseek(ps_chan->l_channel_no, l_off, SEEK_SET);  /* set file offset to buffer begin */
+    if(-1 == val)
+    {
+      return(GETEVT__TAGRDERR);
+    }
     if(read(ps_chan->l_channel_no,c_temp,sizeof(s_bufhe))!=sizeof(s_bufhe)) { return(GETEVT__RDERR); }
     if(ps_chan->l_lmdswap) { f_evt_swap(c_temp,sizeof(s_bufhe)); }
     /* is event buffer big enough? */
@@ -2599,7 +2725,11 @@ INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INT
     }
     l_fragsize=0;
     ps_ve10_1 = (s_ve10_1*)ps_chan->pc_evt_buf;
-    lseek(ps_chan->l_channel_no, -ps_tag->l_offset, SEEK_SET);  /* set file offset*/
+    val = lseek(ps_chan->l_channel_no, -ps_tag->l_offset, SEEK_SET);  /* set file offset*/
+    if(-1 == val)
+    {
+      return(GETEVT__TAGRDERR);
+    }
     if(read(ps_chan->l_channel_no,ps_chan->pc_evt_buf,8)!=8) { return(GETEVT__RDERR); }
     if(ps_chan->l_lmdswap) { f_evt_swap(ps_chan->pc_evt_buf,8); }
     pc=ps_chan->pc_evt_buf+8;
@@ -2611,7 +2741,11 @@ INTS4 f_evt_get_tagevent(s_evt_channel* ps_chan,INTS4 l_value, INTS4 l_type, INT
     /* loop over fragments */
     while(l_fragsize < l_evsize) {
       l_off += ps_chan->ps_taghe->l_bufsize; /* next buffer absolut address */
-      lseek(ps_chan->l_channel_no,l_off+sizeof(s_bufhe), SEEK_SET);  /* set file offset*/
+      val = lseek(ps_chan->l_channel_no,l_off+sizeof(s_bufhe), SEEK_SET);  /* set file offset*/
+      if(-1 == val)
+      {
+        return(GETEVT__TAGRDERR);
+      }
       if(read(ps_chan->l_channel_no,(CHARS*)&la_head,8)!=8) { return(GETEVT__RDERR); }
       if(ps_chan->l_lmdswap) { f_evt_swap((CHARS*)&la_head,8); }
       if(read(ps_chan->l_channel_no,pc,la_head[0]*2)!=la_head[0]*2) { return(GETEVT__RDERR); }
diff --git a/MbsAPI/f_evt.h b/MbsAPI/f_evt.h
index 680c029..306a618 100644
--- a/MbsAPI/f_evt.h
+++ b/MbsAPI/f_evt.h
@@ -1,16 +1,10 @@
-// $Id: f_evt.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*****************  f_evt.h ******************************/
 #ifndef F_EVT
 #define F_EVT
diff --git a/MbsAPI/f_find_peaks.c b/MbsAPI/f_find_peaks.c
deleted file mode 100644
index 94f19d9..0000000
--- a/MbsAPI/f_find_peaks.c
+++ /dev/null
@@ -1,346 +0,0 @@
-// $Id: f_find_peaks.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-
-/****************************************************************
- *
- * Copyright (C)
- *
- *  Gesellschaft f. Schwerionenforschung, GSI
- *  Planckstr. 1
- *  64291 Darmstadt
- *  Germany
- *
- * Author: H.Essel@gsi.de
- *
- *  This program is free software; you can redistribute it and/or
- *  modify it under the terms of the
- *      GNU General Public License
- *  as published by the Free Software Foundation; either version 2
- *  of the License, or (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- *  See the GNU General Public License for more details
- *  (http://www.gnu.org).
- *
- *****************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#define UP 1
-#define DOWN -1
-#define HORI 0
-#define PRINT 0
-#include "f_find_peaks.h"
-
-void f_find_peaks(
-  void*   pfData,     // pointer to data
-  int     lType,      // data type: 0=w 1=l 2=f 3=d
-  int     lFirstChan, // first channel
-  int     lPoints,    // number of points
-  int     lAver,      // channels to sum up
-  double  dDeltaFact, // noise factor
-  double  dDeltaMin,  // noise minimum
-  double* dNoise,     // noise array
-  int     lPeaksMax,  // Maximum number of peaks
-  int*    plPeaks,    // returns number of peaks found
-  int*    plMinima,   // pointer to list of minima
-  double* pdMinima,   // pointer to list of minima values
-  int*    plMaxima,   // pointer to list of maxima
-  int*    plWidth,    // pointer to list of width
-  double* pdIntegral) // pointer to list of integrals
-{
-  short* pw;
-  int lMaxIndex,lMinIndex,lIndexMax,lDirection,lIndex,lLastUp,lLastDown,ii,i,
-      *plMinimaL,*plMaximaL,*plMinimaR,*plMaximaR,lPrint,*pl;
-  float* pf;
-  double dValue,dLow,dHigh,dDelta,dAver,*pdData,*pdNoise,dMax,dMin,dPos,dSig,dSum,*pd;
-
-  *plPeaks=0;
-  pdNoise=NULL;
-  pdData = (double*)malloc(lPoints*8);
-  pdNoise = (double*)malloc(lPoints*8);
-  memset(pdData,0,lPoints*8);
-  memset(pdNoise,0,lPoints*8);
-  lPrint=PRINT;
-  dMax=0.;
-  dMin=1e20;
-  pw = ((short*)pfData) + lFirstChan;
-  pl = ((int*)pfData) + lFirstChan;
-  pf = ((float*)pfData) + lFirstChan;
-  pd = ((double*)pfData) + lFirstChan;
-  if(lAver == 0) { lAver=1; }
-  lPoints=lPoints/lAver;
-  dAver = (double) lAver;
-  // copy the data field into local double field
-  switch(lType) {
-  case TYPE__SHORT:
-    for(ii=0; ii<lPoints; ii++) {
-      *(pdData+ii) = (double)*(pw+lAver*ii);
-      for(i=1; i<lAver; i++) { *(pdData+ii) += (double)*(pw+lAver*ii+i); }
-      *(pdData+ii) = *(pdData+ii)/dAver;
-      if(*(pdData+ii) > dMax) { dMax=*(pdData+ii); }
-      if(*(pdData+ii) < dMin) { dMin=*(pdData+ii); }
-    }
-    break;
-  case TYPE__INT:
-    for(ii=0; ii<lPoints; ii++) {
-      *(pdData+ii) = (double)*(pl+lAver*ii);
-      for(i=1; i<lAver; i++) { *(pdData+ii) += (double)*(pl+lAver*ii+i); }
-      *(pdData+ii) = *(pdData+ii)/dAver;
-      if(*(pdData+ii) > dMax) { dMax=*(pdData+ii); }
-      if(*(pdData+ii) < dMin) { dMin=*(pdData+ii); }
-    }
-    break;
-  case TYPE__FLOAT:
-    for(ii=0; ii<lPoints; ii++) {
-      *(pdData+ii) = (double)*(pf+lAver*ii);
-      for(i=1; i<lAver; i++) { *(pdData+ii) += (double)*(pf+lAver*ii+i); }
-      *(pdData+ii) = *(pdData+ii)/dAver;
-      if(*(pdData+ii) > dMax) { dMax=*(pdData+ii); }
-      if(*(pdData+ii) < dMin) { dMin=*(pdData+ii); }
-    }
-    break;
-  case TYPE__DOUBLE:
-    for(ii=0; ii<lPoints; ii++) {
-      *(pdData+ii) = (double)*(pd+lAver*ii);
-      for(i=1; i<lAver; i++) { *(pdData+ii) += (double)*(pd+lAver*ii+i); }
-      *(pdData+ii) = *(pdData+ii)/dAver;
-      if(*(pdData+ii) > dMax) { dMax=*(pdData+ii); }
-      if(*(pdData+ii) < dMin) { dMin=*(pdData+ii); }
-    }
-    break;
-  default:
-    printf("Data type %d not supported!\n",lType);
-    printf("Type 0: short, 1: int, 2: float, 3: double\n");
-    free(pdData);
-    free(pdNoise);
-    return;
-  }
-  if(dNoise == NULL) {
-    // calculate from square root
-    for(ii=0; ii<lPoints; ii++) {
-      if(*(pdData+ii) == 0.0) { *(pdNoise+ii) = dDeltaFact; }
-      else { *(pdNoise+ii) = sqrt(*(pdData+ii)) * dDeltaFact; }
-      if(dDeltaMin > *(pdNoise+ii)) { *(pdNoise+ii)=dDeltaMin; }
-    }
-  } else {// sum up bins from noise input array
-    for(ii=0; ii<lPoints; ii++) {
-      *(pdNoise+ii) = *(dNoise+lFirstChan+lAver*ii);
-      for(i=1; i<lAver; i++) { *(pdNoise+ii) += *(dNoise+lFirstChan+lAver*ii+i); }
-      *(pdNoise+ii) = *(pdNoise+ii)/dAver;
-    }
-  }
-  lMaxIndex=0;
-  lMinIndex=0;
-  lIndexMax=lPoints-1;
-  plMinimaL = (int*)malloc(lPeaksMax*16);
-  plMaximaL = (int*)(plMinimaL+lPeaksMax);
-  plMinimaR = (int*)(plMinimaL+2*lPeaksMax);
-  plMaximaR = (int*)(plMinimaL+3*lPeaksMax);
-  memset(plMinimaL,0,lPeaksMax*16);
-
-  dDelta= *pdNoise;
-  dHigh = *pdData + dDelta;
-  dLow  = *pdData - dDelta;
-  //-----------------------------------------------------
-  // loop: get points of minima and maxima
-  lDirection=HORI;
-  lIndex=0;
-  lLastDown=0;
-  lLastUp=0;
-  while ((lIndex <= lIndexMax) & (lMaxIndex < lPeaksMax-2)) {
-    dValue = *(pdData+lIndex);
-    if(dValue > dHigh) {
-      // direction goes upstairs
-      if (lDirection != UP) {
-        // direction was downstairs: minimum found
-        if(lPrint)printf("%5d - %5d - %5d d %8.1f\n",
-                           lMinIndex,
-                           lLastDown,
-                           lIndex,
-                           dDelta);
-        *(plMinimaR+lMinIndex)=lIndex;
-        *(plMinimaL+lMinIndex)=lLastDown;
-        lMinIndex++;
-      }
-      lLastUp=lIndex;
-      lDirection=UP;// direction goes upstairs
-    }
-    if(dValue < dLow) {
-      // direction goes downstairs
-      if (lDirection == UP) {
-        // direction was upstairs: maximum found
-        if(lPrint)printf("%5d + %5d - %5d d %8.1f\n",
-                           lMaxIndex,
-                           lLastUp,
-                           lIndex,
-                           dDelta);
-        *(plMaximaR+lMaxIndex)=lIndex;
-        *(plMaximaL+lMaxIndex)=lLastUp;
-        lMaxIndex++;
-      }
-      lLastDown=lIndex;
-      lDirection=DOWN;// direction goes downstairs
-    }
-    // calculate new limits if noise band has been left
-    if((dValue < dLow)|(dValue > dHigh)) {
-      dDelta= *(pdNoise+lIndex);
-      dHigh = dValue + dDelta;
-      dLow  = dValue - dDelta;
-    }
-    lIndex++;
-  }
-  if(lDirection == DOWN) {
-    *(plMinimaL+lMinIndex)=lLastDown;
-    *(plMinimaR+lMinIndex)=lIndexMax;
-    if(lPrint)printf("%5d - %5d - %5d\n",
-                       lMinIndex,
-                       lLastDown,
-                       lIndexMax);
-    lMinIndex++;
-  }
-  //-----------------------------------------------------
-  if(lPrint) { printf("-------------------------\n"); }
-  if(lPrint) { printf("Minima %d Maxima %d  \n",lMinIndex,lMaxIndex); }
-  // for each peak there must be a minimum left and right
-  if(lMinIndex != (lMaxIndex+1)) {
-    free(plMinimaL);
-    free(pdData);
-    free(pdNoise);
-    printf("Error, wrong minima\n");
-    return;
-  }
-  // calculate mean values of minima L&R, mean content, peaks
-  // start with first minimum
-  if(lPrint) { printf("  [ Left   Right ]  \n"); }
-  *plMinima = (*plMinimaL + *plMinimaR)/2;
-  *plMinima = (int)((double)(*plMinima)*dAver + dAver/2.)+lFirstChan;
-  *pdMinima=0.; // average content at mean minimum channel
-  for(ii = *plMinimaL; ii <= *plMinimaR; ii++) { *pdMinima += *(pdData+ii); }
-  *pdMinima = *pdMinima/(double)(*plMinimaR - *plMinimaL + 1);
-  if(lPrint)printf("- [%6d %6d] %6d %6.1f\n",
-                     *plMinimaL,
-                     *plMinimaR,
-                     *plMinima,
-                     *pdMinima);
-  for(lIndex=0; lIndex < lMaxIndex; lIndex++) {
-    // simple mean peak value, overwritten later
-    *(plMaxima+lIndex)=(*(plMaximaL+lIndex)+*(plMaximaR+lIndex))/2;
-    if(lPrint)printf("+ [%6d %6d] %6d\n",
-                       *(plMaximaL+lIndex),
-                       *(plMaximaR+lIndex),
-                       *(plMaxima+lIndex));
-    // mean minima values (channel and content)
-    *(plMinima+lIndex+1) = (*(plMinimaL+lIndex+1) + *(plMinimaR+lIndex+1))/2;
-    *(plMinima+lIndex+1) = (int)((double)(*(plMinima+lIndex+1))*dAver + dAver/2.)+lFirstChan;
-    *(pdMinima+lIndex+1)=0.;
-    for(ii = *(plMinimaL+lIndex+1); ii <= *(plMinimaR+lIndex+1); ii++) {
-      *(pdMinima+lIndex+1) += *(pdData+ii);
-    }
-    *(pdMinima+lIndex+1) = *(pdMinima+lIndex+1)/
-                           (double)(*(plMinimaR+lIndex+1) - *(plMinimaL+lIndex+1)+1);
-    if(lPrint)printf("- [%6d %6d] %6d %6.1f\n",
-                       *(plMinimaL+lIndex+1),
-                       *(plMinimaR+lIndex+1),
-                       *(plMinima+lIndex+1),
-                       *(pdMinima+lIndex+1));
-    // Peak positions, width and sum by momenta
-    ii = *(plMinimaL+lIndex+1) - *(plMinimaR+lIndex) + 1;
-    if(ii > 1) {
-      f_position(ii,pdData + *(plMinimaR+lIndex),&dPos,&dSig,&dSum);
-
-      *(plMaxima+*plPeaks)=(int)((dPos+(double)(*(plMinimaR+lIndex)))*dAver)+lFirstChan;
-      *(plWidth+*plPeaks) =(int)(dSig*dAver + 0.5);
-      if(*(pdMinima+lIndex) < *(pdMinima+lIndex+1)) {
-        dSum=dSum-((double)ii * *(pdMinima+lIndex)+ (double)ii * (*(pdMinima+lIndex+1)-*(pdMinima+lIndex))/2.);
-      } else {
-        dSum=dSum-((double)ii * *(pdMinima+lIndex)- (double)ii * (*(pdMinima+lIndex)-*(pdMinima+lIndex+1))/2.);
-      }
-      *(pdIntegral+*plPeaks) = dSum*dAver;
-      (*plPeaks)++;
-    } else {
-      free(plMinimaL);
-      free(pdData);
-      free(pdNoise);
-      printf("Error, negative interval\n");
-      return;
-    }
-  }
-  if(lPrint) { printf("peaks found %d\n",*plPeaks); }
-
-  free(plMinimaL);
-  free(pdData);
-  free(pdNoise);
-}
-//**********************************************************************************
-int f_position(int l_len,double* pa_data,double* pr_pos,double* pr_sig, double* pr_sum)
-{
-
-#define LOW  2
-#define WIDTH  8
-
-  double r_sig_f     ;
-  int I,J,K,L     ;
-  double d_sum_prod  ;
-  double l_max_chan  ;
-  double* pl_data,d_max    ;
-
-  /* 2.0E2*SQRT(2.0E0*LOG(2.0E0))/100. */;
-  r_sig_f      = 55.4518;
-  r_sig_f      = 2.;
-  *pr_sum   = 0;
-  d_sum_prod   = 0;
-  *pr_sig      = 0.;
-  *pr_pos      = 0.;
-  d_max=0.0;
-
-  /* get maximum channel content and integral */
-  /*  pl_data = pa_data;
-      for(J = 0; J < l_len; J++)
-      {
-      if(d_max < *pl_data)
-      {
-      d_max = *pl_data;
-      l_max_chan = J;
-      }
-      pl_data++;
-      }
-  */
-  /* Calculate first momentum */
-  pl_data = pa_data;
-  for(J = 1; J <= l_len; J++) {
-    *pr_sum = *pr_sum +     *pl_data;
-    d_sum_prod = d_sum_prod + J * *pl_data;
-    pl_data++;
-  }
-  /* Calculate second momentum */
-  if(*pr_sum > 0) {
-    *pr_pos = (d_sum_prod/ *pr_sum + 0.5);
-    pl_data = pa_data;
-    for(J = 1; J <= l_len; J++) {
-      *pr_sig = *pr_sig + ((double)J - *pr_pos) * ((double)J - *pr_pos) * *pl_data;
-      pl_data++;
-    }
-    *pr_sig = r_sig_f * sqrt(*pr_sig/ *pr_sum);
-  } else { return(1); }
-  *pr_pos = *pr_pos -1.0;
-  return(0);
-}
-/** END f_position C Procedure ******************************************/
diff --git a/MbsAPI/f_find_peaks.h b/MbsAPI/f_find_peaks.h
deleted file mode 100644
index 92b7388..0000000
--- a/MbsAPI/f_find_peaks.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// $Id: f_find_peaks.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_FIND_PEAKS
-#define F_FIND_PEAKS
-
-#define TYPE__SHORT  0
-#define TYPE__INT    1
-#define TYPE__FLOAT  2
-#define TYPE__DOUBLE 3
-void f_find_peaks(
-  void*,     // pointer to data
-  int,       // data type: use definitions above
-  int,       // first channel (0,...)
-  int,       // number of channels
-  int,       // channels to sum up (bin size in channels)
-  double,    // noise factor to square root
-  double,    // noise minimum (absolut)
-  double*,   // array with noise (original channels)
-  int,       // Maximum number of peaks. Arrays below must have this size.
-  int*,      // returns number of peaks found
-  int*,      // pointer to array of minima
-  double*,   // pointer to array of minima values
-  int*,      // pointer to array of maxima
-  int*,      // pointer to array of width
-  double*);  // pointer to array of integrals
-
-#endif
diff --git a/MbsAPI/f_his_hist.c b/MbsAPI/f_his_hist.c
deleted file mode 100644
index 4e7373a..0000000
--- a/MbsAPI/f_his_hist.c
+++ /dev/null
@@ -1,697 +0,0 @@
-// $Id: f_his_hist.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#include "f_his_hist.h"
-#include "f_his_toupper.h"
-#include "f_his_swpbas.h"
-#include "f_stccomm.h"
-#include "f_swaplw.h"
-#include "f_ut_compress.h"
-#include "portnum_def.h"
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-static CHARS c_gl_serv_access[64];
-static CHARS c_gl_serv_base[32];
-static INTS4 l_gl_serv_port;
-static INTS4 l_gl_serv_chan;
-static INTS4 l_gl_serv_verb;
-struct s_tcpcomm* ps_tcpserv;
-s_his_comm s_his_comm_serv;
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 41                                                */
-/*   D-6100 Darmstadt 11                                              */
-/*                                                                    */
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_getbas                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_getbas(char server, int port, char base, char password, int **p_buf)*/
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Returns list of histogram available from server     */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+   c_server  : Node of server.                                     */
-/*+  l_port     : Port number (must be known from server)             */
-/*+  c_base     : Histogram base name                                 */
-/*+  c_password : Password if required from server                    */
-/*+    p_buf    : Address of buffer pointer.                          */
-/*                Data base is allocated and address returned.        */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOACCESS: Password wrong                      */
-/*-               COMM__NOBASE  : Base wrong                          */
-/*-               COMM__NOSERVER: Cannot connect (Port?)              */
-/*-               COMM__NOHIST  : Histogram not there                 */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Connects to histogram server.                       */
-/*                Allocates and returns LEA data base                 */
-/*                Bse must be compressed by server.                   */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_getbas(CHARS* pc_server, INTS4 l_port, CHARS* pc_base, CHARS* pc_access,INTS4** p_buffer)
-{
-  s_his_comm s_his_comm_cli;
-  s_his_head* ps_his_head;
-  INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
-  INTS4* pl_all,*pl_l;
-  s_compress*               ps_compress;
-  struct s_tcpcomm* ps_tcpcli;
-
-  ps_tcpcli = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-
-  /* get base ***************************************************/
-  s_his_comm_cli.lu_endian=1;
-  s_his_comm_cli.lu_size=0;
-  s_his_comm_cli.lu_histos=0;
-  s_his_comm_cli.lu_action=COMM__GETBASE;
-  s_his_comm_cli.l_status=COMM__SUCCESS;
-  strcpy(s_his_comm_cli.c_histo,"*");
-  strcpy(s_his_comm_cli.c_access,pc_access);
-  strcpy(s_his_comm_cli.c_base,pc_base);
-  l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
-  if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER; goto g_return;}
-  l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_swap = (s_his_comm_cli.lu_endian > 1);
-  if(l_swap) { l_status = f_swaplw((INTS4*)&s_his_comm_cli,5,NULL); }
-  if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status; goto g_return;}
-
-  /* allocate buffer for comporessed base */
-  pl_all  = (INTS4*)malloc(s_his_comm_cli.lu_size);
-  l_buffer = s_his_comm_cli.lu_size;
-  /* break total buffer in TCP buffers */
-  pl_l=pl_all;
-  i_l=l_buffer/16384;
-  l_buffer=l_buffer%16384;
-  for(i_j=0; i_j<i_l; i_j++) {l_status = f_stc_read (pl_l,16384,l_chan,-1); pl_l+=4096;}
-  if(l_buffer > 0) { l_status = f_stc_read (pl_l,l_buffer,l_chan,-1); }
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  /* uncompress base */
-  ps_compress = (s_compress*) pl_all;
-  if(l_swap == 1) {
-    f_swaplw((INTS4*)pl_all,sizeof(s_compress)/4,NULL);
-    pl_l=pl_all+(sizeof(s_compress)/4);
-    f_swaplw((INTS4*)pl_l,ps_compress->l_masks,NULL);
-  }
-  *p_buffer  = (INTS4*)malloc(ps_compress->l_full_bytes);
-  f_ut_compr_unpack((INTU1*)pl_all,(INTU1*) *p_buffer,ps_compress->l_full_bytes);
-  if(l_swap == 1) { l_status = f_his_swpbas((s_head*) *p_buffer); }
-
-  l_status=COMM__SUCCESS;
-g_return:
-  f_stc_discclient (l_chan);
-  f_stc_close (ps_tcpcli);
-  free(pl_all);
-  free(ps_tcpcli);
-  return(l_status);
-}
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_getdir                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_getdir(char server, int port, char base, char password,*/
-/*                              char histo, int **p_buf, int **l_histos)*/
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Returns list of histogram available from server     */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+   c_server  : Node of server.                                     */
-/*+  l_port     : Port number (must be known from server)             */
-/*+  c_base     : Histogram base name                                 */
-/*+  c_password : Password if required from server                    */
-/*+  c_histo    : Histogram wildcard                                  */
-/*+    p_buf    : Address of buffer pointer.                          */
-/*                If NULL, buffer is allocated, if not l_histos gives */
-/*                size of buffer in sizeof(s_his_head).               */
-/*+   l_histos  : Size in sizeof(s_his_head) of buffer,               */
-/*                returns number of histograms                        */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOACCESS: Password wrong                      */
-/*-               COMM__NOBASE  : Base wrong                          */
-/*-               COMM__NOSERVER: Cannot connect (Port?)              */
-/*-               COMM__NOHIST  : Histogram not there                 */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Connects to histogram server.                       */
-/*                Returns buffer with s_his_head slots                */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_getdir(CHARS* pc_server, INTS4 l_port, CHARS* pc_base, CHARS* pc_access, CHARS* pc_histo
-                   ,INTS4** p_buffer, INTS4* pl_histos)
-{
-  s_his_comm s_his_comm_cli;
-  s_his_head* ps_his_head;
-  INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
-  INTS4* pl_all,*pl_l;
-  struct s_tcpcomm* ps_tcpcli;
-
-  ps_tcpcli = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-
-  /* get directory ***************************************************/
-  s_his_comm_cli.lu_endian=1;
-  s_his_comm_cli.lu_size=0;
-  s_his_comm_cli.lu_histos=0;
-  s_his_comm_cli.lu_action=COMM__GETDIR;
-  s_his_comm_cli.l_status=COMM__SUCCESS;
-  strcpy(s_his_comm_cli.c_histo,pc_histo);
-  strcpy(s_his_comm_cli.c_access,pc_access);
-  strcpy(s_his_comm_cli.c_base,pc_base);
-  l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
-  if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER; goto g_return;}
-  l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_swap = (s_his_comm_cli.lu_endian > 1);
-  if(l_swap) { l_status = f_swaplw((INTS4*)&s_his_comm_cli,5,NULL); }
-  if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status; goto g_return;}
-
-  l_histos=s_his_comm_cli.lu_histos;
-  l_size=sizeof(s_his_head)*l_histos;
-  /* allocate buffer */
-  if(*p_buffer == 0) {
-    pl_all  = (INTS4*)malloc(l_size);
-    *p_buffer = pl_all;
-  } else {
-    if(*pl_histos < l_histos) {l_status=COMM__ERROR; goto g_return;}
-    pl_all = *p_buffer;
-  }
-  *pl_histos = l_histos;
-  l_buffer = s_his_comm_cli.lu_size;
-  /* break total buffer in TCP buffers */
-  pl_l=pl_all;
-  i_l=l_buffer/16384;
-  l_buffer=l_buffer%16384;
-  for(i_j=0; i_j<i_l; i_j++) {l_status = f_stc_read (pl_l,16384,l_chan,-1); pl_l+=4096;}
-  if(l_buffer > 0) { l_status = f_stc_read (pl_l,l_buffer,l_chan,-1); }
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-
-  ps_his_head = (s_his_head*)pl_all;
-  for(i_j=0; i_j<s_his_comm_cli.lu_histos; i_j++) {
-    if(l_swap) { l_status = f_swaplw((INTS4*)ps_his_head,16,NULL); }
-    ps_his_head++;
-
-  }
-  l_status=COMM__SUCCESS;
-g_return:
-  f_stc_discclient (l_chan);
-  f_stc_close (ps_tcpcli);
-  free(ps_tcpcli);
-  return(l_status);
-}
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 41                                                */
-/*   D-6100 Darmstadt 11                                              */
-/*                                                                    */
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_gethis                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_gethis(char server, int port, char base, char password,*/
-/*                        char histo, s_his_head **p_head, int **p_buf, int **l_size)*/
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Returns histogram from server                       */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+   c_server  : Node of server.                                     */
-/*+  l_port     : Port number (must be known from server)             */
-/*+  c_base     : Histogram base name                                 */
-/*+  c_password : Password if required from server                    */
-/*+  c_histo    : Histogram                                           */
-/*+    p_head   : Address of header pointer (s_his_head)              */
-/*                If NULL, s_his_head will be allocated               */
-/*+    p_buf    : Address of buffer pointer                           */
-/*                If NULL, buffer for data will be allocated          */
-/*+   l_size    : Size in bytes of buffer, returns size               */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOACCESS: Password wrong                      */
-/*-               COMM__NOBASE  : Base wrong                          */
-/*-               COMM__NOSERVER: Cannot connect (Port?)              */
-/*-               COMM__NOHIST  : Histogram not there                 */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Connects to histogram server.                       */
-/*                Returns buffer with s_his_head and data buffer      */
-/*                Required buffer size can be obtained from           */
-/*                s_his_head after calling f_his_getdir.              */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_gethis(CHARS* pc_server, INTS4 l_port, CHARS* pc_base, CHARS* pc_access, CHARS* pc_histo
-                   , s_his_head** p_head, INTS4** p_buffer, INTS4* pl_size)
-{
-  s_his_comm s_his_comm_cli;
-  s_his_head* ps_his_head;
-  INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
-  INTS4* pl_all,*pl_head,*pl_l;
-  struct s_tcpcomm* ps_tcpcli;
-
-  ps_tcpcli = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-
-  /* get histogram ******************************************************/
-  s_his_comm_cli.lu_endian=1;
-  s_his_comm_cli.lu_size=0;
-  s_his_comm_cli.lu_histos=0;
-  s_his_comm_cli.lu_action=COMM__GETHIST;
-  s_his_comm_cli.l_status=COMM__SUCCESS;
-  strcpy(s_his_comm_cli.c_histo,pc_histo);
-  strcpy(s_his_comm_cli.c_access,pc_access);
-  strcpy(s_his_comm_cli.c_base,pc_base);
-  l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
-  if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER; goto g_return;}
-  l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-  l_swap = (s_his_comm_cli.lu_endian > 1);
-  if(l_swap) { l_status = f_swaplw((INTS4*)&s_his_comm_cli,5,NULL); }
-  if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status; goto g_return;}
-
-  l_size=s_his_comm_cli.lu_size-sizeof(s_his_head);
-  /* allocate buffer */
-  if(*p_buffer == 0) {
-    pl_all  = (INTS4*)malloc(l_size);
-    *p_buffer = pl_all;
-  } else {
-    if(*pl_size < l_size) {l_status=COMM__ERROR; goto g_return;}
-    pl_all = *p_buffer;
-  }
-  /* allocate header buffer */
-  if(*p_head == 0) {
-    ps_his_head = (s_his_head*)malloc(sizeof(s_his_head));
-    *p_head = ps_his_head;
-  } else { ps_his_head = *p_head; }
-
-  l_status = f_stc_read (ps_his_head,sizeof(s_his_head),l_chan,-1);
-  if(l_swap) { l_status = f_swaplw((INTS4*)ps_his_head,16,NULL); }
-
-  *pl_size = l_size;
-  l_buffer = l_size;
-
-  /* break total buffer in TCP buffers */
-  pl_l=pl_all;
-  i_l=l_buffer/16384;
-  l_buffer=l_buffer%16384;
-  for(i_j=0; i_j<i_l; i_j++) {l_status = f_stc_read (pl_l,16384,l_chan,-1); pl_l+=4096;}
-  if(l_buffer > 0) { l_status = f_stc_read (pl_l,l_buffer,l_chan,-1); }
-  if(l_status != STC__SUCCESS) {l_status=COMM__ERROR; goto g_return;}
-
-  if(l_swap) { l_status = f_swaplw((INTS4*)pl_all,l_size/4,NULL); }
-
-  l_status=COMM__SUCCESS;
-g_return:
-  f_stc_discclient (l_chan);
-  f_stc_close (ps_tcpcli);
-  free(ps_tcpcli);
-  return(l_status);
-}
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_server                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_server(int *pl_port, char base, char accesss)*/
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Start histogram server                              */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+  pl_port    : Address to receive port number used.                */
-/*+  base       : Base name                                           */
-/*+  access     : Password                                            */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Creates histogram server.                           */
-/*                Returns port number                                 */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_server(CHARS* pc_base, CHARS* pc_access, INTS4* pl_port)
-{
-  INTS4* pl_l,i_j,i_l,ll,l_buffer,l_status;
-
-  ps_tcpserv  = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-  l_gl_serv_port=PORT__HIST_SERV;
-  strcpy(c_gl_serv_access,pc_access);
-  strcpy(c_gl_serv_base,pc_base);
-  f_his_toupper(c_gl_serv_access,sizeof(c_gl_serv_access));
-  f_his_toupper(c_gl_serv_base,sizeof(c_gl_serv_base));
-
-  while((l_status = f_stc_createserver (&l_gl_serv_port, ps_tcpserv)) != STC__SUCCESS) {
-    l_gl_serv_port++;
-    if(l_gl_serv_port > PORT__HIST_SERV + 20) {
-      printf("Error creating histogram server\n");
-      return(COMM__ERROR);
-    }
-  }
-  *pl_port=l_gl_serv_port;
-  return(0);
-}
-
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_wait                                          */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_wait(int *pl_action, char histogram)        */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Wait for client                                     */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+  pl_action  : Address to receive required action.                 */
-/*+  histogram  : Histogram sepc.                                     */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOACCESS: Password wrong                      */
-/*-               COMM__NOBASE  : Base wrong                          */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Waits for client to connect.                        */
-/*                Returns action required.                            */
-/*                Checks for correct base and password                */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_wait(INTS4* pl_action, CHARS* pc_histo)
-{
-  INTS4* pl_l,i_j,i_l,ll,l_buffer,l_status;
-  /* Wait for client to connect */
-  if(l_gl_serv_verb == 1) {printf("Waiting for client on port %d [%s] \n",l_gl_serv_port,c_gl_serv_access);}
-  l_status = f_stc_acceptclient (ps_tcpserv, &l_gl_serv_chan);
-  if(l_status != STC__SUCCESS) { printf("error accepting client\n"); return(COMM__ERROR);}
-  if(l_gl_serv_verb == 1) {printf("Client connected. \n");}
-  l_status = f_stc_read (&s_his_comm_serv,sizeof(s_his_comm),l_gl_serv_chan,-1);
-  if(l_status != STC__SUCCESS) { printf("error reading client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
-  /* check access */
-  f_his_toupper(s_his_comm_serv.c_access,sizeof(s_his_comm_serv.c_access));
-  f_his_toupper(s_his_comm_serv.c_base,sizeof(s_his_comm_serv.c_base));
-  if((strlen(c_gl_serv_access) != 0) &
-      (strcmp(s_his_comm_serv.c_access,c_gl_serv_access) != 0)) {
-    printf("Client connected with wrong password [%s]. \n",s_his_comm_serv.c_access);
-    s_his_comm_serv.lu_endian=1;
-    s_his_comm_serv.lu_size=0;
-    s_his_comm_serv.lu_histos=0;
-    s_his_comm_serv.l_status=COMM__NOACCESS;
-    l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
-    f_stc_discclient (l_gl_serv_chan);
-    return(COMM__NOACCESS);
-  }
-  /* check base name */
-  if(strcmp(s_his_comm_serv.c_base,c_gl_serv_base) != 0) {
-    printf("Client connected for wrong base [%s]. \n",s_his_comm_serv.c_base);
-    s_his_comm_serv.lu_endian=1;
-    s_his_comm_serv.lu_size=0;
-    s_his_comm_serv.lu_histos=0;
-    s_his_comm_serv.l_status=COMM__NOBASE;
-    l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
-    f_stc_discclient (l_gl_serv_chan);
-    return(COMM__NOBASE);
-  }
-  if(s_his_comm_serv.lu_endian > 100) { l_status = f_swaplw((INTS4*)&s_his_comm_serv,5,NULL); }
-  if(l_gl_serv_verb == 1) {
-    printf("%d: %d %d %d %d %d \"%s\" \"%s\" \"%s\"\n",l_status
-           ,s_his_comm_serv.lu_endian
-           ,s_his_comm_serv.lu_action
-           ,s_his_comm_serv.lu_histos
-           ,s_his_comm_serv.lu_size
-           ,s_his_comm_serv.l_status
-           ,s_his_comm_serv.c_access
-           ,s_his_comm_serv.c_base
-           ,s_his_comm_serv.c_histo);
-  }
-  *pl_action=s_his_comm_serv.lu_action;
-  strcpy(pc_histo,s_his_comm_serv.c_histo);
-  return(COMM__SUCCESS);
-}
-
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_senddir                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_senddir(s_his_head *ps_head, int l_histos)  */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Send list of available histogram                    */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+  ps_head    : Address of header list.                             */
-/*+  l_histos   : Number of histograms                                */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOHIST  : Histogram not there                 */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Send list of s_his_head to client.                  */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_senddir(s_his_head* ps_head, INTS4 l_histos)
-{
-  INTS4* pl_l,i_j,i_l,ll,l_buffer,l_status;
-
-  if(l_gl_serv_verb == 1) {printf("Send directory %s. \n",s_his_comm_serv.c_histo);}
-  s_his_comm_serv.lu_histos=l_histos;
-  s_his_comm_serv.lu_endian=1;
-  s_his_comm_serv.lu_action=COMM__PUTDIR;
-  s_his_comm_serv.lu_size=sizeof(s_his_head)*s_his_comm_serv.lu_histos;
-  s_his_comm_serv.l_status=COMM__SUCCESS;
-  l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
-  if(l_status != STC__SUCCESS)
-    { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR);}
-
-  /* break total buffer in TCP buffers */
-  pl_l=(INTS4*)ps_head;
-  l_buffer = s_his_comm_serv.lu_size;
-  i_l=l_buffer/16384;
-  l_buffer=l_buffer%16384;
-  for(i_j=0; i_j<i_l; i_j++) {l_status = f_stc_write (pl_l,16384,l_gl_serv_chan); pl_l+=4096;}
-  if(l_buffer > 0) { l_status = f_stc_write (pl_l,l_buffer,l_gl_serv_chan); }
-
-  if(l_status != STC__SUCCESS)
-    { printf("error writing directory to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR);}
-  f_stc_discclient (l_gl_serv_chan);
-  return(COMM__SUCCESS);
-}
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_sendhis                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_sendhis(s_his_head *ps_head, int histos, char *histo, int *data)*/
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Send histogram                                      */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+  ps_head    : Address of header list.                             */
-/*+  histos     : Number of histograms                                */
-/*+  histo      : Name of requested histograms                        */
-/*+  data       : Pointer array to histogram data                     */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*-               COMM__NOHIST  : Histogram not there                 */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Send one s_his_head and data to client.             */
-/*                Histogram is searched by name.                      */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_sendhis(s_his_head* ps_head, INTS4 l_histos, CHARS* pc_histo, INTS4* pl_data)
-{
-  s_his_head* ps_his_head;
-  INTS4* pl_l,i_j,i_l,ll,l_buffer,l_status;
-
-  s_his_comm_serv.lu_endian=1;
-  s_his_comm_serv.lu_histos=0;
-  s_his_comm_serv.lu_action=COMM__PUTHIST;
-  ps_his_head = ps_head;
-  for(ll=0; ll<l_histos; ll++) {
-    pl_l = pl_data;
-    if(strcmp(ps_his_head->c_name,pc_histo) == 0) {
-      s_his_comm_serv.lu_histos=1;
-      s_his_comm_serv.l_status=COMM__SUCCESS;
-      s_his_comm_serv.lu_size=sizeof(s_his_head)+ps_his_head->l_bins_1 * ps_his_head->l_bins_2 * 4;
-      l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
-      if(l_status != STC__SUCCESS)
-        { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR);}
-      if(l_gl_serv_verb == 1) {printf("%-32s %8d\n",ps_his_head->c_name,s_his_comm_serv.lu_size-sizeof(s_his_head));}
-      l_status = f_stc_write (ps_his_head,sizeof(s_his_head), l_gl_serv_chan);
-      if(l_status != STC__SUCCESS)
-        { printf("error writing header to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
-
-      /* break total buffer in TCP buffers */
-      l_buffer = s_his_comm_serv.lu_size-sizeof(s_his_head);
-      i_l=l_buffer/16384;
-      l_buffer=l_buffer%16384;
-      for(i_j=0; i_j<i_l; i_j++) {l_status = f_stc_write (pl_l,16384,l_gl_serv_chan); pl_l+=4096;}
-      if(l_buffer > 0) { l_status = f_stc_write (pl_l,l_buffer,l_gl_serv_chan); }
-      if(l_status != STC__SUCCESS)
-        { printf("error writing data to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
-      break;
-    } /* found */
-    ps_his_head++;
-  } /* loop */
-  if(s_his_comm_serv.lu_histos == 0) {
-    if(l_gl_serv_verb == 1) {printf("Histogram %s not found\n",pc_histo);}
-    s_his_comm_serv.l_status=COMM__NOHIST;
-    s_his_comm_serv.lu_size=0;
-    l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
-    if(l_status != STC__SUCCESS)
-      { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
-    f_stc_discclient (l_gl_serv_chan);
-    return(COMM__NOHIST);
-  }
-  f_stc_discclient (l_gl_serv_chan);
-  return(COMM__SUCCESS);
-}
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_his_close                                         */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l=f_his_close()                                     */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Stop server, close sockets                          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+ Return type : int.                                                */
-/*-               COMM__SUCCESS : OK                                  */
-/*-               COMM__ERROR   : Error                               */
-/*                                                                    */
-/*2+DESCRIPTION***+***********+****************************************/
-/*                                                                    */
-/*+ FUNCTION    : Stop server, close sockets .                        */
-/*                                                                    */
-/*2+IMPLEMENTATION************+****************************************/
-/*                                                                    */
-/*+ File name   : f_his_hist.c                                        */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Hans Essel                                          */
-/*+ Created     : 21-May-2000                                         */
-/*+ Updates     : Date        Purpose                                 */
-/*                                                                    */
-/*1- C Main ****************+******************************************/
-INTS4 f_his_close()
-{
-  printf("Exit histogram server\n");
-  f_stc_close (ps_tcpserv);
-  free(ps_tcpserv);
-  return(COMM__SUCCESS);
-}
diff --git a/MbsAPI/f_his_hist.h b/MbsAPI/f_his_hist.h
deleted file mode 100644
index 6c39a1c..0000000
--- a/MbsAPI/f_his_hist.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// $Id: f_his_hist.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_HIS_HIST
-#define F_HIS_HIST
-
-#include "typedefs.h"
-#include "s_his_comm.h"
-#include "s_his_head.h"
-
-/* node, port, base, password, histogram, [header, ] buffer, size */
-INTS4 f_his_getbas(CHARS*, INTS4, CHARS*, CHARS*, INTS4**);
-INTS4 f_his_getdir(CHARS*, INTS4, CHARS*, CHARS*, CHARS*, INTS4**, INTS4*);
-INTS4 f_his_gethis(CHARS*, INTS4, CHARS*, CHARS*, CHARS*, s_his_head**, INTS4**, INTS4*);
-INTS4 f_his_server(CHARS*, CHARS*, INTS4*);
-INTS4 f_his_wait(INTS4*, CHARS*);
-INTS4 f_his_senddir(s_his_head*, INTS4);
-INTS4 f_his_sendhis(s_his_head*, INTS4, CHARS*, INTS4*);
-INTS4 f_his_close();
-
-#endif
diff --git a/MbsAPI/f_his_swpbas.c b/MbsAPI/f_his_swpbas.c
deleted file mode 100644
index d655721..0000000
--- a/MbsAPI/f_his_swpbas.c
+++ /dev/null
@@ -1,122 +0,0 @@
-// $Id: f_his_swpbas.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_his_swpbas                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status = f_his_swpbas(ps_head)                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Swaps whole base (except strings)                   */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+   ps_head  : (s_head *) input                                     */
-/*                 pointer to header structure, address of shared     */
-/*                 segment.                                           */
-/*+ Return type : int                                                 */
-/*                                                                    */
-/*2+Description***+***********+****************************************/
-/*                                                                    */
-/*+ CALLING     : l_status = f_his_swpbas(ps_head)                    */
-/*                                                                    */
-/*+ FUNCTION    :                                                     */
-/*                                                                    */
-/*3+Function******+***********+****************************************/
-/*                                                                    */
-/*                                                                    */
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*+ Utility     : f_his_swpbas                                        */
-/*+ File name   : f_his_swpbas.c                                      */
-/*+ Home direct.: /sbs/prod/src                                       */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 06-Jul-2000                                         */
-/*+ Object libr.:                                                     */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-
-#include "f_his_swpbas.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include "s_spe.h"
-#include "s_pol_cond.h"
-#include "s_win_cond.h"
-#include "f_swaplw.h"
-
-INTS4 f_his_swpbas(s_head* ps_head)
-{
-  INTS4  i;
-  s_spe*  ps_spe;
-  s_win* ps_win;
-  s_pol* ps_pol;
-  INTS4*  *pl;
-
-  /* swap first two LWs to get correct size */
-  pl=(INTS4*)ps_head;
-  f_swaplw(pl,2,NULL);
-  if(ps_head->l_endian != 1) {
-    printf("endian was wrong %x\n",ps_head->l_endian);
-    return(-1);
-  }
-
-  /* swap whole base */
-  pl += 2;
-  f_swaplw(pl,ps_head->l_len-2,NULL);
-
-  /* swap back strings in header */
-  pl=(INTS4*)&ps_head->c_date;
-  f_swaplw(pl,23,NULL);
-
-  /* swap back strings in all slots */
-  ps_spe=(s_spe*)(ps_head+1);
-  pl=(INTS4*)&ps_spe->c_name;
-  for(i=0; i<ps_head->i_slot; i++) {
-    f_swaplw(pl,71,NULL);
-    pl += (sizeof(s_spe)/4);
-  }
-
-  /* swap back strings in all conditions */
-  if(ps_head->l_cond_win > 0) {
-    pl=(INTS4*)ps_head;
-    pl = pl + ps_head->l_cond_win;
-    ps_win = (s_win*)(pl + 1);
-    /*reswap window names */
-    for(i=0; i< * pl; i++) {
-      f_swaplw((INTS4*)ps_win->c_name,28,NULL);
-      ps_win++;
-    }
-  }
-  if(ps_head->l_cond_pol > 0) {
-    pl=(INTS4*)ps_head;
-    pl = pl + ps_head->l_cond_pol;
-    ps_pol = (s_pol*)(pl + 1);
-    /*reswap window names */
-    for(i=0; i < *pl; i++) {
-      f_swaplw((INTS4*)ps_pol->c_name,28,NULL);
-      ps_pol++;
-    }
-  }
-  return(0);
-}
-
diff --git a/MbsAPI/f_his_swpbas.h b/MbsAPI/f_his_swpbas.h
deleted file mode 100644
index c1c2ddd..0000000
--- a/MbsAPI/f_his_swpbas.h
+++ /dev/null
@@ -1,22 +0,0 @@
-// $Id: f_his_swpbas.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_HIS_SWPBAS
-#define F_HIS_SWPBAS
-
-#include "typedefs.h"
-#include "s_head.h"
-
-INTS4 f_his_swpbas(s_head* ps_head);
-
-#endif
diff --git a/MbsAPI/f_his_toupper.c b/MbsAPI/f_his_toupper.c
deleted file mode 100644
index 543bb9a..0000000
--- a/MbsAPI/f_his_toupper.c
+++ /dev/null
@@ -1,72 +0,0 @@
-// $Id: f_his_toupper.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                               */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_his_toupper                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : f_his_toupper(string,i_max)                         */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     :  Convert string to upper case.                      */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+   string    : (char *) input/output                               */
-/*                 pointer to character string                        */
-/*                                                                    */
-/*+   i_max     : int input                                           */
-/*                 maximum number of char to be converted.            */
-/*                                                                    */
-/*+ Return type : void                                                */
-/*                                                                    */
-/*2+Description***+***********+****************************************/
-/*                                                                    */
-/*+ CALLING     : f_his_tolower(string,i_max)                         */
-/*                                                                    */
-/*+ FUNCTION    : Converts string to upper case until '\0' or         */
-/*                the specified maximum number of characters          */
-/*                                                                    */
-/*3+Function******+***********+****************************************/
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*+ Utility     : f_his_toupper                                       */
-/*+ File name   : f_his_toupper.c                                     */
-/*+ Home direct.: /sbs/prod/src                                       */
-/*+ Version     : 1.01                                                */
-/*+ Author      : Ilya Kuznetsov                                      */
-/*+ Created     : 20-Sep-1994                                         */
-/*+ Object libr.: libxxx.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*-               11-Oct-94 : changes/RSM                             */
-/*1- C Procedure *************+****************************************/
-
-#include "f_his_toupper.h"
-
-void f_his_toupper(CHARS* c, INTS4 i)
-/* +++ convert string to uppercase, max i char +++ */
-{
-  INTS4 i_j=0;
-  while (!((c[i_j]=='\0') || (i_j==i))) {
-    c[i_j]=(CHARS)toupper((INTS4)c[i_j]);
-    i_j++;
-  }
-  c[i_j] = '\0';
-}
diff --git a/MbsAPI/f_his_toupper.h b/MbsAPI/f_his_toupper.h
deleted file mode 100644
index 7702279..0000000
--- a/MbsAPI/f_his_toupper.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// $Id: f_his_toupper.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_HIS_TOUPPER
-#define F_HIS_TOUPPER
-
-#include "typedefs.h"
-
-void f_his_toupper(CHARS* c, INTS4 i);
-
-#endif
diff --git a/MbsAPI/f_mbs_status.c b/MbsAPI/f_mbs_status.c
deleted file mode 100644
index 3a799f7..0000000
--- a/MbsAPI/f_mbs_status.c
+++ /dev/null
@@ -1,196 +0,0 @@
-// $Id: f_mbs_status.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include "sbs_def.h"
-#include "sys_def.h"
-#include "ml_def.h"
-#include "portnum_def.h"
-#include "s_daqst.h"
-#include "s_setup.h"
-#include "s_set_ml.h"
-#include "s_set_mo.h"
-#include "f_stccomm.h"
-#include "f_ut_status.h"
-
-long l_gl_tcp_chan;
-
-int l_status,l;
-
-#define VERSION__DAQST  2
-#define VERSION__SETUP  1
-#define VERSION__SET_ML 1
-#define VERSION__SET_MO 1
-
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_mbs_status                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_mbs_status(s_daqst, socket)             */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_daqst from socket.                           */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_daqst    : pointer to s_daqst                                  */
-/*+  socket     : Tcp socket from connect                             */
-/*1- C Procedure *************+****************************************/
-INTS4 f_mbs_status(CHARS* c_node, s_daqst* ps_daqst)
-{
-  struct s_tcpcomm* ps_tcpcomm;
-
-  ps_tcpcomm = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    return(-2);
-  }
-  l_status = f_ut_status_r (ps_daqst, l_gl_tcp_chan);
-  f_stc_discclient (l_gl_tcp_chan);
-  free(ps_tcpcomm);
-  return l_status;
-}
-
-
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_mbs_setup                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_mbs_setup(s_setup, socket)              */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_setup from socket.                           */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_setup    : pointer to s_setup                                  */
-/*+  socket     : Tcp socket from connect                             */
-/*1- C Procedure *************+****************************************/
-INTS4 f_mbs_setup(CHARS* c_node, s_setup* ps_setup)
-{
-  s_daqst* ps_daqst;
-  struct s_tcpcomm* ps_tcpcomm;
-
-  ps_tcpcomm = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    return(-2);
-  }
-  ps_daqst   = (s_daqst*) malloc (sizeof( s_daqst));
-  l_status = f_ut_status_r (ps_daqst, l_gl_tcp_chan);
-  f_stc_discclient (l_gl_tcp_chan);
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    free(ps_daqst);
-    return(-1);
-  }
-  if(ps_daqst->bh_setup_loaded == 0) { l_status=-3; }
-  else { l_status = f_ut_setup_r (ps_setup, l_gl_tcp_chan); }
-  f_stc_discclient (l_gl_tcp_chan);
-  free(ps_daqst);
-  free(ps_tcpcomm);
-  return l_status;
-}
-
-
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_mbs_ml_setup                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_mbs_ml_setup(s_set_ml, socket)            */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_set_ml from socket.                          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_ml   : pointer to s_set_ml                                 */
-/*+  socket     : Tcp socket from connect                             */
-/*1- C Procedure *************+****************************************/
-INTS4 f_mbs_ml_setup(CHARS* c_node, s_set_ml* ps_set_ml)
-{
-  s_daqst* ps_daqst;
-  struct s_tcpcomm* ps_tcpcomm;
-
-  ps_tcpcomm = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    return(-2);
-  }
-  ps_daqst   = (s_daqst*) malloc (sizeof( s_daqst));
-  l_status = f_ut_status_r (ps_daqst, l_gl_tcp_chan);
-  f_stc_discclient (l_gl_tcp_chan);
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    free(ps_daqst);
-    return(-1);
-  }
-  if(ps_daqst->bh_set_ml_loaded == 0) { l_status=-3; }
-  else { l_status = f_ut_set_ml_r (ps_set_ml, l_gl_tcp_chan); }
-  f_stc_discclient (l_gl_tcp_chan);
-  free(ps_tcpcomm);
-  free(ps_daqst);
-  return l_status;
-}
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_mbs_mo_setup                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_mbs_mo_setup(s_set_mo, socket)            */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_set_mo from socket.                          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_mo   : pointer to s_set_mo                                 */
-/*+  socket     : Tcp socket from connect                             */
-/*1- C Procedure *************+****************************************/
-INTS4 f_mbs_mo_setup(CHARS* c_node, s_set_mo* ps_set_mo)
-{
-  s_daqst* ps_daqst;
-  struct s_tcpcomm* ps_tcpcomm;
-
-  ps_tcpcomm = (struct s_tcpcomm*) malloc (sizeof( struct s_tcpcomm));
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    return(-2);
-  }
-  ps_daqst   = (s_daqst*) malloc (sizeof( s_daqst));
-  l_status = f_ut_status_r (ps_daqst, l_gl_tcp_chan);
-  f_stc_discclient (l_gl_tcp_chan);
-  l_status = f_stc_connectserver (c_node,PORT__STAT_SERV,&l_gl_tcp_chan,ps_tcpcomm);
-  if (l_status != STC__SUCCESS) {
-    free(ps_tcpcomm);
-    free(ps_daqst);
-    return(-1);
-  }
-  if(ps_daqst->bh_set_mo_loaded == 0) { l_status=-3; }
-  else { l_status = f_ut_set_mo_r (ps_set_mo, l_gl_tcp_chan); }
-  f_stc_discclient (l_gl_tcp_chan);
-  free(ps_tcpcomm);
-  free(ps_daqst);
-  return l_status;
-}
diff --git a/MbsAPI/f_radware.c b/MbsAPI/f_radware.c
deleted file mode 100644
index f47b558..0000000
--- a/MbsAPI/f_radware.c
+++ /dev/null
@@ -1,114 +0,0 @@
-// $Id: f_radware.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include "f_radware.h"
-#include "typedefs.h"
-
-#ifdef GSI__WINNT
-#include <errno.h>
-#else
-#include <errno.h>
-#include <unistd.h>
-#endif
-
-#define HIS__BASPERM   0774
-//*************************************************************
-int f_radware_out1d(char* pc_file, char* pc_name, float* pr_data, int l_chan, int l_over)
-{
-  char c_retmsg[128];
-  int  i32_fd, i32_bytes, i32_hislen;
-  int  l_status,ll,l_head[6],l_bytes;
-  char* pc,c_str[128];
-
-  if(l_over) { // delete old file
-    strcpy(c_str,"rm ");
-    strcat(c_str,pc_file);
-    system(c_str);
-  }
-  i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
-  if (i32_fd < 0) {
-    printf("Error %d opening file %s, already exists?\n",errno, pc_file);
-    return(1);
-  }
-//write file
-  strcpy(c_str,pc_name);
-  strcat(c_str,"        ");
-  l_head[0]=24;
-  l_head[1]=1;
-  l_head[2]=1;
-  l_head[3]=1;
-  l_head[4]=24;
-  l_head[5]=l_chan*4; /* record size */
-
-  i32_bytes   = write(i32_fd, (char*) l_head, 4);
-  i32_bytes  += write(i32_fd, c_str, 8);
-  l_head[0]   = l_chan;
-  i32_bytes  += write(i32_fd, (char*) l_head, 24);  /* includes record size */
-
-  i32_bytes  += write(i32_fd, (char*) pr_data, l_chan*4);
-  l_head[0]   = l_chan*4;
-  i32_bytes  += write(i32_fd, (char*) l_head, 4);
-
-  i32_hislen = l_chan*4 + 40;
-  if (i32_bytes == i32_hislen) {
-    //  printf("Histogram %32s: %d bytes (data %d) written to %s\n",
-    //     pc_name,i32_bytes,l_chan*4,pc_file);
-  } else {
-    printf("Error %d. Dumping histogram:%s, %d bytes written to %s\n",
-           errno,pc_name,i32_bytes,pc_file);
-  }
-  l_status = close(i32_fd);
-  if (l_status != 0) {
-    printf("Error %d. Close %s failed!\n",errno,pc_file);
-    return(1);
-  }
-  return(0);
-}
-//*************************************************************
-int f_radware_out2d(char* pc_file, char* pc_name, int* pl_data, int l_chan, int l_over)
-{
-  int   i32_fd, i32_bytes, i32_hislen;
-  int   l_status,ll,l_head[6],l_bytes;
-  char*  pc,c_str[128];
-
-  if(l_over) {
-    strcpy(c_str,"rm ");
-    strcat(c_str,pc_file);
-    system(c_str);
-  }
-  i32_fd = open(pc_file, O_WRONLY | O_CREAT | O_EXCL, HIS__BASPERM);
-  if (i32_fd < 0) {
-    printf("Error %d opening file %s, already exists?\n",errno, pc_file);
-    return(1);
-  }
-  i32_bytes  = write(i32_fd, (char*) pl_data, l_chan*4);
-  if (i32_bytes == l_chan*4) {
-    //  printf("Histogram %32s: %d bytes written to %s\n",
-    //     pc_name,i32_bytes,pc_file);
-  } else {
-    printf("Error %d. Dumping histogram:%s, only %d bytes written to %s\n",
-           errno,pc_name,i32_bytes,pc_file);
-  }
-  l_status = close(i32_fd);
-  if (l_status != 0) {
-    printf("Error %d. Close %s failed!\n",errno,pc_file);
-    return(1);
-  }
-  return(0);
-}
diff --git a/MbsAPI/f_radware.h b/MbsAPI/f_radware.h
deleted file mode 100644
index bcd2482..0000000
--- a/MbsAPI/f_radware.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// $Id: f_radware.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_RADWARE
-#define F_RADWARE
-
-// Output functions for Radware
-
-int f_radware_out1d(char* file, char* histogram, float* data, int channels, int over);
-int f_radware_out2d(char* file, char* histogram, int*   data, int channels, int over);
-
-// file     : output file name
-// histogram: name of histogram
-// data     : pointer to data (float for 1d, int for 2d)
-// channels : # of channels
-// over     : flag, if = 1, delete file first
-
-#endif
diff --git a/MbsAPI/f_stccomm.c b/MbsAPI/f_stccomm.c
index a48def8..68a5bbe 100644
--- a/MbsAPI/f_stccomm.c
+++ b/MbsAPI/f_stccomm.c
@@ -1,16 +1,10 @@
-// $Id: f_stccomm.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "f_stccomm.h"
 
 CHARS c_msg[80];
@@ -497,10 +491,10 @@ struct s_tcpcomm* ps_client;
 {
 
 
-  INTS4 shut , retval ;
-  INTS4 thirty = 30;
+  INTS4 /*shut,*/ retval ;
+//  INTS4 thirty = 30;
   struct s_tcpcomm s_client;
-
+  memset(&s_client, 0, sizeof(s_client));
 
   /* ----------------------------------------------------------------------- */
   /*           init communication socket.              */
@@ -704,8 +698,8 @@ INTS4 f_stc_acceptclient( ps_server , pi_channel)
 struct s_tcpcomm* ps_server;
 INTS4* pi_channel;
 {
-  INTS4 i_socket;
-  struct hostent*  he;
+//  INTS4 i_socket;
+//  struct hostent*  he;
 
 #ifdef GSI__AIX
   *pi_channel = accept( ps_server->sock_rw,
@@ -714,7 +708,7 @@ INTS4* pi_channel;
 #else
   *pi_channel = accept( ps_server->sock_rw,
                         ( struct sockaddr*) &ps_server->sock_name,
-                        &ps_server->namelength);
+                        (uint*)&ps_server->namelength);
 #endif
   if( *pi_channel == -1) {
     switch( errno ) {
@@ -871,9 +865,10 @@ struct s_tcpcomm* ps_server;
 
 {
 
-  INTS4 retval , i , retry , on ;
-  struct protoent* p;
+  INTS4 retval, /*i,*/ retry, on ;
+//  struct protoent* p;
   struct s_tcpcomm s_server;
+  memset(&s_server, 0, sizeof(s_server));
 
 
 #ifdef GSI__WINNT
diff --git a/MbsAPI/f_stccomm.h b/MbsAPI/f_stccomm.h
index 790e678..27366c1 100644
--- a/MbsAPI/f_stccomm.h
+++ b/MbsAPI/f_stccomm.h
@@ -1,21 +1,10 @@
-// $Id: f_stccomm.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*************************************************************************/
-/* F_STCCOMM.H                                                           */
-/* 18.7.95, H.G.: add message no. STC__ECONNREF                          */
-/*************************************************************************/
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef F_STCCOMM
 #define F_STCCOMM
 
diff --git a/MbsAPI/f_swaplw.c b/MbsAPI/f_swaplw.c
deleted file mode 100644
index 9769c20..0000000
--- a/MbsAPI/f_swaplw.c
+++ /dev/null
@@ -1,108 +0,0 @@
-// $Id: f_swaplw.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#define DEBUG 0
-/*2+F_SWAPLW****+******************************************************/
-/*                                                                    */
-/*+ Module      : F_SWAPLW                                            */
-/*                                                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : sts = f_swaplw(pp_source,                           */
-/*                               l_len,                               */
-/*                               pp_dest)                             */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Long word byte swap.                                */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+    pp_source   : Pointer to source.                               */
-/*+    l_dest      : length (in long words)                           */
-/*+    pp_dest     : Pointer to destination or 0 if                   */
-/*                   destination = source.                            */
-/*                                                                    */
-/*+ FUNCTION    : Long word byte swap. Works on the source field if   */
-/*                pp_dest points to value 0 or swaps from the source  */
-/*                to the destination field.                           */
-/*                (Should be replaced by a fast assembler routine)    */
-/*                                                                    */
-/*+ Return type : int (see s_errnum_def.h)                            */
-/*+ Status codes: bit 0: success                                      */
-/*                                                                    */
-/*+ Initialize  : -                                                   */
-/*+ Include name: -                                                   */
-/*                                                                    */
-/*3+Implementation************+****************************************/
-/*                                                                    */
-/*+ File name   : PC_PROC.C                                           */
-/*+ Version     : 1.01                                                */
-/*+ Author      : R.S. Mayer                                          */
-/*+ Last Update : 27-Apr-1994                                         */
-/*+ Object libr.: ?                                                   */
-/*3+Updates*******+***********+****************************************/
-/*                                                                    */
-/*+ Updates     : Date          Purpose                               */
-/*                                                                    */
-/*3+Description***+***********+****************************************/
-/*1- C Procedure ***********+******************************************/
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-
-/* function prototypes */
-
-/* defines */
-
-int f_swaplw(int* pp_source, int l_len, int* pp_dest)
-
-{
-  unsigned char*     p_source, *p_dest, *p_s, *p_d;
-  unsigned int      lu_save;
-
-  /* +++ action +++ */
-  p_source = (unsigned char*) pp_source;
-  p_dest   = (unsigned char*) pp_dest;
-
-  if (p_dest == NULL) {
-    /* source == destination          */
-    for (p_d = (unsigned char*) p_source,
-         p_s = (unsigned char*) &lu_save;
-         p_d < p_source + (l_len * 4);
-        ) {
-      lu_save = *( (int*) p_d);
-      p_s    += 4;                 /* increment source               */
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-    }
-  } else {
-    for (p_s = (unsigned char*) p_source,
-         p_d = (unsigned char*) p_dest;
-         p_s < p_source + (l_len * 4);
-         p_s += 4) {
-      p_s     += 4;                /* increment source               */
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-      *(p_d++) = *(--p_s);
-    }
-
-  }  /* dest == 0 */
-
-  return(0);
-}
-
diff --git a/MbsAPI/f_swaplw.h b/MbsAPI/f_swaplw.h
deleted file mode 100644
index 75e534f..0000000
--- a/MbsAPI/f_swaplw.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// $Id: f_swaplw.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef F_SWAPLW
-#define F_SWAPLW
-
-#include "typedefs.h"
-INTS4 f_swaplw(INTS4* pp_source, INTS4 l_len, INTS4* pp_dest);
-
-#endif
diff --git a/MbsAPI/f_ut_compress.c b/MbsAPI/f_ut_compress.c
deleted file mode 100644
index ed6aaa3..0000000
--- a/MbsAPI/f_ut_compress.c
+++ /dev/null
@@ -1,421 +0,0 @@
-// $Id: f_ut_compress.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* type definitions */
-#include "typedefs.h"
-#include "f_ut_compress.h"
-#include <stdio.h>
-
-#define PACK(bit)   if(*pc_in != 0){*pl_mask += bit ; *pc_out++ = *pc_in; }  pc_in++;
-
-#ifdef GSI__LINUX
-#define UNPACK(bit) if(l_mask & bit ) *pc_out++ = *pc_in++; else *pc_out++ = 0;
-#endif
-#ifdef GSI__NT
-#define UNPACK(bit) if(l_mask & bit ) *pc_out++ = *pc_in++; else *pc_out++ = 0;
-#endif
-#ifdef GSI__WINNT
-#define UNPACK(bit) if(l_mask & bit ) *pc_out++ = *pc_in++; else *pc_out++ = 0;
-#endif
-#ifdef GSI__VMS
-#define UNPACK(bit) if(l_mask & bit ) *pc_out = *pc_in++; pc_out++;
-#endif
-#ifdef GSI__AIX
-#define UNPACK(bit) if(l_mask & bit ) *pc_out = *pc_in++; pc_out++;
-#endif
-#ifdef GSI__SOLARIS
-#define UNPACK(bit) if(l_mask & bit ) *pc_out = *pc_in++; pc_out++;
-#endif
-#ifdef GSI__LYNX
-#define UNPACK(bit) if(l_mask & bit ) *pc_out = *pc_in++; pc_out++;
-#endif
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 41                                                */
-/*   D-6100 Darmstadt 11                                              */
-/*                                                                    */
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_ut_compr_size                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : size=f_ut_compr_size(*input,inlen)                  */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : return size of compressed data field.               */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+    input    : (INTU1 *) Pointer to data field.                    */
-/*+    inlen    : (INTS4) Length of input data field [bytes].         */
-/*                                                                    */
-/*+ Return type : INTS4                                               */
-/*+    return   : Number of bytes of compressed output                */
-/*+ Include name: f_ut_compress.h                                     */
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*                                                                    */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Last Update : 13-Jul-2000                                         */
-/*                                                                    */
-/*2+Internals*****+***********+****************************************/
-/*                                                                    */
-/*+ Utility     : UTIL                                                */
-/*+ Created     : 07-Jul-2000                                         */
-/*                                                                    */
-/*1- C Procedure ***********+******************************************/
-INTS4 f_ut_compr_size(INTU1* pc_input,INTS4 l_inlen)
-{
- // INTU4 I,J,K,L,M,N;
-  INTU4 l_bytes;
-  INTU4 l_masks;
-  INTU4* pl_mask,*pl_end;
-  INTU1* *pc_in;
-//  s_compress*  ps_compress;
-
-  pc_in =pc_input;
-  l_bytes=0;
-  pl_mask=(INTU4*)pc_input;
-  pl_end=pl_mask+l_inlen/4;
-  while(pl_mask!=pl_end) {
-    if(*pl_mask&0x000000ff) { l_bytes++; }
-    if(*pl_mask&0x0000ff00) { l_bytes++; }
-    if(*pl_mask&0x00ff0000) { l_bytes++; }
-    if(*pl_mask&0xff000000) { l_bytes++; }
-    pl_mask++;
-  }
-  if(l_bytes%4 != 0) { l_bytes=l_bytes+4-l_bytes%4; }
-  l_masks=(l_inlen >> 5);
-  if(l_inlen%32 != 0) { l_masks++; }
-  return(l_bytes+4*l_masks+sizeof(s_compress));
-}
-
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_ut_compr_zeros                                    */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : zeros=f_ut_compr_zeros(*input,inlen)                */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : return % zero bytes.                                */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+    input    : (INTU1 *) Pointer to data field.                    */
-/*+    inlen    : (INTS4) Length of input data field [bytes].         */
-/*                                                                    */
-/*+ Return type : INTS4                                               */
-/*+    return   : % of zero bytes                                     */
-/*+ Include name: f_ut_compress.h                                     */
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*                                                                    */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Last Update : 13-Jul-2000                                         */
-/*                                                                    */
-/*2+Internals*****+***********+****************************************/
-/*                                                                    */
-/*+ Utility     : UTIL                                                */
-/*+ Created     : 07-Jul-2000                                         */
-/*                                                                    */
-/*1- C Procedure ***********+******************************************/
-INTS4 f_ut_compr_zeros(INTU1* pc_input,INTS4 l_inlen)
-{
-  INTU4 I;
-  INTU4 l_bytes;
-  INTU1* *pc_in;
-
-  pc_in =pc_input;
-  l_bytes=0;
-  for(I=1; I<=l_inlen; I++) if(*pc_in++ == 0) { l_bytes++; }
-  return (l_bytes*100/l_inlen);
-}
-
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_ut_compr_pack                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : size=f_ut_compr_pack(*input,inlen,*output,outlen)   */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Compress data field by removing zero bytes          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+    input    : (INTU1 *) Pointer to input data field.              */
-/*+    inlen    : (INTS4) Length of input data field in bytes.        */
-/*+    output   : (INTU1 *) Pointer to compressed output data field.  */
-/*+    outlen   : (INTS4) Length of output data field.                */
-/*                                                                    */
-/*+ Return type : INTS4                                               */
-/*+    return   : Number of bytes of compressed output                */
-/*+    return   : -1: output buffer may be too small                  */
-/*+ Include name: f_ut_compress.h                                     */
-/*                                                                    */
-/*2+Description***+***********+****************************************/
-/*                                                                    */
-/*+ CALLING     : size=f_ut_compr_pack(*input,inlen,*output,outlen)   */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+    input    : (INTU1 *) Pointer to input data field. The field    */
-/*                must be longword aligned.                           */
-/*+    inlen    : (INTS4) Length of input data field in bytes.        */
-/*+    output   : (INTU1 *) Pointer to output data field.             */
-/*                The output field must be 12.5% bigger than input.   */
-/*+    outlen   : (INTS4) Length of output data field in bytes.       */
-/*                                                                    */
-/*+ FUNCTION    : The output field begins with structure s_compress:  */
-/*                                                                    */
-/*-               INTU4 l_endian:     set to 1 by creator             */
-/*-               INTU4 l_length:     total size [b] of compr. buffer */
-/*-               INTU4 l_masks:      # of masks following this header */
-/*-               INTU4 l_full_bytes: # of bytes of uncompressed buffer */
-/*-               INTU4 l_comp_bytes: # of non zero bytes             */
-/*-               INTU4 l_pattern:    COMPR__PATTERN                  */
-/*+ :                                                                  */
-/*                Then there follow inbytes/32 pattern longwords.     */
-/*                Then follow all non zero bytes.                     */
-/*                Zero bytes are suppressed. The overhead is about    */
-/*                13% of input, i.e. if no zeros are found, output is */
-/*                13% bigger than input. In the patterns, bits are    */
-/*                set for following nonzero bytes, not set for        */
-/*                suppressed zero bytes.                              */
-/*+  endian     : When receiving a compressed buffer one must check   */
-/*                the endian. If it is not 1, one must swap           */
-/*                s_compress and then s_sompress.l_masks longwords.   */
-/*                Then the buffer can be uncompressed. The            */
-/*                uncompressed buffer must be checked again for right */
-/*                endian, and eventually swapped.                     */
-/*                                                                    */
-/*+ EXAMPLE     : l=f_ut_compr_pack(pl_data,1024,pl_comp,2000);       */
-/*                l=f_ut_compr_unpack(pl_comp,pl_data,1024);          */
-/*                pl_data should be the same now.                     */
-/*                                                                    */
-/*+ NOTE        : Output data field must be 13% bigger than input.    */
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*                                                                    */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Last Update : 13-Jul-2000                                         */
-/*                                                                    */
-/*2+Internals*****+***********+****************************************/
-/*                                                                    */
-/*+ Utility     : UTIL                                                */
-/*+ Created     : 07-Jul-2000                                         */
-/*                                                                    */
-/*1- C Procedure ***********+******************************************/
-INTS4 f_ut_compr_pack(INTU1* pc_input,INTS4 l_inlen,INTU1* pc_output,INTS4 l_outlen)
-{
-  INTU4 I,J,K,M,N;
-  INTU4 l_bytes;
-  INTU4 l_mask,l_masks;
-  INTU4* pl_mask;
-  INTU1* pc_out,*pc_in,*pc_1;
-  s_compress*  ps_compress;
-
-  /* how many masks do we need: one for 32 bytes */
-  l_masks=(l_inlen >> 5);
-  if(l_inlen%32 != 0) { l_masks++; }
-  /* on output we need the header, the masks, and maybe all bytes */
-  if(l_outlen < 4*l_masks+sizeof(s_compress)+l_inlen) { return -1; }
-  pc_out=pc_output;
-  pc_in =pc_input;
-  ps_compress=(s_compress*)pc_out;    /* header */
-  pl_mask=(INTU4*)(ps_compress+1);    /* first mask behind header */
-  pc_out = (INTU1*)(pl_mask+l_masks); /* first data byte behind all masks */
-  pc_1=pc_out;
-  *pl_mask=0;
-  l_mask=1;
-  l_bytes=0;
-  /* loop over all masks -1 */
-  for(I=1; I<l_masks; I++) {
-    PACK(0x00000001);
-    PACK(0x00000002);
-    PACK(0x00000004);
-    PACK(0x00000008);
-    PACK(0x00000010);
-    PACK(0x00000020);
-    PACK(0x00000040);
-    PACK(0x00000080);
-    PACK(0x00000100);
-    PACK(0x00000200);
-    PACK(0x00000400);
-    PACK(0x00000800);
-    PACK(0x00001000);
-    PACK(0x00002000);
-    PACK(0x00004000);
-    PACK(0x00008000);
-    PACK(0x00010000);
-    PACK(0x00020000);
-    PACK(0x00040000);
-    PACK(0x00080000);
-    PACK(0x00100000);
-    PACK(0x00200000);
-    PACK(0x00400000);
-    PACK(0x00800000);
-    PACK(0x01000000);
-    PACK(0x02000000);
-    PACK(0x04000000);
-    PACK(0x08000000);
-    PACK(0x10000000);
-    PACK(0x20000000);
-    PACK(0x40000000);
-    PACK(0x80000000);
-    pl_mask++;
-    *pl_mask=0;
-  }
-  l_bytes=pc_out-pc_1 ;
-  /* last mask could be less than 32 bytes */
-  l_mask=1;
-  for(I=0; I<(l_inlen-l_masks*32+32); I++) {
-    if(*pc_in != 0) {*pl_mask += l_mask; *pc_out++ = *pc_in; l_bytes++; }
-    l_mask = l_mask << 1;
-    pc_in++;
-  }
-  /* add the number of last fragment bytes */
-  ps_compress->l_endian     = 1;
-  ps_compress->l_length     = l_bytes+4*l_masks+sizeof(s_compress);
-  ps_compress->l_pattern    = COMPR__PATTERN;
-  ps_compress->l_masks      = l_masks;
-  ps_compress->l_full_bytes = l_inlen;
-  ps_compress->l_comp_bytes = l_bytes; /* without header and masks */
-
-  return (l_bytes+4*l_masks+sizeof(s_compress));
-}
-
-/*1+ C Procedure ***********+******************************************/
-/*                                                                    */
-/*+ Module      : f_ut_compr_unpack                                   */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : size=f_ut_compr_unpack(*input,*output,outlen)       */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Deompress data field.                               */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*                                                                    */
-/*+    input    : (INTU1 *) Pointer to compressed data field.         */
-/*+    output   : (INTU1 *) Pointer to uncompressed output data field.*/
-/*+    outlen   : (INTS4) Length of output data field.                */
-/*                                                                    */
-/*+ Return type : INTS4                                               */
-/*+    return   : 0 : OK                                              */
-/*+    return   : -1: output buffer may be too small                  */
-/*+ Include name: f_ut_compress.h                                     */
-/*                                                                    */
-/*2+Description***************+****************************************/
-/*                Receiving a compressed buffer which could have      */
-/*                a different endian, proceed as follows:             */
-/*                Receive sizeof(s_compress) bytes and check          */
-/*                s_compress.l_endian. If not 1 swap s_compress.      */
-/*                Get s_compress.l_length-sizeof(s_compress) bytes.   */
-/*                Swap next s_compress.l_masks longwords.             */
-/*                Call f_ut_compr_unpack to compress the buffer.      */
-/*                The uncompressed buffer must be checked for correct */
-/*                endian again. The method is up to the sender.       */
-/*                                                                    */
-/*2+Implementation************+****************************************/
-/*                                                                    */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Last Update : 13-Jul-2000                                         */
-/*                                                                    */
-/*2+Internals*****+***********+****************************************/
-/*                                                                    */
-/*+ Utility     : UTIL                                                */
-/*+ Created     : 07-Jul-2000                                         */
-/*                                                                    */
-/*1- C Procedure ***********+******************************************/
-INTS4 f_ut_compr_unpack(INTU1* pc_input,INTU1* pc_output,INTS4 l_outlen)
-{
-  INTU4 I,J,K,L,M,N;
-  INTU4 l_mask;
-  INTU4* pl_mask,*pl_tmp,*pl_out;
-  INTU1* pc_out,*pc_in;
-  s_compress*  ps_compress;
-
-  ps_compress=(s_compress*)pc_input;
-  /* is output buffer big enough?  */
-  if(ps_compress->l_full_bytes > l_outlen) { return -1; }
-
-#ifdef GSI__VMS
-  pl_out=(INTU4*) pc_output;
-  pl_tmp=pl_out+(ps_compress->l_full_bytes>>2);
-  while(pl_out != pl_tmp) { *pl_out++ = 0; }
-#endif
-#ifdef GSI__LYNX
-  pl_out=(INTU4*) pc_output;
-  pl_tmp=pl_out+(ps_compress->l_full_bytes>>2);
-  while(pl_out != pl_tmp) { *pl_out++ = 0; }
-#endif
-#ifdef GSI__AIX
-  memset(pc_output,0,ps_compress->l_full_bytes);
-#endif
-
-  pl_mask=(INTU4*)(ps_compress+1);
-  pc_in = (INTU1*)(pl_mask+ps_compress->l_masks);
-  pc_out=pc_output;
-  /* all masks -1 */
-  for(L=1; L<ps_compress->l_masks; L++) {
-    l_mask=*pl_mask;
-    UNPACK(0x00000001);
-    UNPACK(0x00000002);
-    UNPACK(0x00000004);
-    UNPACK(0x00000008);
-    UNPACK(0x00000010);
-    UNPACK(0x00000020);
-    UNPACK(0x00000040);
-    UNPACK(0x00000080);
-    UNPACK(0x00000100);
-    UNPACK(0x00000200);
-    UNPACK(0x00000400);
-    UNPACK(0x00000800);
-    UNPACK(0x00001000);
-    UNPACK(0x00002000);
-    UNPACK(0x00004000);
-    UNPACK(0x00008000);
-    UNPACK(0x00010000);
-    UNPACK(0x00020000);
-    UNPACK(0x00040000);
-    UNPACK(0x00080000);
-    UNPACK(0x00100000);
-    UNPACK(0x00200000);
-    UNPACK(0x00400000);
-    UNPACK(0x00800000);
-    UNPACK(0x01000000);
-    UNPACK(0x02000000);
-    UNPACK(0x04000000);
-    UNPACK(0x08000000);
-    UNPACK(0x10000000);
-    UNPACK(0x20000000);
-    UNPACK(0x40000000);
-    UNPACK(0x80000000);
-    pl_mask++;
-  }
-  l_mask=*pl_mask;
-  /* restore bytes of last mask (could be less than 32) */
-  for(L=0; L<ps_compress->l_full_bytes-ps_compress->l_masks*32+32; L++) {
-    if(l_mask%2 != 0) { *pc_out++ = *pc_in++; }
-    else { *pc_out++=0; }
-    l_mask = l_mask >> 1;
-  }
-  return 0;
-}
diff --git a/MbsAPI/f_ut_compress.h b/MbsAPI/f_ut_compress.h
deleted file mode 100644
index 5b62246..0000000
--- a/MbsAPI/f_ut_compress.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// $Id: f_ut_compress.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#define COMPR__PATTERN 0x0f0f0f0f
-typedef struct {
-  INTU4 l_endian;     /* set to 1 by creator */
-  INTU4 l_length;     /* total size [bytes] of compressed buffer */
-  INTU4 l_masks;      /* number of masks following this header */
-  INTU4 l_full_bytes; /* number of bytes needed for uncompressed buffer */
-  INTU4 l_comp_bytes; /* number of non zero bytes */
-  INTU4 l_pattern;    /* COMPR__PATTERN */
-} s_compress;
-INTS4 f_ut_compr_size(INTU1*, INTS4);
-INTS4 f_ut_compr_zeros(INTU1*, INTS4);
-INTS4 f_ut_compr_pack(INTU1*, INTS4, INTU1*, INTS4);
-INTS4 f_ut_compr_unpack(INTU1*, INTU1*, INTS4);
diff --git a/MbsAPI/f_ut_seg_show.c b/MbsAPI/f_ut_seg_show.c
deleted file mode 100644
index b53b2bf..0000000
--- a/MbsAPI/f_ut_seg_show.c
+++ /dev/null
@@ -1,411 +0,0 @@
-// $Id: f_ut_seg_show.c 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-// print of daq status, setup, and multi layer setup
-
-#include "typedefs.h"
-#include <stdio.h>
-#include <string.h>
-#include <stddef.h>
-
-#include "sys_def.h"
-#include "sbs_def.h"
-#include "ml_def.h"
-#include "s_setup.h"
-#include "s_set_ml.h"
-#include "s_set_mo.h"
-#include "s_daqst.h"
-#include "err_mask_def.h"
-#include "errnum_def.h"
-
-#ifdef Linux
-#define LOUT printf("%s\n",c_line);
-#endif
-#ifdef Solaris
-#define LOUT printf("%s\n",c_line);
-#endif
-#ifdef Darwin
-#define LOUT printf("%s\n",c_line);
-#endif
-
-#ifdef WIN32
-#define LOUT printf("%s\n",c_line);
-#endif
-#ifdef Lynx
-#include "f_ut_error.h"
-#define LOUT f_ut_error("",ERR__MSG_INFO,0,c_line,MASK__PRTTERM);
-#endif
-
-CHARS* f_ut_time(CHARS*);
-
-INTS4 f_ut_seg_show (s_daqst* ps_daqst, s_setup* ps_setup, s_set_ml* ps_set_ml, s_set_mo* ps_set_mo)
-{
-  INTS4 i,j;
-  CHARS c_time[32];
-  CHARS c_line[128];
-  CHARS* ps_master[16]= {"CVC","E6","E7","AEB","CBV","CVI","CAV","RIO2","PC","RIO3","V32C32","RIO4","nn","nn","nn","nn"};
-
-  sprintf(c_line,"%s",f_ut_time(c_time));
-  LOUT;
-  if(ps_daqst != NULL) {
-    sprintf(c_line,"S_daqst *********************************************************************");
-    LOUT;
-    sprintf(c_line," l_version   __________%5d l_endian   ___________%5d",
-            ps_daqst->l_version,          ps_daqst->l_endian);
-    LOUT;
-    sprintf(c_line," l_daqst_lw   _________%5d l_fix_lw   ___________%5d",
-            ps_daqst->l_daqst_lw,         ps_daqst->l_fix_lw);
-    LOUT;
-    sprintf(c_line," l_sys__n_max_procs   _%5d l_sbs__str_len_64   __%5d",
-            ps_daqst->l_sys__n_max_procs, ps_daqst->l_sbs__str_len_64);
-    LOUT;
-    sprintf(c_line," l_sbs__n_trg_typ   ___%5d bh_verbose_flg   _____%5d",
-            ps_daqst->l_sbs__n_trg_typ,   ps_daqst->bh_verbose_flg);
-    LOUT;
-    sprintf(c_line," bl_n_events   ___%10d bl_r_events   ________%5d",
-            ps_daqst->bl_n_events,        ps_daqst->bl_r_events);
-    LOUT;
-    sprintf(c_line," bl_n_buffers   ___%9d bl_r_buffers   _______%5d",
-            ps_daqst->bl_n_buffers,       ps_daqst->bl_r_buffers);
-    LOUT;
-    sprintf(c_line," bl_n_bufstream   _%9d bl_r_bufstream   _____%5d",
-            ps_daqst->bl_n_bufstream,     ps_daqst->bl_r_bufstream);
-    LOUT;
-    sprintf(c_line," bl_n_kbyte   ____%10d bl_r_kbyte   _________%5d",
-            ps_daqst->bl_n_kbyte,         ps_daqst->bl_r_kbyte);
-    LOUT;
-    sprintf(c_line," bl_n_evserv_events %8d bl_r_evserv_events    %5d",
-            ps_daqst->bl_n_evserv_events, ps_daqst->bl_r_evserv_events);
-    LOUT;
-    sprintf(c_line," bl_n_evserv_kbytes %8d bl_r_evserv_kbytes   _%5d",
-            ps_daqst->bl_n_evserv_kbytes, ps_daqst->bl_r_evserv_kbytes);
-    LOUT;
-    sprintf(c_line," bl_n_strserv_bufs %9d bl_r_strserv_bufs   __%5d",
-            ps_daqst->bl_n_strserv_bufs,  ps_daqst->bl_r_strserv_bufs);
-    LOUT;
-    sprintf(c_line," bl_n_strserv_kbytes %7d bl_r_strserv_kbytes   %5d",
-            ps_daqst->bl_n_strserv_kbytes,ps_daqst->bl_r_strserv_kbytes);
-    LOUT;
-    sprintf(c_line," bl_n_kbyte_tape  %10d bl_r_kbyte_tape   ____%5d",
-            ps_daqst->bl_n_kbyte_tape,    ps_daqst->bl_r_kbyte_tape);
-    LOUT;
-    sprintf(c_line," bl_n_kbyte_file   %9d l_free_streams________%5d",
-            ps_daqst->bl_n_kbyte_file,    ps_daqst->l_free_streams);
-    LOUT;
-    sprintf(c_line," l_block_length   _____%5d l_record_size   ______%5d",
-            ps_daqst->l_block_length,     ps_daqst->l_record_size);
-    LOUT;
-    sprintf(c_line," l_block_size   _______%5d bl_flush_time   ______%5d",
-            ps_daqst->l_block_size,       ps_daqst->bl_flush_time);
-    LOUT;
-    sprintf(c_line," l_open_vol   _________%5d l_open_file   ________%5d",
-            ps_daqst->l_open_vol,         ps_daqst->l_open_file);
-    LOUT;
-    sprintf(c_line," l_max_tape_size   __%7d l_pos_on_tape   ____%7d",
-            ps_daqst->l_max_tape_size,    ps_daqst->l_pos_on_tape);
-    LOUT;
-    sprintf(c_line," l_file_auto   ________%5d l_file_cur   _________%5d",
-            ps_daqst->l_file_auto-1,        ps_daqst->l_file_cur-1);
-    LOUT;
-    sprintf(c_line," l_file_count   _______%5d l_pathnum   __________%5d",
-            ps_daqst->l_file_count,       ps_daqst->l_pathnum);
-    LOUT;
-    sprintf(c_line," l_file_size   ________%5d l_block_count   ______%5d",
-            ps_daqst->l_file_size,       ps_daqst->l_block_count);
-    LOUT;
-    sprintf(c_line," l_rate_on   __________%5d l_rate_sec   _________%5d",
-            ps_daqst->l_rate_on,          ps_daqst->l_rate_sec);
-    LOUT;
-    sprintf(c_line," bl_histo_port  _______%5d bl_run_time   ________%5d",
-            ps_daqst->bl_histo_port,       ps_daqst->bl_run_time);
-    LOUT;
-    sprintf(c_line," l_irq_driv_id   ______%5d l_irq_maj_dev_id   ___%5d",
-            ps_daqst->l_irq_driv_id,      ps_daqst->l_irq_maj_dev_id);
-    LOUT;
-    for(i=0; i<SBS__N_TRG_TYP; i++)
-      if(ps_daqst->bl_n_trig[i] != 0) {
-        sprintf(c_line," %2d bl_n_trig %9d bl_n_si   _____%9d bl_n_evt   _%9d",
-                i,ps_daqst->bl_n_trig[i],ps_daqst->bl_n_si[i],ps_daqst->bl_n_evt[i]);
-        LOUT;
-      }
-    sprintf(c_line," bl_spill_on   _______%d bl_delayed_eb_ena   ___%d bl_event_build_on   %d",
-            ps_daqst->bl_spill_on,           ps_daqst->bl_delayed_eb_ena,           ps_daqst->bl_event_build_on);
-    LOUT;
-    sprintf(c_line," bl_trans_ready   ___%2d bl_trans_connected   _%2d bl_dabc_enabled  _%3d",
-            ps_daqst->bl_trans_ready,         ps_daqst->bl_trans_connected,           ps_daqst->bl_dabc_enabled);
-    LOUT;
-
-    sprintf(c_line," bl_strsrv_scale   __%2d bl_strsrv_sync   ______%d bl_strsrv_keep   ___%d",
-            ps_daqst->bl_strsrv_scale,         ps_daqst->bl_strsrv_sync,           ps_daqst->bl_strsrv_keep);
-    LOUT;
-    sprintf(c_line," bl_strsrv_scaled   __%d bl_strsrv_nosync   ____%d bl_strsrv_nokeep   _%d",
-            ps_daqst->bl_strsrv_scaled,         ps_daqst->bl_strsrv_nosync,           ps_daqst->bl_strsrv_nokeep);
-    LOUT;
-    sprintf(c_line," bl_evtsrv_maxcli   _%2d bl_evtsrv_scale   ____%2d bl_evtsrv_events  %3d",
-            ps_daqst->bl_evtsrv_maxcli,         ps_daqst->bl_evtsrv_scale,           ps_daqst->bl_evtsrv_events);
-    LOUT;
-    sprintf(c_line," bl_evtsrv_all   _____%d bl_esosrv_maxcli   ___%2d",
-            ps_daqst->bl_evtsrv_all,           ps_daqst->bl_esosrv_maxcli);
-    LOUT;
-//sprintf(c_line," bl_pipe_slots   ___%3d bl_pipe_slots_filled %3d",
-//ps_daqst->bl_pipe_slots,           ps_daqst->bl_pipe_slots_filled);LOUT;
-//sprintf(c_line," bl_pipe_size_KB %6d bl_pipe_filled_KB %6d",
-//ps_daqst->bl_pipe_size_KB,           ps_daqst->bl_pipe_filled_KB);LOUT;
-
-    sprintf(c_line," c_user  ______________%s",ps_daqst->c_user);
-    LOUT;
-    sprintf(c_line," c_date  ______________%s",ps_daqst->c_date);
-    LOUT;
-    sprintf(c_line," c_exprun  ____________%s",ps_daqst->c_exprun);
-    LOUT;
-    sprintf(c_line," c_exper  _____________%s",ps_daqst->c_exper);
-    LOUT;
-    sprintf(c_line," c_host  ______________%s",ps_daqst->c_host);
-    LOUT;
-    sprintf(c_line," c_remote______________%s",ps_daqst->c_remote);
-    LOUT;
-    sprintf(c_line," c_display_____________%s",ps_daqst->c_display);
-    LOUT;
-    sprintf(c_line," c_anal_segm_name  ____%s",ps_daqst->c_anal_segm_name);
-    LOUT;
-    sprintf(c_line," c_setup_name  ________%s",ps_daqst->c_setup_name);
-    LOUT;
-    sprintf(c_line," c_ml/o_setup_name  ___%s",ps_daqst->c_ml_setup_name);
-    LOUT;
-    sprintf(c_line," c_readout_name  ______%s",ps_daqst->c_readout_name);
-    LOUT;
-    sprintf(c_line," c_pathstr  ___________%s",ps_daqst->c_pathstr);
-    LOUT;
-    sprintf(c_line," c_devname  ___________%s",ps_daqst->c_devname);
-    LOUT;
-    sprintf(c_line," c_tape_label  ________%s",ps_daqst->c_tape_label);
-    LOUT;
-    sprintf(c_line," c_file_name  _________%s",ps_daqst->c_file_name);
-    LOUT;
-    sprintf(c_line," c_out_chan  __________%s",ps_daqst->c_out_chan);
-    LOUT;
-
-    sprintf(c_line," bh_daqst_initalized %d bh_acqui_started   __%d bh_acqui_running   _%d",
-            ps_daqst->bh_daqst_initalized,         ps_daqst->bh_acqui_started,           ps_daqst->bh_acqui_running);
-    LOUT;
-    sprintf(c_line," bh_setup_loaded   __%d bh_set_ml/o_loaded %d %d bh_cam_tab_loaded   %d",
-            ps_daqst->bh_setup_loaded,             ps_daqst->bh_set_ml_loaded,             ps_daqst->bh_set_mo_loaded,           ps_daqst->bh_cam_tab_loaded);
-    LOUT;
-    sprintf(c_line," bh_trig_master   ___%d bh_histo_enable   ___%d bh_histo_ready   ___%d",
-            ps_daqst->bh_trig_master,              ps_daqst->bh_histo_enable,            ps_daqst->bh_histo_ready);
-    LOUT;
-    sprintf(c_line," bh_event_serv_ready %d bh_ena_evt_copy   ___%d l_procs_run _______%2d",
-            ps_daqst->bh_event_serv_ready,         ps_daqst->bh_ena_evt_copy,            ps_daqst->l_procs_run);
-    LOUT;
-    sprintf(c_line," m_dispatch   _______%d m_msg_log   _________%d m_util   ___________%d",
-            ps_daqst->bh_running[SYS__dispatch],   ps_daqst->bh_running[SYS__msg_log],   ps_daqst->bh_running[SYS__util]);
-    LOUT;
-    sprintf(c_line," m_collector   ______%d m_transport   _______%d m_read_cam_slav ____%d",
-            ps_daqst->bh_running[SYS__collector],  ps_daqst->bh_running[SYS__transport], ps_daqst->bh_running[SYS__read_cam_slav]);
-    LOUT;
-    sprintf(c_line," m_read_meb   _______%d m_event_serv   ______%d m_esone_serv   _____%d",
-            ps_daqst->bh_running[SYS__read_meb],   ps_daqst->bh_running[SYS__event_serv],ps_daqst->bh_running[SYS__esone_serv]);
-    LOUT;
-    sprintf(c_line," m_stream_serv   ____%d m_histogram   _______%d m_sbs_mon   ________%d",
-            ps_daqst->bh_running[SYS__stream_serv],ps_daqst->bh_running[SYS__histogram], ps_daqst->bh_running[SYS__sbs_mon]);
-    LOUT;
-    sprintf(c_line," m_prompt   _________%d m_daq_rate  _________%d m_smi  _____________%d",
-            ps_daqst->bh_running[SYS__prompt],ps_daqst->bh_running[SYS__daq_rate],ps_daqst->bh_running[SYS__smi]);
-    LOUT;
-    sprintf(c_line," m_ar   _____________%d m_rirec  ____________%d m_to  ______________%d",
-            ps_daqst->bh_running[SYS__ar],ps_daqst->bh_running[SYS__rirec],ps_daqst->bh_running[SYS__to]);
-    LOUT;
-    sprintf(c_line," m_ds  ______________%d m_dr  _______________%d m_vme_serv  ________%d",
-            ps_daqst->bh_running[SYS__ds],ps_daqst->bh_running[SYS__dr],ps_daqst->bh_running[SYS__vme_serv]);
-    LOUT;
-
-    sprintf(c_line," Tasks  ---------------------------------------------------------------------");
-    LOUT;
-    for(i=0; i<ps_daqst->l_procs_run; i++) {
-      sprintf(c_line," %2d pid %5d pprio%3d pact %1d type %2d pname %s",
-              i,ps_daqst->l_pid[i],ps_daqst->l_pprio[i],ps_daqst->bh_pact[i],ps_daqst->l_type[i],ps_daqst->c_pname[i]);
-      LOUT;
-    }
-  }
-
-  if(ps_setup != NULL) {
-    sprintf(c_line,"S_setup *********************************************************************");
-    LOUT;
-
-    sprintf(c_line," l_version ___________________%5d l_endian ___________________%5d",
-            ps_setup->l_version,ps_setup->l_endian);
-    LOUT;
-    sprintf(c_line," bl_struc_len ________________%5d l_fix_lw ___________________%5d",
-            ps_setup->bl_struc_len,             ps_setup->l_fix_lw);
-    LOUT;
-    sprintf(c_line," bl_sbs__n_cr ________________%5d bl_sbs__n_trg_typ __________%5d",
-            ps_setup->bl_sbs__n_cr,             ps_setup->bl_sbs__n_trg_typ);
-    LOUT;
-    sprintf(c_line," bl_no_crates ________________%5d bh_crate_nr ________________%5d",
-            ps_setup->bl_no_crates,             ps_setup->bh_crate_nr);
-    LOUT;
-    sprintf(c_line," bl_se_meb_asy_len ___________%5d bh_rd_typ __________________%5d",
-            ps_setup->bl_se_meb_asy_len,        ps_setup->bh_rd_typ);
-    LOUT;
-    sprintf(c_line," bh_meb_asy_flg ______________%5d bh_col_mode ________________%5d",
-            ps_setup->bh_meb_asy_flg,           ps_setup->bh_col_mode);
-    LOUT;
-    sprintf(c_line," bh_meb_trig_mode ____________%5d bh_special_meb_trig_type ___%5d",
-            ps_setup->bh_meb_trig_mode,         ps_setup->bh_special_meb_trig_type);
-    LOUT;
-    sprintf(c_line," bl_loc_esone_base _______x%08x bl_rem_esone_base ______x%08x",
-            ps_setup->bl_loc_esone_base,        ps_setup->bl_rem_esone_base);
-    LOUT;
-    sprintf(c_line," bl_esone_off ____________x%08x bl_cvc_crr_off _________x%08x",
-            ps_setup->bl_esone_off,             ps_setup->bl_cvc_crr_off);
-    LOUT;
-    sprintf(c_line," bl_cvc_csr_off __________x%08x bl_cvc_clb_off _________x%08x",
-            ps_setup->bl_cvc_csr_off,           ps_setup->bl_cvc_clb_off);
-    LOUT;
-    sprintf(c_line," bl_ml_pipe_base_addr ____x%08x bl_ml_pipe_seg_len _____x%08x",
-            ps_setup->bl_ml_pipe_base_addr,     ps_setup->bl_ml_pipe_seg_len);
-    LOUT;
-    sprintf(c_line," bl_special_meb_trig_base x%08x bl_ml_pipe_len _________x%08x",
-            ps_setup->bl_special_meb_trig_base, ps_setup->bl_ml_pipe_len);
-    LOUT;
-    sprintf(c_line," lp_cvc_irq ______________x%08x bl_cvc_irq_len _________x%08x",
-            ps_setup->lp_cvc_irq,               ps_setup->bl_cvc_irq_len);
-    LOUT;
-    sprintf(c_line," bl_cvc_irq_source_off ___x%08x bl_cvc_irq_mask_off ____x%08x",
-            ps_setup->bl_cvc_irq_source_off,    ps_setup->bl_cvc_irq_mask_off);
-    LOUT;
-    sprintf(c_line," bl_ev_buf_len ________%5d bl_n_ev_buf _______%5d bl_n_stream _______%5d",
-            ps_setup->bl_ev_buf_len,    ps_setup->bl_n_ev_buf,   ps_setup->bl_n_stream);
-    LOUT;
-    sprintf(c_line," bi_evt_typ_sy ________%5d bi_evt_typ_asy ____%5d bi_evt_subtyp_sy __%5d",
-            ps_setup->bi_evt_typ_sy,    ps_setup->bi_evt_typ_asy,ps_setup->bi_evt_subtyp_sy);
-    LOUT;
-    sprintf(c_line," bi_evt_subtyp_asy ____%5d h_se_control ______%5d h_rd_tab_flg ______%5d",
-            ps_setup->bi_evt_subtyp_asy,ps_setup->h_se_control,  ps_setup->h_rd_tab_flg);
-    LOUT;
-    sprintf(c_line," bl_init_read_len _____%5d bl_n_col_retry ____%5d bi_master ___%4s__%5d",
-            ps_setup->bl_init_read_len, ps_setup->bl_n_col_retry,ps_master[ps_setup->bi_master-1],ps_setup->bi_master);
-    LOUT;
-    sprintf(c_line," Crates ---------------------------------------------------------------------");
-    LOUT;
-    for(i=0; i<SBS__N_CR; i++) {
-      if((ps_setup->lp_rem_mem_base[i] != 0) |
-          (ps_setup->lp_rem_cam_base[i] != 0) |
-          (ps_setup->lp_loc_mem_base[i] != 0) |
-          (ps_setup->lp_loc_pipe_base[i] != 0)) {
-        sprintf(c_line," %2d rem_mem_base __x%08x rem_mem_off ___x%08x rem_mem_len ___x%08x",
-                i,ps_setup->lp_rem_mem_base[i], ps_setup->bl_rem_mem_off[i], ps_setup->bl_rem_mem_len[i]);
-        LOUT;
-        sprintf(c_line," %2d rem_cam_base __x%08x rem_cam_off ___x%08x rem_cam_len ___x%08x",
-                i,ps_setup->lp_rem_cam_base[i], ps_setup->bl_rem_cam_off[i], ps_setup->bl_rem_cam_len[i]);
-        LOUT;
-        sprintf(c_line," %2d loc_mem_base __x%08x loc_mem_len ___x%08x loc_pipe_base _x%08x",
-                i,ps_setup->lp_loc_mem_base[i], ps_setup->bl_loc_mem_len[i], ps_setup->lp_loc_pipe_base[i]);
-        LOUT;
-        sprintf(c_line," %2d pipe_off ______x%08x pipe_seg_len __x%08x pipe_len __________%5d",
-                i,ps_setup->bl_pipe_off[i],     ps_setup->bl_pipe_seg_len[i],ps_setup->bl_pipe_len[i]);
-        LOUT;
-        sprintf(c_line," %2d init_tab_off __x%08x init_tab_len __x%08x",
-                i,ps_setup->bl_init_tab_off[i], ps_setup->bi_init_tab_len[i]);
-        LOUT;
-        sprintf(c_line," %2d controller_id _____%5d sy_asy_flg ________%5d trig_stat_nr ______%5d",
-                i,ps_setup->bh_controller_id[i],ps_setup->bh_sy_asy_flg[i],  ps_setup->bh_trig_stat_nr[i]);
-        LOUT;
-        sprintf(c_line," %2d trig_cvt __________%5d trig_fct __________%5d rd_flg ____________%5d",
-                i,ps_setup->bl_trig_cvt[i],     ps_setup->bl_trig_fct[i],    ps_setup->bh_rd_flg[i]);
-        LOUT;
-        sprintf(c_line," %2d i_se_typ __________%5d i_se_subtyp _______%5d i_se_procid _______%5d",
-                i,ps_setup->i_se_typ[i],        ps_setup->i_se_subtyp[i],    ps_setup->i_se_procid[i]);
-        LOUT;
-        for(j=0; j<SBS__N_TRG_TYP; j++) {
-          if(ps_setup->bi_rd_tab_len[i][j] != 0) {
-            sprintf(c_line,"  %2d %2d bl_max_se_len x%08x   bl_rd_tab_off x%08x   bi_rd_tab_len x%08x",
-                    i,j,ps_setup->bl_max_se_len[i][j],ps_setup->bl_rd_tab_off[i][j],ps_setup->bi_rd_tab_len[i][j]);
-            LOUT;
-          }
-        }
-      }
-    }
-  }
-
-  if(ps_set_ml != NULL) {
-    sprintf(c_line,"S_set_ml ********************************************************************");
-    LOUT;
-    sprintf(c_line," l_version ______________%5d l_endian _______________%5d",
-            ps_set_ml->l_version,      ps_set_ml->l_endian);
-    LOUT;
-    sprintf(c_line," l_set_ml_lw ____________%5d l_fix_lw _______________%5d",
-            ps_set_ml->l_set_ml_lw,    ps_set_ml->l_fix_lw);
-    LOUT;
-    sprintf(c_line," l_ml__n_rd_pipe ________%5d l_short_len ____________%5d",
-            ps_set_ml->l_ml__n_rd_pipe,ps_set_ml->l_short_len);
-    LOUT;
-    sprintf(c_line," l_long_len _____________%5d l_n_rd_pipe ____________%5d",
-            ps_set_ml->l_long_len,     ps_set_ml->l_n_rd_pipe);
-    LOUT;
-    sprintf(c_line," l_out_mode _____________%5d l_wr_pipe_base_addr x%08x",
-            ps_set_ml->l_out_mode,     ps_set_ml->l_wr_pipe_base_addr);
-    LOUT;
-    sprintf(c_line," l_wr_pipe_len ______x%08x l_wr_pipe_n_frag _______%5d",
-            ps_set_ml->l_wr_pipe_len,  ps_set_ml->l_wr_pipe_n_frag);
-    LOUT;
-    sprintf(c_line," l_ev_buf_len ___________%5d l_n_ev_buf _____________%5d",
-            ps_set_ml->l_ev_buf_len,   ps_set_ml->l_n_ev_buf);
-    LOUT;
-    sprintf(c_line," l_n_stream _____________%5d",
-            ps_set_ml->l_n_stream);
-    LOUT;
-    sprintf(c_line," c_hostname _____________%s",
-            ps_set_ml->c_hostname);
-    LOUT;
-    sprintf(c_line," Pipes ----------------------------------------------------------------------");
-    LOUT;
-    for(i=0; i<ps_set_ml->l_n_rd_pipe; i++) {
-      sprintf(c_line,"  %2d c_rd_hostname     %s",
-              i,ps_set_ml->c_rd_hostname[i]);
-      LOUT;
-      sprintf(c_line,"  %2d c_sbs_setup_path  %s",
-              i,ps_set_ml->c_sbs_setup_path[i]);
-      LOUT;
-      sprintf(c_line,"  %2d l_rd_pipe_base_addr x%08x   l_rd_pipe_len _____x%08x",
-              i,ps_set_ml->l_rd_pipe_base_addr[i],ps_set_ml->l_rd_pipe_len[i]);
-      LOUT;
-      sprintf(c_line,"  %2d l_rd_pipe_n_frag _______%5d   l_rd_host_flg _________%5d",
-              i,ps_set_ml->l_rd_pipe_n_frag[i],   ps_set_ml->l_rd_host_flg[i]);
-      LOUT;
-    }
-  }
-
-  if(ps_set_mo != NULL) {
-    sprintf(c_line,"S_set_mo ********************************************************************");
-    LOUT;
-    sprintf(c_line,"ds_hostname       dr_hostname      active");
-    LOUT;
-    if(ps_set_mo->l_no_senders > ps_set_mo->l_no_receivers) { j = ps_set_mo->l_no_senders; }
-    else { j = ps_set_mo->l_no_receivers; }
-    for(i = 0; i < j ; i++) {
-      sprintf(c_line,"%2d %-16s  %-16s %d",i+1,
-              &ps_set_mo->c_ds_hostname[i][0],&ps_set_mo->c_dr_hostname[i][0],ps_set_mo->bl_dr_active[i]);
-      LOUT;
-    }
-    for(i = 0; i < ps_set_mo->l_no_receivers ; i++) {
-      sprintf(c_line,"%2d l_ev_buf_len ___%5d l_n_ev_buf __%5d l_n_stream __%5d",i+1,
-              ps_set_mo->l_ev_buf_len[i],    ps_set_mo->l_n_ev_buf[i],   ps_set_mo->l_n_stream[i]);
-      LOUT;
-    }
-    sprintf(c_line,"l_max_evt_size ___%8d l_n_frag ____%5d",ps_set_mo->l_max_evt_size,ps_set_mo->l_n_frag);
-    LOUT;
-
-  }
-  return(0);
-}
diff --git a/MbsAPI/f_ut_status.c b/MbsAPI/f_ut_status.c
deleted file mode 100644
index b0090ae..0000000
--- a/MbsAPI/f_ut_status.c
+++ /dev/null
@@ -1,701 +0,0 @@
-// $Id: f_ut_status.c 600 2010-03-18 12:26:47Z goofy $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-//
-// NOTE !!!!!!!
-// To avoid hanging sockets on Lynx, we read one byte less than MBS sends.
-// This byte is the last of process name table, so never used.
-// In MBS the problem can be fixed. Then this workaround can be rolled back.
-// Reason is that client must close socket before server.
-
-#include "typedefs.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <string.h>
-#include <memory.h>
-#include <sys/types.h>
-#include <ctype.h>
-#include "sbs_def.h"
-#include "sys_def.h"
-#include "ml_def.h"
-#include "s_daqst.h"
-#include "s_setup.h"
-#include "s_set_ml.h"
-#include "s_set_mo.h"
-#include "f_stccomm.h"
-
-#define VERSION__DAQST  2
-#define VERSION__SETUP  1
-#define VERSION__SET_ML 1
-#define VERSION__SET_MO 1
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_status_ini                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_status_ini(s_daqst)                   */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Initialize s_daqst.                                 */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_daqst    : pointer to s_daqst                                  */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_status_ini(s_daqst* ps_daqst)
-{
-  if(ps_daqst == NULL) { return -1; }
-
-  ps_daqst->l_endian            = 1;
-  ps_daqst->l_version           = VERSION__DAQST;
-  ps_daqst->l_daqst_lw          = sizeof(s_daqst)/4;
-  ps_daqst->l_fix_lw            = ((long)&ps_daqst->c_pname[0][0]-(long)ps_daqst)/4;
-  ps_daqst->l_sys__n_max_procs  = SYS__N_MAX_PROCS;
-  ps_daqst->l_sbs__str_len_64   = SBS__STR_LEN_64;
-  ps_daqst->l_sbs__n_trg_typ    = SBS__N_TRG_TYP;
-  ps_daqst->bh_daqst_initalized = 1;
-
-  return 0;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_status                                         */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_status(s_daqst, socket)               */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Send s_daqst to socket.                             */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_daqst    : pointer to s_daqst                                  */
-/*+  socket     : Tcp socket from accept                              */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_status(s_daqst* ps_daqst, INTS4 l_tcp)
-{
-  INTS4 l,l_status;
-
-  l = ps_daqst->l_fix_lw * 4 + ps_daqst->l_procs_run * ps_daqst->l_sbs__str_len_64;
-  /*printf("daqst Send %d LW + %d LW",ps_daqst->l_fix_lw,ps_daqst->l_procs_run * ps_daqst->l_sbs__str_len_64/4);*/
-  l_status = f_stc_write (ps_daqst, l, l_tcp);
-  return l_status;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_status_r                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_status_r(s_daqst, socket)             */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_daqst from socket.                           */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_daqst    : pointer to s_daqst                                  */
-/*+  socket     : Tcp socket from connect                             */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_status_r(s_daqst* ps_daqst, INTS4 l_tcp)
-{
-  INTS4 l_swap=0, len_64, n_trg, max_proc;
-  INTS4 l_cmd;
-  INTS4 i,k;
-  INTS4 l_status;
-  INTU4* pc;
-
-  memset((void*)ps_daqst,0,sizeof(s_daqst));
-  l_cmd=1;
-  l_status = f_stc_write (&l_cmd,4,l_tcp);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  l_status = f_stc_read (&ps_daqst->l_endian,28,l_tcp,-1);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  if(ps_daqst->l_endian != 1) { l_swap = 1; }
-  if(l_swap == 1) { l_status = f_swaplw(&ps_daqst->l_endian,7,NULL); }
-  len_64=ps_daqst->l_sbs__str_len_64;
-  n_trg=ps_daqst->l_sbs__n_trg_typ;
-  max_proc=ps_daqst->l_sys__n_max_procs;
-  if(ps_daqst->l_version == 1) {
-    // MBS v44 and previous no longer supported
-    return(-1);
-  }
-  // MBS v50
-  if(ps_daqst->l_version == 2) {
-    k=(48+n_trg*3)*4; // up to bl_n_evt inclusive
-    l_status = f_stc_read (&ps_daqst->bh_daqst_initalized, k , l_tcp,-1);
-    k=(24+max_proc*5)*4; // bh_running up to bl_event_build_on inclusive
-    l_status = f_stc_read (&ps_daqst->bh_running[0], k , l_tcp,-1);
-    k=len_64*15; // strings up to c_file_name inclusive
-    l_status = f_stc_read (&ps_daqst->c_user[0], k , l_tcp,-1);
-    l_status = f_stc_read (&ps_daqst->c_out_chan[0], len_64 , l_tcp,-1);
-    ps_daqst->l_fix_lw += n_trg*3 + 212 + len_64/4*3;
-    if(l_swap == 1) {
-      l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7) - (19 * len_64/4),NULL);
-    }
-  }
-  // MBS v51
-  if(ps_daqst->l_version == 51) {
-    l_status = f_stc_read (&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7)*4 , l_tcp,-1);
-    if(l_swap == 1) {
-      l_status = f_swaplw(&ps_daqst->bh_daqst_initalized, (ps_daqst->l_fix_lw-7) - (19 * len_64/4),NULL);
-    }
-  }
-
-  //l_status = f_stc_read (&ps_daqst->c_pname[0], ps_daqst->l_procs_run * len_64, l_tcp,-1);
-  // workaround:
-  l_status = f_stc_read (&ps_daqst->c_pname[0], ps_daqst->l_procs_run * len_64 -1, l_tcp,-1);
-  return l_status;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_setup_ini                                      */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_setup_ini(s_setup)                    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Initialize s_setup.                                 */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_setup    : pointer to s_setup                                  */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_setup_ini(s_setup* ps_setup)
-{
-  if(ps_setup == NULL) { return -1; }
-  ps_setup->l_endian     = 1;
-  ps_setup->l_version    = VERSION__SETUP;
-  ps_setup->bl_struc_len = sizeof(s_setup)/4;
-  ps_setup->l_fix_lw     = ((long)&ps_setup->lp_rem_mem_base[0]-(long)ps_setup)/4;
-  ps_setup->bl_sbs__n_cr = SBS__N_CR;
-  ps_setup->bl_sbs__n_trg_typ = SBS__N_TRG_TYP;
-  return 0;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_setup                                          */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_setup(s_setup, s_setup, socket)       */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Write s_setup to socket.                            */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_setup    : pointer to s_setup                                  */
-/*+  s_setup    : pointer to copy of s_setup                          */
-/*+  socket     : Tcp socket from accept                              */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_setup(s_setup* ps_setup, INTU4* pl_o, INTS4 l_tcp)
-{
-  INTS4 i,l,k,n=0,l_status;
-  INTU4* pl_count,*pl_s,*pl_size;
-
-  l_status = f_ut_setup_ini(ps_setup);
-
-  /*printf("setup Send %d LW + ",ps_setup->l_fix_lw);*/
-  l_status = f_stc_write (ps_setup, ps_setup->l_fix_lw*4, l_tcp);
-  pl_count = pl_o++;
-  pl_size = pl_o++;
-  l = 0;
-  for(i=0; i<ps_setup->bl_sbs__n_cr; i++) {
-    if(ps_setup->bh_rd_flg[i] != 0) {
-      n=0;
-      l++;
-      *pl_o++ = i;
-      n++;
-      *pl_o++ = (INTU4) ps_setup->lp_rem_mem_base[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_rem_mem_off[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_rem_mem_len[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->lp_rem_cam_base[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_rem_cam_off[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_rem_cam_len[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->lp_loc_mem_base[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_loc_mem_len[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->lp_loc_pipe_base[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_pipe_off[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_pipe_seg_len[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_pipe_len[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bh_controller_id[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bh_sy_asy_flg[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bh_trig_stat_nr[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_trig_cvt[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_trig_fct[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->i_se_typ[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->i_se_subtyp[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->i_se_procid[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bh_rd_flg[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bl_init_tab_off[i];
-      n++;
-      *pl_o++ = (INTU4) ps_setup->bi_init_tab_len[i];
-      n++;
-      for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) {
-        *pl_o++ = (INTU4) ps_setup->bl_max_se_len[i][k];
-      }
-      for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) {
-        *pl_o++ = (INTU4) ps_setup->bl_rd_tab_off[i][k];
-      }
-      for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) {
-        *pl_o++ = (INTU4) ps_setup->bi_rd_tab_len[i][k];
-      }
-      n = n + 3 * ps_setup->bl_sbs__n_trg_typ;
-    }
-  }
-  *pl_count=l;
-  *pl_size=n;
-  l = l * n + 2;
-  /*printf("%d \n",l);*/
-  l_status = f_stc_write (pl_count, l * 4, l_tcp);
-  return l_status;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_setup_r                                        */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_setup_r(s_setup, socket)              */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_setup from socket.                           */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_setup    : pointer to s_setup                                  */
-/*+  socket     : Tcp socket from connect                             */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_setup_r(s_setup* ps_setup, INTS4 l_tcp)
-{
-  INTS4 l_swap=0;
-  INTS4 l_cmd;
-  INTS4 i,k,l_items,l_size,l_crate;
-  INTS4* pl_b,*pl_o;
-  INTS4 l_status;
-
-  memset(ps_setup,0,sizeof(s_setup));
-  l_cmd=2;
-  l_status = f_stc_write (&l_cmd,4,l_tcp);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  l_status = f_stc_read (&ps_setup->l_endian,16,l_tcp,-1);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  if(ps_setup->l_endian != 1) { l_swap = 1; }
-  if(l_swap == 1) { l_status = f_swaplw(&ps_setup->l_endian,4,NULL); }
-  if(ps_setup->l_version != VERSION__SETUP) { return -1; }
-  l_status = f_stc_read (&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4)*4 , l_tcp,-1);
-  l_status = f_stc_read (&l_items,4 , l_tcp,-1);
-  l_status = f_stc_read (&l_size,4 , l_tcp,-1);
-  if(l_swap == 1) { l_status = f_swaplw(&ps_setup->bl_sbs__n_cr, (ps_setup->l_fix_lw-4),NULL); }
-  if(l_swap == 1) { l_status = f_swaplw(&l_items,1,NULL); }
-  if(l_swap == 1) { l_status = f_swaplw(&l_size,1,NULL); }
-  pl_b = (INTS4*) malloc(l_size * l_items * 4);
-  l_status = f_stc_read (pl_b,l_size * l_items * 4, l_tcp,-1);
-  if(l_swap == 1) { l_status = f_swaplw(pl_b,l_size * l_items,NULL); }
-
-  pl_o = pl_b;
-  for(i=0; i<l_items; i++) {
-    l_crate = *pl_o++;
-    ps_setup->lp_rem_mem_base[l_crate] = *pl_o++;
-    ps_setup->bl_rem_mem_off[l_crate] = *pl_o++;
-    ps_setup->bl_rem_mem_len[l_crate] = *pl_o++;
-    ps_setup->lp_rem_cam_base[l_crate] = *pl_o++;
-    ps_setup->bl_rem_cam_off[l_crate] = *pl_o++;
-    ps_setup->bl_rem_cam_len[l_crate] = *pl_o++;
-    ps_setup->lp_loc_mem_base[l_crate] = *pl_o++;
-    ps_setup->bl_loc_mem_len[l_crate] = *pl_o++;
-    ps_setup->lp_loc_pipe_base[l_crate] = *pl_o++;
-    ps_setup->bl_pipe_off[l_crate] = *pl_o++;
-    ps_setup->bl_pipe_seg_len[l_crate] = *pl_o++;
-    ps_setup->bl_pipe_len[l_crate] = *pl_o++;
-    ps_setup->bh_controller_id[l_crate] = *pl_o++;
-    ps_setup->bh_sy_asy_flg[l_crate] = *pl_o++;
-    ps_setup->bh_trig_stat_nr[l_crate] = *pl_o++;
-    ps_setup->bl_trig_cvt[l_crate] = *pl_o++;
-    ps_setup->bl_trig_fct[l_crate] = *pl_o++;
-    ps_setup->i_se_typ[l_crate] = *pl_o++;
-    ps_setup->i_se_subtyp[l_crate] = *pl_o++;
-    ps_setup->i_se_procid[l_crate] = *pl_o++;
-    ps_setup->bh_rd_flg[l_crate] = *pl_o++;
-    ps_setup->bl_init_tab_off[l_crate] = *pl_o++;
-    ps_setup->bi_init_tab_len[l_crate] = *pl_o++;
-    for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) { ps_setup->bl_max_se_len[l_crate][k] = *pl_o++; }
-    for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) { ps_setup->bl_rd_tab_off[l_crate][k] = *pl_o++; }
-    for(k=0; k<ps_setup->bl_sbs__n_trg_typ; k++) { ps_setup->bi_rd_tab_len[l_crate][k] = *pl_o++; }
-  } /* setup */
-  free(pl_b);
-  return 0;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_ml_ini                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_ml_ini(s_set_ml)                  */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Initialize s_set_ml.                                */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_ml   : pointer to s_set_ml                                 */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_ml_ini(s_set_ml* ps_set_ml)
-{
-  if(ps_set_ml == NULL) { return -1; }
-  ps_set_ml->l_endian        = 1;
-  ps_set_ml->l_version       = VERSION__SET_ML;
-  ps_set_ml->l_set_ml_lw     = sizeof(s_set_ml)/4;
-  ps_set_ml->l_fix_lw        = ((long)&ps_set_ml->c_rd_hostname[0][0]-(long)ps_set_ml)/4;
-  ps_set_ml->l_ml__n_rd_pipe = ML__N_RD_PIPE;
-  ps_set_ml->l_short_len     = 16;
-  ps_set_ml->l_long_len      = 128;
-  return 0;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_ml                                         */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_ml(s_set_ml, s_set_ml, socket)    */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Write s_set_ml to socket.                           */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_ml   : pointer to s_set_ml                                 */
-/*+  s_set_ml   : pointer to copy of s_set_ml                         */
-/*+  socket     : Tcp socket from accept                              */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_ml(s_set_ml* ps_set_ml, INTU4* pl_o, INTS4 l_tcp)
-{
-  INTS4 i,l,k,n=0,l_status;
-  INTU4* pl_count,*pl_s,*pl_size;
-
-  l_status = f_ut_set_ml_ini(ps_set_ml);
-
-  pl_count = pl_o;
-  /*printf("MLset Send %d LW + ",ps_set_ml->l_fix_lw);*/
-  l_status = f_stc_write (ps_set_ml, ps_set_ml->l_fix_lw*4, l_tcp);
-  l = 0;
-  for(i=0; i<ps_set_ml->l_n_rd_pipe; i++) {
-    l++;
-    pl_s = (INTU4*)&ps_set_ml->c_rd_hostname[i];
-    for(k=0; k<ps_set_ml->l_short_len/4; k++) { *pl_o++ = *pl_s++; }
-    pl_s = (INTU4*)&ps_set_ml->c_sbs_setup_path[i];
-    for(k=0; k<ps_set_ml->l_long_len/4; k++) { *pl_o++ = *pl_s++; }
-  }
-  l = l * (ps_set_ml->l_short_len + ps_set_ml->l_long_len);
-  /*printf("%d \n",l);*/
-  l_status = f_stc_write (pl_count, l , l_tcp);
-  return l_status;
-}
-
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_ml_r                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_ml_r(s_set_ml, socket)            */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_set_ml from socket.                          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_ml   : pointer to s_set_ml                                 */
-/*+  socket     : Tcp socket from connect                             */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 14-Nov-1998                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_ml_r(s_set_ml* ps_set_ml, INTS4 l_tcp)
-{
-  INTS4 l_swap=0;
-  INTS4 l_cmd;
-  INTS4 i;
-  INTS4 l_status;
-
-  l_cmd=3;
-  l_status = f_stc_write (&l_cmd,4, l_tcp);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  l_status = f_stc_read (&ps_set_ml->l_endian,16,l_tcp,-1);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  if(ps_set_ml->l_endian != 1) { l_swap = 1; }
-  if(l_swap == 1) { l_status = f_swaplw(&ps_set_ml->l_endian,4,NULL); }
-  if(ps_set_ml->l_version != VERSION__SET_ML) { return -1; }
-  l_status = f_stc_read (&ps_set_ml->l_ml__n_rd_pipe,(ps_set_ml->l_fix_lw-4)*4 , l_tcp,-1);
-  if(l_swap == 1) { l_status = f_swaplw(&ps_set_ml->l_ml__n_rd_pipe,(ps_set_ml->l_fix_lw-4)-4,NULL); } /* last 16 byte are char */
-  for(i=0; i<ps_set_ml->l_n_rd_pipe; i++) {
-    l_status = f_stc_read (&ps_set_ml->c_rd_hostname[i],   ps_set_ml->l_short_len, l_tcp,-1);
-    l_status = f_stc_read (&ps_set_ml->c_sbs_setup_path[i],ps_set_ml->l_long_len,  l_tcp,-1);
-  }
-  return 0;
-}
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                                */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_mo_ini                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_mo_ini(s_set_mo)                  */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Initialize s_set_mo.                                */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_mo   : pointer to s_set_mo                                 */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 24-Oct-2005                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_mo_ini(s_set_mo* ps_set_mo)
-{
-  INTS4 i;
-  if(ps_set_mo == NULL) { return -1; }
-  ps_set_mo->l_endian        = 1;
-  ps_set_mo->l_version       = VERSION__SET_MO;
-  ps_set_mo->l_set_mo_lw     = sizeof(s_set_mo)/4;
-  ps_set_mo->l_swap_lw       = ((long)&ps_set_mo->c_ds_hostname[0][0]-(long)ps_set_mo)/4;
-  ps_set_mo->l_max_nodes     = MO__N_NODE;
-  ps_set_mo->l_no_senders    = 0;
-  ps_set_mo->l_no_receivers  = 0;
-  for(i=0; i<MO__N_NODE; i++)if(strlen(&ps_set_mo->c_ds_hostname[i][0]) > 0) { ps_set_mo->l_no_senders++; }
-  for(i=0; i<MO__N_NODE; i++)if(strlen(&ps_set_mo->c_dr_hostname[i][0]) > 0) { ps_set_mo->l_no_receivers++; }
-  return 0;
-}
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_mo                                         */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_mo(s_set_mo, socket)               */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Send s_set_mo to socket.                             */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_daqst    : pointer to s_set_mo                                  */
-/*+  socket     : Tcp socket from accept                              */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 25.Oct.2005                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_mo(s_set_mo* ps_set_mo, INTS4 l_tcp)
-{
-  INTS4 l,l_status;
-
-  l_status=f_ut_set_mo_ini(ps_set_mo);
-  if(l_status != 0) { return l_status; }
-  l_status = f_stc_write (ps_set_mo, ps_set_mo->l_set_mo_lw*4, l_tcp);
-  return l_status;
-}
-
-
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_set_mo_r                                       */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : l_status=f_ut_set_mo_r(s_set_mo, socket)            */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Read s_set_mo from socket.                          */
-/*                                                                    */
-/*+ ARGUMENTS   :                                                     */
-/*+  s_set_mo   : pointer to s_set_mo                                 */
-/*+  socket     : Tcp socket from connect                             */
-/*2+Implementation************+****************************************/
-/*+ File name   : f_ut_status.c                                       */
-/*+ Home direct.: /mbs/prod/src                                       */
-/*+ Version     : 2.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 25.Oct.2005                                         */
-/*+ Object libr.: mbslib.a                                            */
-/*+ Updates     : Date        Purpose                                 */
-/*1- C Procedure *************+****************************************/
-INTS4 f_ut_set_mo_r(s_set_mo* ps_set_mo, INTS4 l_tcp)
-{
-  INTS4 l_swap=0;
-  INTS4 l_cmd;
-  INTS4 l_status;
-
-  l_cmd=4;
-  l_status = f_stc_write (&l_cmd,4, l_tcp);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  l_status = f_stc_read (ps_set_mo,16,l_tcp,-1);
-  if (l_status != STC__SUCCESS) { return(-1); }
-  if(ps_set_mo->l_endian != 1) { l_swap=1; }
-  if(l_swap) { l_status = f_swaplw(ps_set_mo,4,NULL); }
-
-  l_status = f_stc_read (&ps_set_mo->l_max_nodes,(ps_set_mo->l_set_mo_lw-4)*4,  l_tcp,-1);
-  if(l_swap) { l_status = f_swaplw(&ps_set_mo->l_max_nodes,ps_set_mo->l_swap_lw-4,NULL); }
-
-  return 0;
-}
diff --git a/MbsAPI/f_ut_status.h b/MbsAPI/f_ut_status.h
deleted file mode 100644
index b74b767..0000000
--- a/MbsAPI/f_ut_status.h
+++ /dev/null
@@ -1,25 +0,0 @@
-// $Id: f_ut_status.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-INTS4 f_ut_setup(s_setup*, INTU4*, INTS4);
-INTS4 f_ut_set_ml(s_set_ml*, INTU4*, INTS4);
-INTS4 f_ut_status(s_daqst*, INTS4);
-INTS4 f_ut_setup_r(s_setup*, INTS4);
-INTS4 f_ut_set_ml_r(s_set_ml*, INTS4);
-INTS4 f_ut_status_r(s_daqst*, INTS4);
-INTS4 f_ut_setup_ini(s_setup*);
-INTS4 f_ut_set_ml_ini(s_set_ml*);
-INTS4 f_ut_set_mo_ini(s_set_mo*);
-INTS4 f_ut_status_ini(s_daqst*);
-INTS4 f_ut_set_mo(s_set_mo*, INTS4);
-INTS4 f_ut_set_mo_r(s_set_mo*, INTS4);
diff --git a/MbsAPI/f_ut_time.c b/MbsAPI/f_ut_time.c
deleted file mode 100644
index da6ea08..0000000
--- a/MbsAPI/f_ut_time.c
+++ /dev/null
@@ -1,88 +0,0 @@
-// $Id: f_ut_time.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*****************+***********+****************************************/
-/*                                                                    */
-/*   GSI, Gesellschaft fuer Schwerionenforschung mbH                  */
-/*   Postfach 11 05 52                                                */
-/*   D-64220 Darmstadt                                               */
-/*                                                                    */
-/*1+ C Procedure *************+****************************************/
-/*                                                                    */
-/*+ Module      : f_ut_time                                     */
-/*                                                                    */
-/*--------------------------------------------------------------------*/
-/*+ CALLING     : CHARS * = f_ut_time(CHARS *)                          */
-/*--------------------------------------------------------------------*/
-/*                                                                    */
-/*+ PURPOSE     : Returns date/time string in format                  */
-/*                  day-month-year hours:min:sec                      */
-/*                must be linked on Lynx with -X (=posix library)     */
-/*                because of the time correction done.                */
-/*                On VMS with /PREF=ALL                               */
-/*                                                                    */
-/*3+Function******+***********+****************************************/
-/*                                                                    */
-/*                Length of returned string is 17. No \n.             */
-/*                                                                    */
-/*3+Examples******+***********+****************************************/
-/*                Description                                         */
-/*2+Implementation************+****************************************/
-/*+ Utility     : util                                                */
-/*+ File name   : f_ut_time.c                                         */
-/*+ Home direct.: path                                                */
-/*+ Declaration : CHARS *f_ut_time(CHARS *);                            */
-/*+ Version     : 1.01                                                */
-/*+ Author      : H.G.Essel                                           */
-/*+ Created     : 24-Mar-1994                                         */
-/*+ Object libr.:                                                     */
-/*+ Updates     : Date        Purpose                                 */
-/*-             : 03-apr-97 : support VMS, AIX, DECunix, Lynx         */
-/*1- C Procedure *************+****************************************/
-#ifdef Lynx
-#include <types.h>
-#include <timeb.h>
-#else
-#include <sys/types.h>
-#include <sys/timeb.h>
-#endif
-#include <stdio.h>
-#include <time.h>
-
-CHARS*     f_ut_time (CHARS* pc_time)
-{
-
-  time_t    t_time;
-  struct timeb tp;
-  struct tm st_time;
-
-  ftime (&tp);
-
-#ifdef Lynx
-  /* Note: due to an error in POSIX Version of localtime, 1 day has to be */
-  /* added to get the correct date. During daylight saving period 1 hour */
-  /* has to be added additionaly                                         */
-  tp.time+=86400; /* add 1 day */
-  localtime_r(&st_time,&tp.time);
-  if(st_time.tm_mon > 2 && st_time.tm_mon < 9) {  /* daylight saving ? */
-    tp.time+=3600;
-    localtime_r(&st_time,&tp.time);
-  }
-#else
-  st_time=*localtime(&tp.time);
-#endif
-
-  strftime(pc_time,30,"%d-%h-%y %T",&st_time);
-  return ((CHARS*) pc_time);
-}
diff --git a/MbsAPI/f_ut_utime.c b/MbsAPI/f_ut_utime.c
index 44f2c12..b24cb0c 100644
--- a/MbsAPI/f_ut_utime.c
+++ b/MbsAPI/f_ut_utime.c
@@ -63,7 +63,7 @@
 INTS4 f_ut_utime(INTS4 l_sec, INTS4 l_msec, CHARS* pc_time)
 {
 
-  time_t t_time;
+//  time_t t_time;
   struct timeb tp;
   struct tm st_time;
   CHARS c_allmon[37]="JanFebMarAprMayJunJulAugSepOctNovDec";
diff --git a/MbsAPI/f_ut_wild.c b/MbsAPI/f_ut_wild.c
deleted file mode 100644
index 7a4fcbb..0000000
--- a/MbsAPI/f_ut_wild.c
+++ /dev/null
@@ -1,62 +0,0 @@
-// $Id: f_ut_wild.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#define MATCH    0
-#define NOMATCH -1
-
-INTS4 f_ut_wild(CHARS* pc_test, CHARS* pc_wild)
-{
-  INTS4 l_wild,l_test,l_len;
-  CHARS c_wild[256],c_test[256];
-  CHARS* pc_h,*pc_n,*pc_w,*pc_s;
-  strcpy(c_wild,pc_wild);
-  strcpy(c_test,pc_test);
-  pc_w=(CHARS*)c_wild;
-  pc_s=(CHARS*)c_test;
-  l_test=strlen(pc_s);
-  while(1) {
-    while(*pc_w=='*') {
-      while(*pc_w=='*') {pc_w++; if(*pc_w==0) { return MATCH; }}
-      pc_h=pc_w;
-      while((*pc_h!='*')&(*pc_h!=0)) { pc_h++; }
-      if(*pc_h==0) {
-        /* match pc_w at end of test */
-        l_len=strlen(pc_w);
-        if(strlen(pc_s) < l_len) { return NOMATCH; }
-        pc_s=(CHARS*)&c_test[l_test-l_len];
-      }
-      if(*pc_h=='*') {
-        /* match pc_w-pc_h somewhere in test */
-        *pc_h=0;
-        if((pc_n=(CHARS*)strstr(pc_s,pc_w))==NULL) { return NOMATCH; }
-        l_len=strlen(pc_w);
-        *pc_h='*';
-        pc_w=pc_h;
-        pc_s=pc_n+l_len;
-      }
-    }
-    if((*pc_w!='%') & (*pc_w!=*pc_s)) { return NOMATCH; }
-    pc_s++;
-    pc_w++;
-    if((*pc_s==0)&(*pc_w==0)) { return MATCH; }
-    if(*pc_s==0) {
-      if((*pc_w=='*') & (*(pc_w+1)==0)) { return MATCH; }
-      return NOMATCH;
-    }
-    if(*pc_w==0) { return NOMATCH; }
-  }
-}
diff --git a/MbsAPI/f_ut_wild.h b/MbsAPI/f_ut_wild.h
deleted file mode 100644
index d6c07f2..0000000
--- a/MbsAPI/f_ut_wild.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// $Id: f_ut_wild.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-INTS4 f_ut_wild(CHARS*, CHARS*);
diff --git a/MbsAPI/gps_sc_def.h b/MbsAPI/gps_sc_def.h
deleted file mode 100644
index 2c113bd..0000000
--- a/MbsAPI/gps_sc_def.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// $Id: gps_sc_def.h 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*********************************************************************
- *  GPS_SC_DEF.H
- *
- *  Include file MUST be EQUAL on GPS-Server, GPS-Client and SBS-Monitor
- *
- *  02-Feb-1994, RSM: file renamed from M_PAW_SC.H and def. names modified
- *
- *********************************************************************
- *  10. 3.98, H.G: implemented in Linux
- *********************************************************************
- */
-
-#ifndef GPS_SC_DEF
-#define GPS_SC_DEF
-
-#define EB__BUFFER_DATA 131072
-#define GPS__OUTBUFSIZ   16384                    /* client output buffer siz*/
-/*    bytes                */
-#define GPS__EVT_BUFSIZ  16384                    /* event buffer size for   */
-/*    spanned evt in bytes */
-#define GPS__MAXFLT         32
-#define GPS__MAXFLTDESCR    16
-#define GPS__MAXCLIENTS      6
-
-#define GPS__CLNT_SNDFLT   404                    /* (GPS__MAXFLT * 3 +
-*  5LW) * 4
-*/
-/* length in bytes!        */
-/* the filter is used in "s_client.h". For filter    */
-/* and descriptor definition see "s_filter.h", for   */
-/* length definitions "s_clntbuf.h", "s_clntoutbuf.h"*/
-
-
-/* +++++++++++++++++++++++++++++++++++++ */
-/* +++ environment of the TX partner +++ */
-/* +++++++++++++++++++++++++++++++++++++ */
-#define GPS__ENV_TESTBIT 0x00000001
-
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-/* ++ the setting of GPS__ENV_ENDIEN is implementation dependent!! ++ */
-/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
-
-/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-/* little endian (bit0 on the right side)  DEC, INTEL machines   */
-/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-#ifdef VMS          /* DEC: VMS, OpenVMS */
-#define GPS__ENV_ENDIAN  0x0
-#endif
-
-#ifdef ultrix       /* DEC Ultrix */
-#define GPS__ENV_ENDIAN  0x0
-#endif
-
-#ifdef Linux        /* Linux */
-#define GPS__ENV_ENDIAN  0x0
-#endif
-
-#ifdef GSI__WINNT       /* Windows NT */
-#define GPS__ENV_ENDIAN  0x0
-#endif
-
-#ifdef Darwin        /* Mac OS X */
-#define GPS__ENV_ENDIAN  0x0
-#endif
-
-
-
-/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-/* big endian  (bit0 on the left side)  IBM, HP, 68xxx...        */
-/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + */
-#ifdef _AIX         /* AIX */
-#define GPS__ENV_ENDIAN  0xFFFFFFFF
-#endif
-
-#ifdef HPUX         /* HP-UX */
-#define GPS__ENV_ENDIAN  0xFFFFFFFF
-#endif
-
-#ifdef Lynx         /* LynxOS */
-#define GPS__ENV_ENDIAN  0xFFFFFFFF
-#endif
-
-#ifdef Solaris        /* Sun Sparc Solaris */
-#define GPS__ENV_ENDIAN  0xFFFFFFFF
-#endif
-
-
-#endif
-
diff --git a/MbsAPI/m_histo_conv.c b/MbsAPI/m_histo_conv.c
deleted file mode 100644
index 400177f..0000000
--- a/MbsAPI/m_histo_conv.c
+++ /dev/null
@@ -1,158 +0,0 @@
-// $Id: m_histo_conv.c 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <errno.h>
-#include <ctype.h>
-#include <string.h>
-#include "f_ut_wild.h"
-#include "f_his_hist.h"
-#include "f_radware.h"
-/**************************************************************************/
-main(argc,argv)
-int argc;
-char* argv[];
-{
-  s_his_head* ps_his_head,*ps_his_head_dir;
-  INTS4 i_j,ii,l_status,l_port,l_int;
-  INTS4 l_size,l_histos=0;
-  INTS4* pl_all,*pl_dir,*pl_l;
-  REAL4* pr,*pr_l;
-  CHARS* pc;
-  CHARS c_server[32];
-  CHARS c_histo[32];
-  CHARS c_base[32];
-  CHARS c_access[32];
-  CHARS c_file[128];
-
-  if(argc < 7) {
-    printf("node port|6009 base password \"histogram\" [-print|-dir|-rad]\n");
-    exit(0);
-  }
-  l_port=atol(argv[2]);
-  strcpy(c_server,argv[1]);
-  strcpy(c_access,argv[4]);
-  strcpy(c_base,argv[3]);
-  strcpy(c_histo,argv[5]);
-
-  pl_all=NULL;
-  /* get directory ******************************************************/
-  if(strstr(argv[6],"-d") != NULL) {
-    printf("Get directory %s from server %s [%d] pass=*** base=%s\n",
-           c_histo,c_server,l_port,c_base);
-    ps_his_head_dir=NULL;
-    pl_dir=NULL;
-    l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4**)&pl_dir,(INTS4**)&l_histos);
-    if(l_status == COMM__SUCCESS) {
-      printf("Histograms: %d, slot size: %d b, Total: %d b\n",
-             l_histos,sizeof(s_his_head),l_histos*sizeof(s_his_head));
-      ps_his_head_dir = (s_his_head*)pl_dir;
-      for(i_j=0; i_j<l_histos; i_j++) {
-        if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0)
-          printf("%-31s %s %8d %8d\n",
-                 ps_his_head_dir->c_name,ps_his_head_dir->c_dtype,ps_his_head_dir->l_bins_1,ps_his_head_dir->l_bins_2);
-        ps_his_head_dir++;
-      }
-    } else { printf("Error %d\n",l_status); }
-    exit(0);
-  }
-  /* get histograms ******************************************************/
-  printf("Lookup histograms %s at server %s [%d] pass=*** base=%s\n",
-         c_histo,c_server,l_port,c_base);
-  ps_his_head_dir=NULL;
-  pl_dir=NULL;
-  l_status = f_his_getdir(c_server,l_port,c_base,c_access,c_histo,(INTS4**)&pl_dir,(INTS4**)&l_histos);
-  if(l_status != COMM__SUCCESS) {
-    printf("Error %d getting histograms %s\n",l_status,c_histo);
-    exit(0);
-  }
-  ps_his_head_dir = (s_his_head*)pl_dir;
-  for(i_j=0; i_j<l_histos; i_j++) {
-    if(f_ut_wild(ps_his_head_dir->c_name,c_histo)==0) {
-      ps_his_head=NULL;
-      pl_all=NULL;
-      l_status = f_his_gethis(c_server,l_port,c_base,c_access,ps_his_head_dir->c_name,
-                              (s_his_head**)&ps_his_head,(INTS4**)&pl_all,(INTS4**)&l_size);
-      if(l_status != COMM__SUCCESS) {
-        printf("Error %d getting histogram %s\n",l_status,ps_his_head_dir->c_name);
-        exit(0);
-      }
-
-      /* process histogram ******************************************************/
-      pl_l =         pl_all;
-      pr_l =(REAL4*)pl_all;
-      if(ps_his_head->c_dtype == 'i') { l_int=1; }
-      else { l_int=0; }
-
-      /* print histogram ******************************************************/
-      if(strstr(argv[6],"-p") != NULL) {
-        printf("Histogram %s\n",ps_his_head_dir->c_name);
-        printf("          channels: %10d, total: %10d [b], %s %8d %8d\n",
-               ps_his_head->l_bins_1*ps_his_head->l_bins_2,l_size,
-               ps_his_head->c_dtype,ps_his_head->l_bins_1,ps_his_head->l_bins_2);
-        /* print data channels */
-        if(ps_his_head->l_bins_2 == 1) {
-          for (i_j = 0; i_j < (ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6); i_j += 6) {
-            if(l_int) printf("%7d:%9d %9d %9d %9d %9d %9d\n",
-                               i_j + 1,*pl_l,*(pl_l+1),*(pl_l+2),*(pl_l+3),*(pl_l+4),*(pl_l+5));
-            else      printf("%7d:%11.4g %11.4g %11.4g %11.4g %11.4g %11.4g\n",
-                               i_j + 1,*pr_l,*(pr_l+1),*(pr_l+2),*(pr_l+3),*(pr_l+4),*(pr_l+5));
-            pl_l+=6;
-            pr_l+=6;
-          }
-          if ((ps_his_head->l_bins_1 % 6)) {
-            printf("%7d:",i_j + 1);
-            for (i_j = ps_his_head->l_bins_1 - ps_his_head->l_bins_1 % 6; i_j < ps_his_head->l_bins_1; i_j++) {
-              if(l_int) { printf("%9d ", *pl_l); }
-              else { printf("%11.4g ", *pr_l); }
-              pl_l++;
-              pr_l++;
-            }
-            printf("\n");
-          }
-        } else { printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name); }
-      }
-      /* dump radware histogram ******************************************************/
-      if(strstr(argv[6],"-r") != NULL) {
-        if(argc == 8) { strcpy(c_file,argv[7]); }
-        else { strcpy(c_file,"rad_"); }
-        strcat(c_file,ps_his_head_dir->c_name); // name from directory call includes path
-        pc=c_file;
-        for(ii=0; ii<strlen(c_file); ii++) {
-          if(*pc == '/') { *pc='-'; }
-          if(*pc == '(') { *pc='['; }
-          if(*pc == ')') { *pc=']'; }
-          if(*pc == ' ') { *pc='_'; }
-          pc++;
-        }
-        strcat(c_file,".spe");
-        if(ps_his_head->l_bins_2 == 1) {
-          if(l_int == 0) {
-            pr=(REAL4*) malloc(ps_his_head->l_bins_1*4);
-            pr_l=pr;
-            for(ii=0; ii<ps_his_head->l_bins_1; ii++) { *pr++=(REAL4)*pl_l++; }
-          }
-          l_status=f_radware_out1d(c_file,ps_his_head->c_name,pr_l,ps_his_head->l_bins_1,0);
-          if(l_status == 0) { printf("Radware histogram %s written to file %s.\n",ps_his_head_dir->c_name,c_file); }
-          else { printf("Radware histogram %s NOT written to file %s, ERROR!\n",ps_his_head_dir->c_name,c_file); }
-          if(l_int == 0) { free(pr_l); }
-        } else { printf("2d Histograms %s not supported\n",ps_his_head_dir->c_name); }
-      }
-      free(pl_all);
-    }
-    ps_his_head_dir++;
-  }
-}
-
diff --git a/MbsAPI/ml_def.h b/MbsAPI/ml_def.h
deleted file mode 100644
index 8e05b11..0000000
--- a/MbsAPI/ml_def.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// $Id: ml_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz 11-Jan-1996
- * global definitions for multi-branch multi-layer system
- */
-#define ML__N_RD_PIPE    16 /* maximal nr. of pipes a mb ml node can read */
-#define ML__N_NODE       32 /* maximal nr. nodes in mb ml (without br master */
-
-#define ML__SETUP_TAB    "ml_setup"
-#define ML__WR_PIPE_NAME "ml_write_pipe"
-#define ML__RD_PIPE_NAME "ml_read_pipe"
diff --git a/MbsAPI/mo_def.h b/MbsAPI/mo_def.h
deleted file mode 100644
index 8c56b5e..0000000
--- a/MbsAPI/mo_def.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// $Id: mo_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* N.Kurz  8-Jun-1998 */
-/* N.Kurz 30-May-2000 updated */
-
-#include "typedefs.h"
-
-#define MO__TCP_MSG_DAQSTAT 0x101
-#define MO__TCP_MSG_DATREQ  0x102
-#define MO__TCP_MSG_ACKREQ1 0x103
-#define MO__TCP_MSG_ACKREQ2 0x104
-
-#define MO__DATREQ_SIZE      12
-#define MO__ACKN1_SIZE       32
-
-#define MO__N_NODE           16
-/* maximal nr. of ds and dr nodes each in a system */
-
-#define MO__SETUP_TAB        "mo_setup"
-
-#define MO__RD_PIPE_NAME     "mo_read_pipe"
-/* generic name, will be expanded by the ds node id */
-
-#define MO__EVT_BUF_NAME     "evt_buf"
-/* intermediate event buffer                        */
-
-#define RIO2__SLAVE_VME_PIPE_OFF  0x200000
-#define RIO2__SLAVE_VME_WIN_SIZE  0x1000000
-#define RIO2__PCI_OFFSET          0x80000000
-
-
-#define DLEB__TCP_INFO      0x201
-#define DLEB__INFO_SIZE       12
-#define DLEB__CONNECT_RETRY   5
diff --git a/MbsAPI/portnum_def.h b/MbsAPI/portnum_def.h
index 73bf989..6ebbf93 100644
--- a/MbsAPI/portnum_def.h
+++ b/MbsAPI/portnum_def.h
@@ -1,16 +1,10 @@
-// $Id: portnum_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "typedefs.h"
 /*
  *   definitons of the port numbers used
diff --git a/MbsAPI/sMbs.h b/MbsAPI/sMbs.h
index 5f43aa4..3ff35e2 100644
--- a/MbsAPI/sMbs.h
+++ b/MbsAPI/sMbs.h
@@ -1,16 +1,10 @@
-// $Id: sMbs.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum f�r Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef MbsStruct
 #define MbsStruct
 
diff --git a/MbsAPI/s_bufhe.h b/MbsAPI/s_bufhe.h
index edea112..34f7efc 100644
--- a/MbsAPI/s_bufhe.h
+++ b/MbsAPI/s_bufhe.h
@@ -1,15 +1,10 @@
-// $Id: s_bufhe.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 
 #ifndef S_BUFHE
 #define S_BUFHE
diff --git a/MbsAPI/s_bufhe_swap.h b/MbsAPI/s_bufhe_swap.h
index e68ff1c..4b88631 100644
--- a/MbsAPI/s_bufhe_swap.h
+++ b/MbsAPI/s_bufhe_swap.h
@@ -1,16 +1,10 @@
-// $Id: s_bufhe_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef F_BUFHE_SWAP
 #define F_BUFHE_SWAP
 
diff --git a/MbsAPI/s_clnt_filter.h b/MbsAPI/s_clnt_filter.h
deleted file mode 100644
index 597707a..0000000
--- a/MbsAPI/s_clnt_filter.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// $Id: s_clnt_filter.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* filter structure for CLIENT */
-
-#ifndef S_CINT_FILTER
-#define S_CINT_FILTER
-
-struct s_clnt_filter {
-  /* --- control byte ordering and machine type (2LW) ---- */
-  unsigned int          l_testbit;       /* bit pattern               */
-  unsigned int          l_endian;        /* endian of sender          */
-  /*  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
-  int                   l_numb_of_evt;   /* numb of events to send    */
-  int                   l_sample_rate;   /* flt match sample rate     */
-  int                   l_flush_rate;    /* buffer flushing rate [sec]*/
-  struct s_filter        filter[GPS__MAXFLT];/* 32 filter express (à 3LW) */
-  struct s_flt_descr     flt_descr[GPS__MAXFLTDESCR]; /* Filter descriptor*/
-  short unsigned         if_fltevt;      /* filter on event            */
-  short unsigned         if_fltsev;      /* filter on subevent         */
-  short unsigned         if_wrtevt;      /* write whole event          */
-  short unsigned         if_wrtsev;      /* write subevts (numb of sev)*/
-};
-
-#endif
diff --git a/MbsAPI/s_clnt_filter_swap.h b/MbsAPI/s_clnt_filter_swap.h
deleted file mode 100644
index 41c02a2..0000000
--- a/MbsAPI/s_clnt_filter_swap.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// $Id: s_clnt_filter_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* filter structure for CLIENT */
-
-struct s_clnt_filter {
-  /* -------> Swapped <-------- */
-  /* --------=========--------- */
-  /* --- control byte ordering and machine type (2LW) ---- */
-  unsigned long          l_testbit;       /* bit pattern               */
-  unsigned long          l_endian;        /* endian of sender          */
-  /*  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
-  long                   l_numb_of_evt;   /* numb of events to send    */
-  long                   l_sample_rate;   /* flt match sample rate     */
-  long                   l_flush_rate;    /* buffer flushing rate [sec]*/
-  struct s_filter        filter[GPS__MAXFLT];/* 32 filter express (à 3LW) */
-  struct s_flt_descr     flt_descr[GPS__MAXFLTDESCR]; /* Filter descriptor*/
-  short unsigned         if_fltsev;      /* filter on subevent         */
-  short unsigned         if_fltevt;      /* filter on event            */
-  short unsigned         if_wrtsev;      /* write subevts (numb of sev)*/
-  short unsigned         if_wrtevt;      /* write whole event          */
-};
diff --git a/MbsAPI/s_clntbuf.h b/MbsAPI/s_clntbuf.h
deleted file mode 100644
index b751e85..0000000
--- a/MbsAPI/s_clntbuf.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// $Id: s_clntbuf.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*************************************************************************/
-/* +++ GSI Darmstadt                                                 +++ */
-/* +++                                                               +++ */
-/*************************************************************************/
-/*+File name        S_CLNTBUF.H                                          */
-/*                                                                       */
-/*************************************************************************/
-/*+    Update       Date          Purpose                                */
-/*-                 10-Dec-1993 : Define testbit and low or high endian  */
-/*                                and some types changed and 2LW added   */
-/*-                 27-Jan-1994 : CLNT_BUFH_LW changed to  11  (RSM)     */
-/*-                 02-Feb-1994 : definitions in CLNT_BUF_DEF.H ,        */
-/*                                def. names changed. (RSM)              */
-/*************************************************************************/
-
-/* RSM 19-MAR-1993      */
-/* is a part of s_clntoutbuf */
-
-struct s_clntbuf {
-  /* ------ first part of s_clntoutbuf omitted ----------- */
-  /* --- control byte ordering and machine type (2LW) ---- */
-  unsigned int   l_testbit;              /* bit pattern                */
-  unsigned int   l_endian;               /* endian of sender           */
-  /* ----------------------------------------------------- */
-  /* ----- length is CLNT__BUFHEAD ----------------------- */
-  int            l_dlen;                 /* data length [bytes]        */
-  int            l_free;                 /* free  length [bytes]       */
-  int            l_events;               /* events in buffer           */
-  int            l_maxbufsiz;            /* maximum buffer size        */
-  int            l_bytestosnd;           /* sent bytes                 */
-  int            l_numbuftosnd;          /* number of buffers to send  */
-  int            l_client_con;           /* currently connect clients  */
-  int  unsigned  l_buffertype;           /* type: data:1 msg:2 flush:4 */
-  /*       last:8 1stBUF:16     */
-  /* (inclusive) (mask)         */
-  int  unsigned  l_msgtyp;               /* I:1 W:2 E:4 F:8 (exclusive)*/
-  char            c_message[CLNT__MSGLEN]; /* error msg and other        */
-  /* ----- part of s_control structure ------------------- */
-  /* ----- length is CLNT__INFO_CONTROL ------------------ */
-  int unsigned  l_inbuf_read_cnt; /* count read buffer              */
-  int unsigned  l_inbuf_rdok_cnt; /* count read buffer that are o.k */
-  int unsigned  l_inbuf_skip_cnt; /* count skipped buffer           */
-  int unsigned  l_inbuf_byrd_cnt; /* count read bytes               */
-  int unsigned  l_inbuf_proc_cnt; /* count processed buffer         */
-  int unsigned  l_inbuf_prev_cnt; /* count processed events         */
-  /* ----- part of s_client structure -------------------- */
-  /* ----- length is CLNT__INFO_CLIENT ------------------- */
-  int unsigned          l_clntoutbuf_sdev; /* sent events             */
-  int unsigned          l_clntoutbuf_sdby; /* sent bytes              */
-  int unsigned          l_clntoutbuf_sdbf; /* sent buffer             */
-  int unsigned          l_clntoutbuf_prev; /* processed evt since con */
-  int unsigned          l_clntoutbuf_fltm; /* filter matched on evt   */
-  /* ----------------------------------------------------------------- */
-  char            c_buffer[GPS__OUTBUFSIZ];
-};
diff --git a/MbsAPI/s_daqst.h b/MbsAPI/s_daqst.h
deleted file mode 100644
index 2797d3b..0000000
--- a/MbsAPI/s_daqst.h
+++ /dev/null
@@ -1,145 +0,0 @@
-#include "typedefs.h"
-/*
- * N. Kurz
- * daq status structure
- * sorted for better byte swap  /HE
- * 30.05.2000 replaced run_start by histo_port /HE
- * 25.10.2005 added spill, event building, and pipe status /HE
- * 23.6.2008 DABC support /HE
- */
-
-/* After allocating s_daqst, set by calling f_ut_status_ini */
-/* ps_daqst->l_endian   = 1;                      */
-/* ps_daqst->l_version  = n;                      */
-/* ps_daqst->l_daqst_lw = sizeof(s_daqst)/4;      */
-/* ps_daqst->l_fix_lw  = ((int)&c_pname[0][0]-(int)ps_daqst)/4; */
-/* ps_daqst->l_sys__n_max_procs =  SYS__N_MAX_PROCS; */
-/* ps_daqst->l_sbs__str_len_64 =   SBS__STR_LEN_64;  */
-/* ps_daqst->l_sbs__n_trg_typ =    SBS__N_TRG_TYP;   */
-
-typedef struct {
-  INTU4 l_endian;                    /* set to 1 if sent */
-  INTU4 l_version;                   /* increment in f_ut_status_ini after changes */
-  INTU4 l_daqst_lw;                  /* sizeof(s_daqst)/4 : number of lw */
-  INTU4 l_fix_lw;                    /* (&c_pname-ps_daqst)/4 : fix number of longwords to read */
-  INTU4 l_sys__n_max_procs;          /* maximum number of processes */
-  INTU4 l_sbs__str_len_64;           /* String length of process names */
-  INTU4 l_sbs__n_trg_typ;            /* maximum number of triggers */
-  INTU4 bh_daqst_initalized;         /* crea_daqst */
-  INTU4 bh_acqui_started;            /* util(f_ut_op_trig_mod), read_cam_slav, read_meb */
-  INTU4 bh_acqui_running;            /* collector, read_cam_slav, read_meb  */
-  INTU4 l_procs_run;                 /* processes running (index in l_pid) */
-  INTU4 bh_setup_loaded;             /* util(f_ut_load_setup) */
-  INTU4 bh_set_ml_loaded;            /* util(f_ut_load_ml_setup) */
-  INTU4 bh_set_mo_loaded;            /* util(f_ut_load_mo_setup) */
-  INTU4 bh_cam_tab_loaded;           /* read_cam_slav, read_meb) */
-  INTS4 l_free_streams;              /* transport */
-  INTU4 bl_n_events;                 /* collector */
-  INTU4 bl_n_buffers;                /* collector f_col_format */
-  INTU4 bl_n_bufstream;              /* transport */
-  INTU4 bl_n_kbyte;                  /* transport */
-  INTU4 bl_n_evserv_events;          /* event_serv f_ev_checkevt  */
-  INTU4 bl_n_evserv_kbytes;          /* event_serv f_ev_send */
-  INTU4 bl_n_strserv_bufs;           /* stream_serv  */
-  INTU4 bl_n_strserv_kbytes;         /* stream_serv  */
-  INTU4 bl_n_kbyte_tape;             /* transport  */
-  INTU4 bl_n_kbyte_file;             /* transport */
-  INTU4 bl_r_events;                 /* rate  */
-  INTU4 bl_r_buffers;                /* rate  */
-  INTU4 bl_r_bufstream;              /* rate */
-  INTU4 bl_r_kbyte;                  /* rate  */
-  INTU4 bl_r_kbyte_tape;             /* rate  (from l_block_count) */
-  INTU4 bl_r_evserv_events;          /* rate */
-  INTU4 bl_r_evserv_kbytes;          /* rate  */
-  INTU4 bl_r_strserv_bufs;           /* rate  */
-  INTU4 bl_r_strserv_kbytes;         /* rate */
-  INTU4 bl_flush_time;               /* stream flush time                */
-  INTS4 l_pathnum;                   /* path number of open device */
-  INTU4 l_block_length;              /* current block length */
-  INTU4 l_pos_on_tape;               /* current tape position in kB */
-  INTU4 l_max_tape_size;             /* maximal tape length in kB */
-  INTU4 l_file_count;                /* file count on volume */
-  INTU4 l_file_auto;                 /* file count on volume */
-  INTU4 l_file_cur;                  /* file count on volume */
-  INTU4 l_file_size;                 /* file size */
-  INTU4 l_block_count;               /* buffers on file */
-  INTU4 l_block_size;                /* block size (=buffer) in bytes */
-  INTU4 l_record_size;               /* record size on bytes */
-  INTS4 l_open_vol;                  /* open mode of volume */
-  INTS4 l_open_file;                 /* open  file flag */
-  INTS4 l_rate_on;                   /* for m_daq_rate */
-  INTS4 l_rate_sec;                  /* for m_daq_rate */
-  INTU4 bh_trig_master;              /* util(f_ut_op_trig_mod) */
-  INTU4 bh_histo_enable;             /* collector */
-  INTU4 bh_histo_ready;              /* collector */
-  INTU4 bh_ena_evt_copy;             /* collector */
-  INTU4 bl_n_trig[SBS__N_TRG_TYP];   /* Trigger counter (read_cam_slav or read_meb) */
-  INTU4 bl_n_si  [SBS__N_TRG_TYP];   /* Invalid subevents (collector) */
-  INTU4 bl_n_evt [SBS__N_TRG_TYP];   /* Valid triggers (collector) */
-  INTU4 bl_r_trig[SBS__N_TRG_TYP];   /* Rate Trigger counter (read_cam_slav or read_meb) */
-  INTU4 bl_r_si  [SBS__N_TRG_TYP];   /* Rate Invalid subevents (collector) */
-  INTU4 bl_r_evt [SBS__N_TRG_TYP];   /* Rate Valid triggers (collector) */
-  INTU4 bh_running[SYS__N_MAX_PROCS];/* run bit for tasks */
-  INTU4 l_pid[SYS__N_MAX_PROCS];     /* pid table */
-  INTU4 l_type[SYS__N_MAX_PROCS];    /* Type number defined in sys_def.h */
-  INTS4 l_pprio[SYS__N_MAX_PROCS];   /* daq processes priority */
-  /*   f_ut_init_daq_proc,  */
-  /*   f_ut_clear_daqst,    */
-  /*   f_ut_exit_daq_proc,  */
-  /*   f_ut_show_acq,       */
-  /*   dispatch,            */
-  /*   prompt               */
-  /*   tasks                */
-  INTU4 bh_pact[SYS__N_MAX_PROCS];   /* daq processes, 1 = active, as pprio */
-  INTU4 bh_verbose_flg;              /* */
-  INTU4 bl_histo_port;                /* not used */
-  INTU4 bl_run_time;                 /* not used */
-  INTS4 l_irq_driv_id;               /* 0=irq driver/device not installed */
-  INTS4 l_irq_maj_dev_id;            /*            "="                    */
-  INTU4 bh_event_serv_ready;         /* event_serv, stream_serv */
-  INTU4 bl_strsrv_scale;             /* stream server */
-  INTU4 bl_strsrv_sync;              /* stream server  */
-  INTU4 bl_strsrv_nosync;            /* stream server  */
-  INTU4 bl_strsrv_keep;              /* stream server  */
-  INTU4 bl_strsrv_nokeep;            /* stream server  */
-  INTU4 bl_strsrv_scaled;            /* stream server  */
-  INTU4 bl_evtsrv_scale;             /* event server  */
-  INTU4 bl_evtsrv_events;            /* event server  */
-  INTU4 bl_evtsrv_maxcli;            /* event server  */
-  INTU4 bl_evtsrv_all;               /* event server  */
-  INTU4 bl_esosrv_maxcli;            /* esone server  */
-  INTU4 bl_pipe_slots;               /* sub event slots in readout pipe */
-  INTU4 bl_pipe_slots_filled;        /* sub event slots used */
-  INTU4 bl_pipe_size_KB;             /* readout pipe size */
-  INTU4 bl_pipe_filled_KB;           /* readout pipe size occupied */
-  INTU4 bl_spill_on;                 /* Spill on/off */
-  INTU4 bl_delayed_eb_ena;           /* Delayed event building enabled/disab.*/
-  INTU4 bl_event_build_on;           /* Event building on/off */
-  INTU4 bl_dabc_enabled;             /* DABC event builder mode off/on */
-  INTU4 bl_trans_ready;              /* transport server ready */
-  INTU4 bl_trans_connected;          /* Client to transport connected */
-  INTU4 bl_no_streams;               /* Number of streams */
-  INTU4 bl_user[16];                /* for user */
-  INTU4 bl_filler[190];              /* filler */
-  INTU4 bl_no_stream_buf;             /* bufs per stream */
-  INTU4 bl_rfio_connected;           /* RFIO connected */
-  CHARS c_user[SBS__STR_LEN_64];     /* username */
-  CHARS c_date[SBS__STR_LEN_64];     /* date of last update (m_daq_rate) */
-  CHARS c_exprun[SBS__STR_LEN_64];   /* run name */
-  CHARS c_exper[SBS__STR_LEN_64];    /* experiment */
-  CHARS c_host[SBS__STR_LEN_64];           /* name of host */
-  CHARS c_remote[SBS__STR_LEN_64];         /* name of remote control node */
-  CHARS c_display[SBS__STR_LEN_64];         /* name of remote display node */
-  CHARS c_anal_segm_name[SBS__STR_LEN_64]; /* name of histogram segment in use */
-  /* by f_his_anal() in m_collector   */
-  CHARS c_setup_name[SBS__STR_LEN_64];     /* setup table loaded */
-  CHARS c_ml_setup_name[SBS__STR_LEN_64];  /* ml setup table loaded */
-  CHARS c_readout_name[SBS__STR_LEN_64];   /* readout table loaded */
-  CHARS c_pathstr[SBS__STR_LEN_64];        /* path string */
-  CHARS c_devname[SBS__STR_LEN_64];        /* Name of tape device */
-  CHARS c_tape_label[SBS__STR_LEN_64];     /* current tape label */
-  CHARS c_file_name[256];                  /* current file name */
-  CHARS c_out_chan[SBS__STR_LEN_64];       /* active ouput media */
-  /* ------------------ end of fixed block --------------------------*/
-  CHARS c_pname[SYS__N_MAX_PROCS][SBS__STR_LEN_64]; /* as pprio */
-} s_daqst;
diff --git a/MbsAPI/s_daqst_v2.h b/MbsAPI/s_daqst_v2.h
deleted file mode 100644
index 2151755..0000000
--- a/MbsAPI/s_daqst_v2.h
+++ /dev/null
@@ -1,146 +0,0 @@
-// $Id: s_daqst.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz
- * daq status structure
- * sorted for better byte swap  /HE
- * 30.05.2000 replaced run_start by histo_port /HE
- * 25.10.2005 added spill, event building, and pipe status /HE
- */
-
-/* After allocating s_daqst, set by calling f_ut_status_ini */
-/* ps_daqst->l_endian   = 1;                      */
-/* ps_daqst->l_version  = n;                      */
-/* ps_daqst->l_daqst_lw = sizeof(s_daqst)/4;      */
-/* ps_daqst->l_fix_lw  = ((int)&c_pname[0][0]-(int)ps_daqst)/4; */
-/* ps_daqst->l_sys__n_max_procs =  SYS__N_MAX_PROCS; */
-/* ps_daqst->l_sbs__str_len_64 =   SBS__STR_LEN_64;  */
-/* ps_daqst->l_sbs__n_trg_typ =    SBS__N_TRG_TYP;   */
-
-typedef struct {
-  INTU4 l_endian;                    /* set to 1 if sent */
-  INTU4 l_version;                   /* increment in f_ut_status_ini after changes */
-  INTU4 l_daqst_lw;                  /* sizeof(s_daqst)/4 : number of lw */
-  INTU4 l_fix_lw;                    /* (&c_pname-ps_daqst)/4 : fix number of longwords to read */
-  INTU4 l_sys__n_max_procs;          /* maximum number of processes */
-  INTU4 l_sbs__str_len_64;           /* String length of process names */
-  INTU4 l_sbs__n_trg_typ;            /* maximum number of triggers */
-  INTU4 bh_daqst_initalized;         /* crea_daqst */
-  INTU4 bh_acqui_started;            /* util(f_ut_op_trig_mod), read_cam_slav, read_meb */
-  INTU4 bh_acqui_running;            /* collector, read_cam_slav, read_meb  */
-  INTU4 l_procs_run;                 /* processes running (index in l_pid) */
-  INTU4 bh_setup_loaded;             /* util(f_ut_load_setup) */
-  INTU4 bh_set_ml_loaded;            /* util(f_ut_load_ml_setup) */
-  INTU4 bh_set_mo_loaded;            /* util(f_ut_load_mo_setup) */
-  INTU4 bh_cam_tab_loaded;           /* read_cam_slav, read_meb) */
-  INTS4 l_free_streams;              /* transport */
-  INTU4 bl_n_events;                 /* collector */
-  INTU4 bl_n_buffers;                /* collector f_col_format */
-  INTU4 bl_n_bufstream;              /* transport */
-  INTU4 bl_n_kbyte;                  /* transport */
-  INTU4 bl_n_evserv_events;          /* event_serv f_ev_checkevt  */
-  INTU4 bl_n_evserv_kbytes;          /* event_serv f_ev_send */
-  INTU4 bl_n_strserv_bufs;           /* stream_serv  */
-  INTU4 bl_n_strserv_kbytes;         /* stream_serv  */
-  INTU4 bl_n_kbyte_tape;             /* transport  */
-  INTU4 bl_n_kbyte_file;             /* transport */
-  INTU4 bl_r_events;                 /* rate  */
-  INTU4 bl_r_buffers;                /* rate  */
-  INTU4 bl_r_bufstream;              /* rate */
-  INTU4 bl_r_kbyte;                  /* rate  */
-  INTU4 bl_r_kbyte_tape;             /* rate  (from l_block_count) */
-  INTU4 bl_r_evserv_events;          /* rate */
-  INTU4 bl_r_evserv_kbytes;          /* rate  */
-  INTU4 bl_r_strserv_bufs;           /* rate  */
-  INTU4 bl_r_strserv_kbytes;         /* rate */
-  INTU4 bl_flush_time;               /* stream flush time                */
-  INTS4 l_pathnum;                   /* path number of open device */
-  INTU4 l_block_length;              /* current block length */
-  INTU4 l_pos_on_tape;               /* current tape position in kB */
-  INTU4 l_max_tape_size;             /* maximal tape length in kB */
-  INTU4 l_file_count;                /* file count on volume */
-  INTU4 l_file_auto;                 /* file count on volume */
-  INTU4 l_file_cur;                  /* file count on volume */
-  INTU4 l_file_size;                 /* file size */
-  INTU4 l_block_count;               /* buffers on file */
-  INTU4 l_block_size;                /* block size (=buffer) in bytes */
-  INTU4 l_record_size;               /* record size on bytes */
-  INTS4 l_open_vol;                  /* open mode of volume */
-  INTS4 l_open_file;                 /* open  file flag */
-  INTS4 l_rate_on;                   /* for m_daq_rate */
-  INTS4 l_rate_sec;                  /* for m_daq_rate */
-  INTU4 bh_trig_master;              /* util(f_ut_op_trig_mod) */
-  INTU4 bh_histo_enable;             /* collector */
-  INTU4 bh_histo_ready;              /* collector */
-  INTU4 bh_ena_evt_copy;             /* collector */
-  INTU4 bl_n_trig[SBS__N_TRG_TYP];   /* Trigger counter (read_cam_slav or read_meb) */
-  INTU4 bl_n_si  [SBS__N_TRG_TYP];   /* Invalid subevents (collector) */
-  INTU4 bl_n_evt [SBS__N_TRG_TYP];   /* Valid triggers (collector) */
-  INTU4 bh_running[SYS__N_MAX_PROCS];/* run bit for tasks */
-  INTU4 l_pid[SYS__N_MAX_PROCS];     /* pid table */
-  INTU4 l_type[SYS__N_MAX_PROCS];    /* Type number defined in sys_def.h */
-  INTS4 l_pprio[SYS__N_MAX_PROCS];   /* daq processes priority */
-  /*   f_ut_init_daq_proc,  */
-  /*   f_ut_clear_daqst,    */
-  /*   f_ut_exit_daq_proc,  */
-  /*   f_ut_show_acq,       */
-  /*   dispatch,            */
-  /*   prompt               */
-  /*   tasks                */
-  INTU4 bh_pact[SYS__N_MAX_PROCS];   /* daq processes, 1 = active, as pprio */
-  INTU4 bh_verbose_flg;              /* */
-  INTU4 bl_histo_port;                /* not used */
-  INTU4 bl_run_time;                 /* not used */
-  INTS4 l_irq_driv_id;               /* 0=irq driver/device not installed */
-  INTS4 l_irq_maj_dev_id;            /*            "="                    */
-  INTU4 bh_event_serv_ready;         /* event_serv, stream_serv */
-  INTU4 bl_strsrv_scale;             /* stream server */
-  INTU4 bl_strsrv_sync;              /* stream server  */
-  INTU4 bl_strsrv_nosync;            /* stream server  */
-  INTU4 bl_strsrv_keep;              /* stream server  */
-  INTU4 bl_strsrv_nokeep;            /* stream server  */
-  INTU4 bl_strsrv_scaled;            /* stream server  */
-  INTU4 bl_evtsrv_scale;             /* event server  */
-  INTU4 bl_evtsrv_events;            /* event server  */
-  INTU4 bl_evtsrv_maxcli;            /* event server  */
-  INTU4 bl_evtsrv_all;               /* event server  */
-  INTU4 bl_esosrv_maxcli;            /* esone server  */
-  INTU4 bl_pipe_slots;               /* sub event slots in readout pipe */
-  INTU4 bl_pipe_slots_filled;        /* sub event slots used */
-  INTU4 bl_pipe_size_KB;             /* readout pipe size */
-  INTU4 bl_pipe_filled_KB;           /* readout pipe size occupied */
-  INTU4 bl_spill_on;                 /* Spill on/off */
-  INTU4 bl_delayed_eb_ena;           /* Delayed event building enabled/disab.*/
-  INTU4 bl_event_build_on;           /* Event building on/off */
-  CHARS c_user[SBS__STR_LEN_64];     /* username */
-  CHARS c_date[SBS__STR_LEN_64];     /* date of last update (m_daq_rate) */
-  CHARS c_exprun[SBS__STR_LEN_64];   /* run name */
-  CHARS c_exper[SBS__STR_LEN_64];    /* experiment */
-  CHARS c_host[SBS__STR_LEN_64];           /* name of host */
-  CHARS c_remote[SBS__STR_LEN_64];         /* name of remote control node */
-  CHARS c_display[SBS__STR_LEN_64];         /* name of remote display node */
-  CHARS c_anal_segm_name[SBS__STR_LEN_64]; /* name of histogram segment in use */
-  /* by f_his_anal() in m_collector   */
-  CHARS c_setup_name[SBS__STR_LEN_64];     /* setup table loaded */
-  CHARS c_ml_setup_name[SBS__STR_LEN_64];  /* ml setup table loaded */
-  CHARS c_readout_name[SBS__STR_LEN_64];   /* readout table loaded */
-  CHARS c_pathstr[SBS__STR_LEN_64];        /* path string */
-  CHARS c_devname[SBS__STR_LEN_64];        /* Name of tape device */
-  CHARS c_tape_label[SBS__STR_LEN_64];     /* current tape label */
-  CHARS c_file_name[SBS__STR_LEN_64];      /* current file name */
-  CHARS c_out_chan[SBS__STR_LEN_64];       /* active ouput media */
-  /* ------------------ end of fixed block --------------------------*/
-  CHARS c_pname[SYS__N_MAX_PROCS][SBS__STR_LEN_64]; /* as pprio */
-} s_daqst;
diff --git a/MbsAPI/s_endian.h b/MbsAPI/s_endian.h
deleted file mode 100644
index 40b2150..0000000
--- a/MbsAPI/s_endian.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// $Id: s_endian.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_ENDIAN_HEADER
-#define S_ENDIAN_HEADER
-
-
-#endif
diff --git a/MbsAPI/s_errstat.h b/MbsAPI/s_errstat.h
deleted file mode 100644
index 2290713..0000000
--- a/MbsAPI/s_errstat.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// $Id: s_errstat.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef __S_ERRSTAT__
-#define __S_ERRSTAT__
-
-#include "typedefs.h"
-/*  s_errstat.h
- *  ===========
- *  purpose        : structure for f_ut_error control
- *  date           : 22-Nov-1994
- *  author         : R.S. Mayer
- *
- *  update         : 12-Jan-1995: Message log flag /RSM
- *
- */
-
-struct s_errstat {
-  INTS4          if_verbose;
-  INTS4          if_msglog;
-  CHARS         c_taskname[16];
-};
-
-#endif
diff --git a/MbsAPI/s_evhe.h b/MbsAPI/s_evhe.h
index 4b37de4..ae9228c 100644
--- a/MbsAPI/s_evhe.h
+++ b/MbsAPI/s_evhe.h
@@ -1,15 +1,11 @@
-// $Id: s_evhe.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+
 
 #ifndef S_EVHE
 #define S_EVHE
diff --git a/MbsAPI/s_evhe_swap.h b/MbsAPI/s_evhe_swap.h
index cc1c7e1..949b0eb 100644
--- a/MbsAPI/s_evhe_swap.h
+++ b/MbsAPI/s_evhe_swap.h
@@ -1,16 +1,10 @@
-// $Id: s_evhe_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_EVHE_SWAP
 #define S_EVHE_SWAP
 
diff --git a/MbsAPI/s_filhe.h b/MbsAPI/s_filhe.h
index 1f12b98..cbe299a 100644
--- a/MbsAPI/s_filhe.h
+++ b/MbsAPI/s_filhe.h
@@ -1,15 +1,10 @@
-// $Id: s_filhe.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 
 #ifndef S_FILHE
 #define S_FILHE
diff --git a/MbsAPI/s_filhe_swap.h b/MbsAPI/s_filhe_swap.h
index 038649d..5e4cbed 100644
--- a/MbsAPI/s_filhe_swap.h
+++ b/MbsAPI/s_filhe_swap.h
@@ -1,15 +1,10 @@
-// $Id: s_filhe_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 
 #ifndef S_FILHE_SWAP
 #define S_FILHE_SWAP
diff --git a/MbsAPI/s_filter.h b/MbsAPI/s_filter.h
deleted file mode 100644
index c7aa747..0000000
--- a/MbsAPI/s_filter.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// $Id: s_filter.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_FILTER
-#define S_FILTER
-
-#include "typedefs.h"
-/* +++ s_filter.h +++
- * client structure for SBS monitor
- * (see also s_filter.h for GPS-Server on (Open)VMS / clients)
- * R.S. Mayer
- * 18-Feb-1994
-*/
-struct s_filter {
-  INTU4          l_pattern;
-  INTS4          l_offset;       /* offset >0: LW  <0: Words     */
-  INTU4          l_opcode;
-};
-
-#endif
diff --git a/MbsAPI/s_flt_descr.h b/MbsAPI/s_flt_descr.h
deleted file mode 100644
index 485fe2c..0000000
--- a/MbsAPI/s_flt_descr.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// $Id: s_flt_descr.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* filter descriptor */
-struct s_flt_descr {
-  char                   hf_wrtdescr;   /* write descriptor          */
-  char                   hf_fltdescr;       /* filter descriptor         */
-  /* indices to filter[]  */
-  char                   h_fltblkbeg;   /* begin filter block        */
-  char                   h_fltblkend;       /* end filter block          */
-  /* index to flt_descr[] */
-  char                   h_nextdescr;       /* next descriptor           */
-  char                   h_dummy;
-  short                  i_descriptors;     /* number of descriptors     */
-};
-
diff --git a/MbsAPI/s_flt_descr_swap.h b/MbsAPI/s_flt_descr_swap.h
deleted file mode 100644
index c851d8b..0000000
--- a/MbsAPI/s_flt_descr_swap.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// $Id: s_flt_descr_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* filter descriptor */
-/* -------> Swapped <-------- */
-/* --------=========--------- */
-struct s_flt_descr {
-  /* indices to filter[]  */
-  char                   h_fltblkend;       /* end filter block          */
-  char                   h_fltblkbeg;   /* begin filter block        */
-  char                   hf_fltdescr;       /* filter descriptor         */
-  char                   hf_wrtdescr;   /* write descriptor          */
-  /* index to flt_descr[] */
-  short                  i_descriptors;     /* number of descriptors     */
-  char                   h_dummy;
-  char                   h_nextdescr;       /* next descriptor           */
-};
diff --git a/MbsAPI/s_head.h b/MbsAPI/s_head.h
deleted file mode 100644
index 9a92f50..0000000
--- a/MbsAPI/s_head.h
+++ /dev/null
@@ -1,74 +0,0 @@
-// $Id: s_head.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/* s_head.h
- * ========
- * Purpose      : Histogram manager for SBS
- * Author       : Ilya Kuznetsov
- * Date         : 20-Sep-1994
- *
- * Modification : 11-Oct-1994 : Version number/RSM
- * Modification : 12-Oct-1994 : Text string/RSM
- * Modification : 10-Nov-1994 : flags for attach, detach etc. ??? /RSM
- * Modification : 15-Nov-1994 : Top-Slot-Index for name sort. /RSM
- * Modification : 22-Nov-1994 : Insertion of s_errstat with flag /RSM
- * Modification : 24-Jan-1995 : Identifier for histogram base /RSM
- * Modification : 24-Jul-1997 : Insert date /HE
- * Modification : 25-Aug-1999 : Insert counters /HE
- * Modification : 20-Jun-2001 : Insert autosave /HE
- */
-
-#ifndef __S_ERRSTAT__
-#include "s_errstat.h"
-#endif
-
-typedef struct {
-  INTS4 l_endian;        /*  1 the length of the memory big piece     */
-  INTS4 l_len;           /*  2 the length of the memory big piece     */
-  INTS4 l_free;          /*  3 free room in that funny memory piece   */
-  INTU4 ul_ofree;        /*  4 offset of the free room beginning      */
-  INTS4 i_slot;          /*  5 no. of the funny slots requested       */
-  INTS4 i_sfree;         /*  6 no. of the free funny slots            */
-  INTS4 i_topslot;       /*  7 slot with first alphabetic name        */
-  INTU4 ui_idbase;       /*  8 Identifier for a histogram base        */
-  INTU4 l_version;       /*  9 version number for analysis check      */
-  INTU4 l_segment;       /* 10 segment number                         */
-  INTS4 bh_histogram;
-  INTS4 bh_anal;
-  INTS4 bh_lock;         /*    lock flag                     */
-  INTS4 bh_free2;        /* 14                               */
-  INTU4 l_events;        /* 15                               */
-  INTU4 l_out_evts;      /* 16                               */
-  INTU4 l_Lwords;        /* 17                               */
-  INTU4 l_event_r;       /* 18                               */
-  INTU4 l_kbyte_r;       /* 19                               */
-  INTS4 l_running;       /* 20                               */
-  REAL4 r_x1;            /* 21                               */
-  REAL4 r_y1;            /* 22                               */
-  REAL4 r_x2;            /* 23                               */
-  REAL4 r_y2;            /* 24                               */
-  struct s_errstat s_errstat_1;    /* 30 control block for f_error    */
-  CHARS c_date[28];      /* 37 creation date                          */
-  CHARS c_ident[32];     /* 45 process identification string          */
-  CHARS c_shsegname[32]; /* 53 shared segment name string             */
-  INTS4 l_points;        /* 54 number of polygon points                  */
-  REAL4 r_x[32];         /* 86 x coordinates                             */
-  REAL4 r_y[32];         /* 118 y coordinates                             */
-  INTS4 l_cond_win;      /* 119 numer of window conditions */
-  INTS4 l_cond_pol;      /* 120 numer of polygon conditions */
-  INTS4 l_params;        /* 121 number of valid parameters in IDL exchange buffer */
-  INTS4 l_param_type;    /* 122 meaning of parameters in IDL exchange buffer */
-  INTS4 l_auto_sec;      /* 123 seconds till next autosave (0 is no autosave)          */
-  INTS4 l_spare[5];      /* 5 spare                                  */
-} s_head;
diff --git a/MbsAPI/s_his_comm.h b/MbsAPI/s_his_comm.h
deleted file mode 100644
index 27821fd..0000000
--- a/MbsAPI/s_his_comm.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// $Id: s_his_comm.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_HIS_COMM
-#define S_HIS_COMM
-
-#include "typedefs.h"
-
-#define COMM__PORT     6009
-#define COMM__GETDIR   1
-#define COMM__GETHIST  2
-#define COMM__PUTDIR   3
-#define COMM__PUTHIST  4
-#define COMM__EXIT     5
-#define COMM__GETBASE  6
-#define COMM__PUTBASE  7
-#define COMM__SUCCESS  0
-#define COMM__ERROR    -1
-#define COMM__NOACCESS -2
-#define COMM__NOBASE   -3
-#define COMM__NOSERVER -4
-#define COMM__NOHIST   -5
-
-/* structure for communication between histogram server and client */
-typedef struct {
-  INTU4 lu_endian;    /* set = 1 by sender, checked by receiver */
-  INTU4 lu_action;    /* what to do, defined by COM__xxx        */
-  INTU4 lu_histos;    /* returned number of histograms                   */
-  INTU4 lu_size;      /* returned number of bytes of following buffer    */
-  INTS4 l_status;     /* completion status, COMM_xxx        */
-  CHARS c_access[32]; /* password depending on server       */
-  CHARS c_base[32];   /* base name depending on server      */
-  CHARS c_histo[64];  /* histogram name                     */
-} s_his_comm;
-
-#endif
diff --git a/MbsAPI/s_his_head.h b/MbsAPI/s_his_head.h
deleted file mode 100644
index ba4854f..0000000
--- a/MbsAPI/s_his_head.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// $Id: s_his_head.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_HIS_HEAD
-#define S_HIS_HEAD
-
-#include "typedefs.h"
-
-/* histogram header sent by histogram server */
-typedef struct {
-  INTS4 l_bins_1;               /* number of bins in dim=1        */
-  INTS4 l_bins_2;               /* number of bins in dim=2 (>=1)  */
-  /* + + +  dim = 1  + + + */
-  INTS4 l_outlim_up_counts;     /* no of counts that are          */
-  INTS4 l_outlim_low_counts;    /* out of range                   */
-  REAL4 r_limits_low;           /* upper limit                    */
-  REAL4 r_limits_up;            /* lower limit                    */
-  REAL4 r_binsize;              /* bin size                       */
-  REAL4 r_factor;               /* linear trans.                  */
-  REAL4 r_offset;               /* offset                         */
-  /* + + +  dim = 2  + + + */
-  INTS4 l_outlim_up_counts_2;   /* no of counts that are          */
-  INTS4 l_outlim_low_counts_2;  /* out of range                   */
-  REAL4 r_limits_low_2;         /* energy limits dim = 2          */
-  REAL4 r_limits_up_2;          /* energy limits dim = 2          */
-  REAL4 r_binsize_2;            /* bin size                       */
-  REAL4 r_factor_2;             /* linear trans.                  */
-  REAL4 r_offset_2;
-  /* +++ character strings +++ */
-  CHARS c_name[64];             /* histogram name                 */
-  CHARS c_dtype[4];             /* data flag                      */
-  CHARS c_data_time_cre[28];    /* creation time                  */
-  CHARS c_clear_date[28];       /* clearing time                  */
-  CHARS c_lettering_res[64];    /* lettering data content         */
-  CHARS c_lettering_1[64];      /* lettering 1st axis             */
-  CHARS c_lettering_2[64];      /* lettering 2nd axis             */
-} s_his_head ;
-
-#endif
diff --git a/MbsAPI/s_opc1.h b/MbsAPI/s_opc1.h
deleted file mode 100644
index a71c764..0000000
--- a/MbsAPI/s_opc1.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// $Id: s_opc1.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_OPC1
-#define S_OPC1
-
-#include "typedefs.h"
-
-#if MBS_ENDIAN == 1
-
-struct s_opc1 {                         /* ++ byte1 (LSB) ++ */
-  char          h_flt_len;          /* ++ byte4 (MSB) ++ length of filter*/
-  char          h_next_fltblk;      /* ++ byte3 ++  next filter blk      */
-  char          h_fltspec;          /* ++ byte2  filter specification */
-  /* +++ 25-Jan-1994 reversed bit sequence +++ */
-  unsigned      b1_lnkf2 :1;        /* lnk different flts blks   */
-  unsigned      b1_lnkf1 :1;        /* lnk filters: and:1 or:0   */
-  unsigned      b3_opc   :3;        /* opcode                    */
-  unsigned      b1_selwrt:1;        /* select write of evt/sev          */
-  unsigned      b1_selflt:1;        /* select event/subevent filter */
-  unsigned      b1_evtsev :1;       /* 1:event/0:subevt active for sel */
-  /* REM : h_next_fltblk and h_flt_len are ABSOLUTE adresses  !!! */
-};
-
-
-#else
-
-/* struct for filter opcode                  */
-struct s_opc1 {
-  /* ++ byte1 (LSB) ++ */
-  unsigned      b1_evtsev :1;       /* 1:event/0:subevt active for sel */
-  unsigned      b1_selflt:1;        /* select event/subevent filter */
-  unsigned      b1_selwrt:1;        /* select write of evt/sev          */
-  unsigned      b3_opc   :3;        /* opcode                    */
-  unsigned      b1_lnkf1 :1;        /* lnk filters: and:1 or:0   */
-  unsigned      b1_lnkf2 :1;        /* lnk different flts blks   */
-  char          h_fltspec;          /* ++ byte2  filter specification */
-  char          h_next_fltblk;      /* ++ byte3 ++  next filter blk      */
-  char          h_flt_len;          /* ++ byte4 (MSB) ++ length of filter*/
-};
-
-/* REM : h_next_fltblk and h_flt_len are ABSOLUTE adresses  !!! */
-
-#endif
-
-#endif
diff --git a/MbsAPI/s_pat.h b/MbsAPI/s_pat.h
deleted file mode 100644
index e55f2ff..0000000
--- a/MbsAPI/s_pat.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// $Id: s_pat.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#ifndef S_PAT
-#define S_PAT
-
-#include "typedefs.h"
-
-#if MBS_ENDIAN == 1
-
-/* identities for filter patterns                */
-struct s_pat1 {
-  short         i_dummy;
-  short         i_trigger;
-};
-
-struct s_pat2 {
-  char          h_control;
-  char          h_subcrate;
-  short         i_procid;
-};
-
-struct s_pat3 {
-  short         i_subtype;
-  short         i_type;
-};
-
-#else
-
-/* identities for filter patterns                */
-struct s_pat1 {
-  short         i_trigger;
-  short         i_dummy;
-};
-
-struct s_pat2 {
-  short         i_procid;
-  char          h_subcrate;
-  char          h_control;
-};
-
-struct s_pat3 {
-  short         i_type;
-  short         i_subtype;
-};
-
-#endif
-
-#endif
diff --git a/MbsAPI/s_pol_cond.h b/MbsAPI/s_pol_cond.h
deleted file mode 100644
index a089558..0000000
--- a/MbsAPI/s_pol_cond.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// $Id: s_pol_cond.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-typedef struct {
-  CHARS c_name[32];
-  CHARS c_desc[80];
-  INTU4 lu_used;
-  INTU4 lu_checked;
-  INTS4 l_freezed;
-  INTU4 lu_true;
-  REAL4 r_xmin;
-  REAL4 r_xmax;
-  REAL4 r_ymin;
-  REAL4 r_ymax;
-  INTS4 l_points;
-  REAL4 ra_x[32];
-  REAL4 ra_y[32];
-  REAL4 ra_x1[32];
-  REAL4 ra_y1[32];
-  REAL4 ra_x2[32];
-  REAL4 ra_y2[32];
-  REAL4 ra_f[32];
-  REAL4 ra_o[32];
-} s_pol;
diff --git a/MbsAPI/s_set_ml.h b/MbsAPI/s_set_ml.h
deleted file mode 100644
index 141c814..0000000
--- a/MbsAPI/s_set_ml.h
+++ /dev/null
@@ -1,102 +0,0 @@
-// $Id: s_set_ml.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz 10-Jan-1996
- *
- * within this structure the setup information for one host in the multi-branch
- * multi-layer daq system is specified.
- * for each host in the system which resides in the hierarchy above a
- * branch master (meb) such a set of data must be provided through a
- * parsed user input file.
- */
-
-/* after allocating s_set_ml set in f_ut_set_ml_ini */
-/* ps_set_ml->l_endian = 1;        */
-/* ps_set_ml->l_version = n;        */
-/* ps_set_ml->l_set_ml_lw = sizeof(s_set_ml)/4;  */
-/* ps_set_ml->l_fix_lw = ((int)&c_rd_hostname[0][0]-(int)ps_set_ml)/4;  */
-/* ps_set_ml->l_ml__n_rd_pipe = ML__N_RD_PIPE;  */
-/* ps_set_ml->l_short_len = 16;  */
-/* ps_set_ml->l_long_len = 128;  */
-typedef struct {
-  INTU4 l_endian;        /* set to 1 */
-  INTU4 l_version;       /* increment in f_ut_status_ini after changes */
-  INTU4 l_set_ml_lw;     /* sizeof(s_set_ml)/4 : total number of lw */
-  INTU4 l_fix_lw;       /* (&c_rd_hostname-ps_set_ml)/4 : fixed number of longwords to read */
-  INTU4 l_ml__n_rd_pipe; /* set to ML__N_RD_PIPE */
-  INTU4 l_short_len;     /* set to length of short strings (16) */
-  INTU4 l_long_len;      /* set to length of long strings (128) */
-
-  INTS4 l_n_rd_pipe;
-  /* number of pipes to read. this variable must not be specified,    */
-  /* instead it will be filled during loading the multi-layer setup   */
-  /* for this host                                                    */
-
-  INTS4 l_out_mode;
-  /* 1: write data from all read pipes into next layer pipe           */
-  /* 2: format events into event buffer streams                       */
-  /* 3: 1 + 2                                                         */
-
-  INTS4 l_ev_buf_len;
-  /* length of single event buffer. only needed if l_out_mode = 2,3   */
-
-  INTS4 l_n_ev_buf;
-  /* number of event buffers in a stream. only if l_out_mode = 2,3    */
-
-  INTS4 l_n_stream;
-  /* number of streams. only needed if l_out_mode = 2,3               */
-
-  INTS4 l_wr_pipe_base_addr;
-  /* base address of write pipe. only needed if l_out_mode = 1,3      */
-
-  INTS4 l_wr_pipe_len;
-  /* size of write pipe (in bytes). only needed if l_out_mode = 1,3   */
-
-  INTS4 l_wr_pipe_n_frag;
-  /* number of fragments to reserve in the write pipe. only needed if */
-  /* l_out_mode = 1,3                                                 */
-
-  INTS4 l_rd_host_flg[ML__N_RD_PIPE];
-  /* 0: not to read from this host                                    */
-  /* 1: pipe must be read from this node, node is branchmaster        */
-  /* 2: pipe must be read from this node, node is NOT a branchmaster  */
-
-  INTS4 l_rd_pipe_base_addr[ML__N_RD_PIPE];
-  /* base address of the pipes to read, seen from this host           */
-
-  INTS4 l_rd_pipe_len[ML__N_RD_PIPE];
-  /* size of the pipes to read. this variable must not be specified,  */
-  /* instead it will be filled from either a SBS setup file or from   */
-  /* the write pipe specification (see below)  of the coresponding    */
-  /* host lying below the hierarchy of this host          (in bytes)  */
-
-  INTS4 l_rd_pipe_n_frag[ML__N_RD_PIPE];
-  /* number of fragments to reserve in the read pipes. must also not  */
-  /* be specified. see comment above for l_rd_pipe_len[]              */
-  CHARS c_hostname[16];
-  /* net name of this host                                            */
-
-  /* ------------------ end of fixed block --------------------------*/
-  CHARS c_rd_hostname [ML__N_RD_PIPE][16];
-  /* netname of all hosts where this host have to read pipes          */
-
-  CHARS c_sbs_setup_path [ML__N_RD_PIPE][128];
-  /* paths/filenames of the SBS setup file of the hosts to read from. */
-  /* only needed if these hosts are SBS branch masters. in this case  */
-  /* the read pipes are specified in the SBS setup file. the base     */
-  /* address of the read pipes must always be specified nevertheless  */
-
-
-} s_set_ml;
diff --git a/MbsAPI/s_set_mo.h b/MbsAPI/s_set_mo.h
deleted file mode 100644
index 734d995..0000000
--- a/MbsAPI/s_set_mo.h
+++ /dev/null
@@ -1,105 +0,0 @@
-// $Id: s_set_mo.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/*
- * N.Kurz 8-Jun-1998
- *
- * within this structure the setup information for a   n # m
- * (multiple output/collector) mbs system is specified
- */
-
-#include "typedefs.h"
-#include "mo_def.h"
-
-typedef struct {
-  INTU4 l_endian;                 /* must be 1 */
-  INTU4 l_version;                /* structure version */
-  INTU4 l_set_mo_lw;              /* length of structure */
-  INTU4 l_swap_lw;                /* longwords to be swapped */
-  INTU4 l_max_nodes;              /* set to MO__N_NODE */
-  INTU4 l_no_senders;             /* actual number of senders */
-  INTU4 l_no_receivers;           /* actual number of receivers */
-  INTU4 bl_dr_active[MO__N_NODE]; /* active receivers */
-
-  INTU4 l_rd_pipe_base_addr [MO__N_NODE] [MO__N_NODE];
-  /* base addresses of all pipes residing on the ds nodes seen remote    */
-  /* from dr nodes  l_rd_pipe_base_addr[dr_node_id][ds_node_id].         */
-  /* this setup parametes are only  necessary for an address mapped      */
-  /* transfer mode (l_trans_mode = 0).                                   */
-  INTU4 l_rd_pipe_seg_len [MO__N_NODE];
-  /* size of pipe segments on ds nodes. index is ds id. this information */
-  /* is only necessary if transfer type 0 (single shot data transfer)    */
-  /* from any of the ds nodes. !!!! WARNING !!!! this information is     */
-  /* redundant. the size is also specified in the setup.usf or           */
-  /* set_ml.usf of the ds node and must match.                           */
-  INTU4 l_rd_pipe_trans_mode [MO__N_NODE] [MO__N_NODE];
-  /* data transfer mode from ds nodes to dr nodes                            */
-  /* l_rd_pipe_base_addr[dr_node_id][ds_node_id].                        */
-  /* transfer mode: 0xxx = address mapped, dr reads data                 */
-  /*                1xxx = message oriented mode ( tcp ), ds sends data  */
-  /*                01xx = address mapped DMA modes (various)            */
-  /*                                                                     */
-  /*              0x   0 = standard singe cycle address mapped           */
-  /*              0x 101 = VME DMA E7                                    */
-  /*              0x 102 = VME DMA RIO2 <- RIO2                          */
-  /*              0x 103 = VSB DMA RIO2 <- "any" VSB slave device        */
-  /*              0x 104 = PVIC DMA RIO2                                 */
-  /*              0x 105 = VME DMA RIO2 <- E7 / VME memory               */
-  /*              0x1001 = TCP sockets                                   */
-  INTU4 l_form_mode;
-  /* two format modes have been forseen, whereas only mode 1 is imple-   */
-  /* mented yet.                                                         */
-  /* mode 1: ds node sends data, or dr node reads data (depending on     */
-  /*         transfer type) to an intermediate event buffer of size      */
-  /*         l_max_evt_size. formatting, and possible byte swapping is   */
-  /*         done afterwards from the intermediate event buffer into the */
-  /*         streams.                                                    */
-  /* mode 2: ds node sends data, or dr node reads data and formats       */
-  /*         immediately into the streams. not yet implemented           */
-  INTU4 l_base_addr_evt_buf[MO__N_NODE];
-  /* if l_form_mode = 1:       (intermediate formatting)                 */
-  /* for transfer types where address mapped writing from ds node or dma */
-  /* data transfer is done a shared segement is needed and created with  */
-  /* physical base address l_base_addr_evt_buf and size l_max_evt_size.  */
-  /* if l_form_mode = 2:       (direct formatting)                       */
-  /* a shared segment for this buffer must also be created for           */
-  /* direct formatting into streams if the ds node writes address mapped */
-  /* or dma is done. this buffer will be used to hold an event if the    */
-  /* actual stream has less space than l_max_evt_size since in this mode */
-  /* the actual event size is not known before the transfer of the last  */
-  /* fraction.                                                           */
-  /*                                                                     */
-  /* if l_base_addr_evt_buf != 0 an smem_create segment will be created  */
-  /* if l_base_addr_evt_buf  = 0 ( or not specified) a buffer of size    */
-  /* l_max_evt_size will be created with malloc and is therefore not     */
-  /* contigious in the address space.                                    */
-  /* MO__N_NODE runs over dr node ids.                                   */
-  INTU4 l_max_evt_size;
-  /* TOTAL maximum event size, which could occur within this setup.      */
-  /* in bytes.                                                           */
-  INTU4 l_n_frag;
-  /* many subevents/fragments can be send/read in one transfer (i.e.     */
-  /* tcp, vme block transfer) from m_ds to m_dr if the data is conscu-   */
-  /* tive. l_n_frag specifies the number fragments sent in such a packet */
-  INTU4 l_ev_buf_len [MO__N_NODE];
-  INTU4 l_n_ev_buf [MO__N_NODE];
-  INTU4 l_n_stream [MO__N_NODE];
-  INTU4 l_base_addr_stream_seg [MO__N_NODE];
-  /* only nedded if l_form mode = 2. see explanation above               */
-  INTU4 l_out_mode [MO__N_NODE];
-  CHARS c_ds_hostname [MO__N_NODE][16];
-  /* name of ds nodes */
-  CHARS c_dr_hostname [MO__N_NODE][16];
-  /* name of dr nodes */
-
-} s_set_mo;
diff --git a/MbsAPI/s_setup.h b/MbsAPI/s_setup.h
deleted file mode 100644
index 179f96c..0000000
--- a/MbsAPI/s_setup.h
+++ /dev/null
@@ -1,265 +0,0 @@
-// $Id: s_setup.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz
- * global SBS setup parameter structure
- */
-
-/* After allocating s_setup, set in f_ut_setup_ini */
-/* ps_setup->l_endian = 1;   */
-/* ps_setup->l_version = n;   */
-/* ps_setup->bl_struc_len = sizeof(s_setup)/4;   */
-/* ps_setup->l_fix_lw = ((int)&lp_rem_mem_base[0]-(int)ps_setup)/4;   */
-/* ps_setup->bl_sbs__n_cr = SBS__N_CR;   */
-/* ps_setup->bl_sbs__n_trg_typ = SBS__N_TRG_TYP;   */
-
-typedef struct {
-  /*---------------------------------------------------------------------------*/
-  INTU4 l_endian;            /* set to 1 */
-  INTU4 l_version;           /* increment in f_ut_setup_ini after changes */
-  INTU4 bl_struc_len;      /* sizeof(s_setup)/4 : length of this structure             */
-  INTU4 l_fix_lw;      /* (&lp_rem_mem_base-ps_setup)/4 : swapping size          */
-  INTU4 bl_sbs__n_cr;        /* set to SBS__N_CR  */
-  INTU4 bl_sbs__n_trg_typ;   /* set to SBS__N_TRG_TYP */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bi_master;      /* indicates type of master event builder                 */
-  /* meb:   1 = CVC, 2 = E6, 3 = E7                         */
-  INTU4 bl_no_crates;      /* Number of crates to read (bh_rd_flg > 0)               */
-  INTU4 bh_crate_nr;      /* crate nr. of readout processor: meb = 0, slave = 1-15  */
-  /* this value will be set by the load setup command and   */
-  /* is not parsed from the .usf file                       */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bl_ev_buf_len;      /* length of single event buffer                          */
-  INTU4 bl_n_ev_buf;      /* number of event buffers in a stream                    */
-  INTU4 bl_n_stream;      /* number of streams                                      */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bi_evt_typ_sy;      /* event type of synchronous events,     default = 10     */
-  INTU4 bi_evt_typ_asy;      /* event type of asynchronous events,    default = 10     */
-  INTU4 bi_evt_subtyp_sy;      /* event subtype of synchronous events,  default = 1      */
-  INTU4 bi_evt_subtyp_asy;   /* event subtype of asynchronous events, default = 2      */
-  INTS4 h_se_control;      /* serves as branch identifier in a multi-branch system   */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bh_rd_typ;      /* 0 = standard readout with  readout tables              */
-  /* 1 = user readout (function)                            */
-  /* if the following bh_meb_asy_flg is set to 1 there will be a second    */
-  /* async. subevent pipe installed, which will be collected by the meb    */
-  /* collector, but must be filled by a seperate process                   */
-  INTU4 bh_col_mode;       /* indicates mode of this MEB collector or master readout:*/
-  /* 0 = standard, the collector formats events and passes  */
-  /*     the formatted event buffer streams to the          */
-  /*     transport                                          */
-  /* 1 = collector collects subevents from the various      */
-  /*     SBS pipes, but no event formatting will be done.   */
-  /*     instead the collected subevents are written into a */
-  /*     output pipe for the next layer node of the         */
-  /*     multi-branch multi-layer daq system. this mode     */
-  /*     requires bl_ml_pipe_base_addr, bl_ml_pipe_seg_len  */
-  /*     and bl_ml_pipe_len to be specified (see below).    */
-  /* 2 = only m_read_meb and no collector runs on the       */
-  /*     SBS master (MEB). Its subevent pipe will be read   */
-  /*     by a node of the multi-branch multi-layer daq      */
-  /*     system. in this case the mb ml node gets the pipe  */
-  /*     specs from bl_pipe_seg_len and bl_pipe_len         */
-  /*     (see above).                                       */
-  /* 3 = includes both 0 and 1 mode.                        */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bl_loc_esone_base;   /* base address to execute CAMAC cnafs via the ESONE      */
-  /* window on the local crate*/
-  INTU4 bl_rem_esone_base;   /* base address to execute CAMAC cnafs via the ESONE      */
-  /* window on the remote crate*/
-  INTU4 bl_esone_off;      /* offset from standard to ESONE window in bytes          */
-  INTU4 bl_cvc_crr_off;      /* offset from  to the CVC CAMAC Read Register            */
-  INTU4 bl_cvc_csr_off;      /* offset to the CVC Control and Status Register          */
-  INTU4 bl_cvc_clb_off;      /* offset to the CVC CAMAC Lam Buffer                     */
-  INTU4 bl_se_meb_asy_len;   /* length of the async. pipe of the master, including     */
-  /* control and data                                       */
-  INTU4 bh_meb_asy_flg;      /* indicates if meb must collect must an async. pipe      */
-  /* residing on the meb: 0 = no, 1 = yes                   */
-  INTU4 bl_ml_pipe_base_addr;/* base address of the multi-branch multi-layer daq       */
-  /* system output pipe.                                    */
-  /* only requested ig bh_col_mode = 1,2                    */
-  INTU4 bl_ml_pipe_seg_len;  /* length of the multi-branch multi-layer daq system      */
-  /* output pipe.  (total lengt of subevent pipe)           */
-  /* only requested ig bh_col_mode = 1,2                    */
-  INTU4 bl_ml_pipe_len;       /* number of subevent/fragment slots in the multi-branch  */
-  /* multi-layer daq system output pipe                     */
-  /* only requested ig bh_col_mode = 1,2                    */
-  INTU4 bl_n_col_retry;      /* number of retries the subevent collect process makes   */
-  /* until giving up time slice                             */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bh_meb_trig_mode;    /* if this is set to NON zero a special mode is requested */
-  /* for the trigger module serving m_read_meb.             */
-  /* this could be:                                         */
-  /*       NOT irq (LAM, VME irq)                           */
-  /*    or NOT standard base address (VME)                  */
-  /*    or NOT local crate                                  */
-  /* if bh_meb_trig_mode is NOT 0 always the following two  */
-  /* setup paramters will be taken for type and base addr.  */
-  /*                                                        */
-  /* NOTE: the fast clear and conversion time will be taken */
-  /*       from bl_trig_fct[0] and bl_trig_cvt[0] from this */
-  /*       setup structure                                  */
-  /*                                                        */
-  /*  0 = standard = local  interrupt (CAMAC LAM, VME IRQ)  */
-  /*  1 = special:   local  interrupt (CAMAC LAM, VME IRQ)  */
-  /*  2 = special:   remote VSB interrupt (not yet impleme) */
-  /*  3 = special:   polling                                */
-  INTU4 bh_special_meb_trig_type;
-  /*  1 = CAMAC   type trigger module                       */
-  /*  2 = VME     type trigger module                       */
-  /*  3 = FASTBUS type triggermodule                        */
-  INTU4 bl_special_meb_trig_base;
-  /* base address of trigger module acting together with    */
-  /* m_read_meb if bh_meb_trig_mode != 0                    */
-  /* NOTE: if trigger module is remote the complete (VSB)   */
-  /*       base address must be specified. example:         */
-  /*       f0580000 for a CAMAC trigger module in crate 2   */
-  /*       serving m_read_meb running on an E7 in a VME     */
-  /*       crate. (see sketch at end of this file)          */
-  /*---------------------------------------------------------------------------*/
-  INTU4 lp_cvc_irq;       /* start address of the CVC irq physical segment          */
-  INTU4 bl_cvc_irq_len;       /* length of CVC irq phys. segment                        */
-  INTU4 bl_cvc_irq_source_off;/* offset from lp_cvc_irq to the CVC irq source register  */
-  INTU4 bl_cvc_irq_mask_off;  /* offset from lp_cvc_irq to the CVC irq mask register    */
-  /*---------------------------------------------------------------------------*/
-  /* all values in this section will be initalized by a loader task */
-  INTS4 h_rd_tab_flg;      /* -1 = init and readout tables invalid (this is set by   */
-  /*      the write_sbs_setup task                          */
-  /* 0  = init and readout tables have to be modified to    */
-  /*      virtual cnafs                                     */
-  /* 1  = this modification is done and must not be done    */
-  /*      before a new table was loaded                     */
-  INTU4 bl_init_read_len;      /* total length of init and readout CAMAC cnaf list for   */
-  /* all crates and trigger types (in bytes)                */
-  /* ------------------ end of fixed block --------------------------*/
-  /*---------------------------------------------------------------------------*/
-  INTU4 lp_rem_mem_base[SBS__N_CR];
-  /* physical base address for accessing slave crate memory */
-  /* seen from the MEB (pipes). This could be the VSB       */
-  /* base address for accessing remote crates               */
-  INTU4 bl_rem_mem_off[SBS__N_CR];
-  /* offset from  lp_rem_mem_base[SBS__N_CR] to the memory  */
-  /* space of the remote slaves (seen from MEB)             */
-  INTU4 bl_rem_mem_len[SBS__N_CR];
-  /* lenght of the memory address window with the physical  */
-  /* base adress lp_rem_mem_base[SBS__N_CR]                 */
-  /*---------------------------------------------------------------------------*/
-  INTU4 lp_rem_cam_base[SBS__N_CR];
-  /* physical base address for accessing slave directly via CAMAC */
-  INTU4 bl_rem_cam_off[SBS__N_CR];
-  /* offset from lp_rem_cam_base[SBS__N_CR] to the remote   */
-  /* CAMAC space of the slaves (seen from MEB).             */
-  INTU4 bl_rem_cam_len[SBS__N_CR];
-  /* lenght of the CAMAC address window with the physical   */
-  /*---------------------------------------------------------------------------*/
-  INTU4 lp_loc_mem_base[SBS__N_CR];
-  /* base address for accessing local crate. (could be for  */
-  /* example local CAMAC base or extended VME base.)        */
-  INTU4 bl_loc_mem_len[SBS__N_CR];
-  /* length of physical segment for accessing local crate   */
-  /* starting from lp_loc_mem_base[SBS__N_CR].              */
-  /*---------------------------------------------------------------------------*/
-  INTU4 l_loc_pipe_type[SBS__N_CR];
-  /* type of subevent pipe:   0: with smem_create           */
-  /*                          1: direct mapping             */
-  INTU4 lp_loc_pipe_base[SBS__N_CR];
-  /* RAM start address of the crate controller (used for    */
-  /* location of subevent pipe)                             */
-  INTU4 bl_pipe_off[SBS__N_CR];
-  /* offset from lp_ram_loc_start to start of the remote    */
-  /* communication segment slave <-> master seen from the   */
-  /* slave in bytes = start of subevent pipe                */
-  INTU4 bl_pipe_seg_len[SBS__N_CR];
-  /* length of the remote communication segment in bytes    */
-  /* = total lengt of subevent pipe                         */
-  INTU4 bl_pipe_len[SBS__N_CR];      /* number of subevent slots in a pipe                     */
-  INTU4 bh_controller_id[SBS__N_CR];
-  /* bh_controller_id MUST be set for ESONE CNAF execution  */
-  /* 1 = CVC, 2 = E6, 3 = E7, 4 = AEB, 5 = CBV, 6 = CVI     */
-  /* 7 = CAV (Q and X inverted)                             */
-  INTU4 bh_sy_asy_flg[SBS__N_CR];
-  /* indicates if this crate must be readout synchronous    */
-  /* or asynchronous: 0 = synchronous, 1 = asynchronous     */
-  /* this flag is only valid for crates with intelligent    */
-  /* controller. At this point it is decided wether a crate */
-  /* is readout sync. or async.                             */
-  INTU4 bh_trig_stat_nr[SBS__N_CR];/* CAMAC station nr. of the trigger module, must be 1     */
-  INTU4 bl_trig_cvt[SBS__N_CR];      /* conversion time of trigger module                      */
-  INTU4 bl_trig_fct[SBS__N_CR];     /* fast clear acceptance time of trigger module           */
-  INTS4 i_se_typ[SBS__N_CR];     /* subevent typ, default = 10                             */
-  INTS4 i_se_subtyp[SBS__N_CR];     /* subevent subtyp: CAMAC = 1, FASTBUS = 2                */
-  INTS4 i_se_procid[SBS__N_CR];     /* subevent processor id                                  */
-  /*---------------------------------------------------------------------------*/
-  INTU4 bh_rd_flg[SBS__N_CR];
-  /* 0 = crate not readout                                  */
-  /* 1 = crate read out by meb                              */
-  /* 2 = crate readout by intelligent crate controller      */
-  INTU4 bl_init_tab_off[SBS__N_CR];
-  /* offset from start of readout table segment to the      */
-  /* start of the init table as a function of crate number  */
-  /* (in longwords)                                         */
-  INTU4 bi_init_tab_len[SBS__N_CR];
-  /* lenght of the init tables. if one of this values is 0  */
-  /* it means that this crate must not be not initalized    */
-  /* (in longwords)                                         */
-  INTU4 bl_max_se_len[SBS__N_CR][SBS__N_TRG_TYP];
-  /* maximal subevent length [b] of this crate and trigger  */
-  INTU4 bl_rd_tab_off[SBS__N_CR][SBS__N_TRG_TYP];
-  /* offset from start of readout table segment to the      */
-  /* start of the readout tables as a function of crate     */
-  /* number and trigger type (in longwords)                 */
-  INTU4 bi_rd_tab_len[SBS__N_CR][SBS__N_TRG_TYP];
-  /* lenght of the readout tables. if one of this values    */
-  /* is 0 it means that this crate for this trigger type is */
-  /* not read out (in longwords)                            */
-  /*---------------------------------------------------------------------------*/
-} s_setup;
-
-/*
-*  address offset for memory access from the master event builder to the slave
-*  CVC's via VSB. these offsets point to the memory address 0x100000 seen
-*  from the slave CVC, which is the beginning of the RAM of the CVC. only
-*  longword access possible, the following offsets are given in bytes.
-*
-*  in the case of accessing non local crates by CAMAC cnaf's via VSB, the
-*  shown address offset (CAM_CRT_OFF) between two consecutive crates is
-*  automatically included by crate number contained in the cnaf. the effective
-*  physical offset to the cnafs is 0x08180000
-*/
-/*----------------------------------------------------------------------------!
-!     VSB and CAMAC memory on the CVC slaves, seen from the MEB CVC           !
-!                                                                             !
-!                                                                             !
-!          0x8000000           0x8200000           0x8400000                  !
-!               |                   |                   |                     !
-!               |                   |                   |                     !
-!               |    VSB_CRT_OFF    |    VSB_CRT_OFF    |                     !
-!    V S B      |===================|===================|===...               !
-!               |      0x200000     |      0x200000     |                     !
-!               |                   |                   |                     !
-!               |              crate|1             crate|2                    !
-!               |                   |                   |                     !
-! VSB_CAM_START | (VSB_OFF = 0x0)                                             !
-!==============>|                                                             !
-!   0x8000000   |                                    |                   |    !
-!               |                               crate|1             crate|2   !
-!               |                                    |                   |    !
-!               |    CAM_OFF     |    CAM_CRT_OFF    |    CAM_CRT_OFF    |    !
-!   C A M A C   |================|===================|===================|==..!
-!               |    0x180000    |     0x200000      |      0x200000     |    !
-!               |                |                   |                   |    !
-!               |                |                   |                   |    !
-!          0x8000000        0x8180000           0x8380000           0x8580000 !
-!----------------------------------------------------------------------------*/
diff --git a/MbsAPI/s_spe.h b/MbsAPI/s_spe.h
deleted file mode 100644
index 88e1563..0000000
--- a/MbsAPI/s_spe.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// $Id: s_spe.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/* s_spe.h
- * =======
- *
- * Author   :     Ilya Kutznetsov, R. S. Mayer
- * Created  :     20-Sep-1994
- *
- * modified :     14-Oct-1994 Prepared for 2-dim histograms /RSM
- *                15-Nov-1994 Slot numbers for binary tree. /RSM
- *                02-Dec-1994 align structure. /RSM
- */
-
-#define HIS__HISNAMLEN 32         /* max lenght of histogram name string     */
-
-typedef struct {
-  INTU4 ul_attr;                /*  flag                          */
-  INTS4 l_version;              /* structure version mumber       */
-  INTS4 i_slotlef;              /* next slot left (sort)          */
-  INTS4 i_slotrig;              /* next slot right (sort)         */
-  INTS4 l_protected;            /* clear histogram?               */
-  INTS4 l_bins_1;               /* number of bins in dim=1        */
-  INTS4 l_bins_2;               /* number of bins in dim=2        */
-  INTS4 l_dim;                  /* dimension size                 */
-  INTS4 l_data;                 /* relative pointer to data,      */
-  INTU4 l_counts;               /* total sum of counts            */
-  REAL8 d_contents;             /* total sum of counts            */
-  INTU4 l_spare1;               /* spare                          */
-  INTU4 l_spare2;               /* spare                          */
-  INTU4 l_spare3;               /* spare                          */
-  INTU4 l_spare4;               /* spare                          */
-  INTU4 l_spare5;               /* spare                          */
-  /* + + +  dim = 1  + + + */
-  INTS4 l_outlim_up_counts;     /* no of counts that are          */
-  INTS4 l_outlim_low_counts;    /* out of range                   */
-  REAL4 r_limits_low;           /* upper limit                    */
-  REAL4 r_limits_up;            /* lower limit                    */
-  REAL4 r_binsize;              /* bin size                       */
-  REAL4 r_factor;               /* linear trans.                  */
-  REAL4 r_offset;               /* offset                         */
-  /* + + +  dim = 2  + + + */
-  INTS4 l_outlim_up_counts_2;   /* no of counts that are          */
-  INTS4 l_outlim_low_counts_2;  /* out of range                   */
-  REAL4 r_limits_low_2;         /* energy limits dim = 2          */
-  REAL4 r_limits_up_2;          /* energy limits dim = 2          */
-  REAL4 r_binsize_2;            /* bin size                       */
-  REAL4 r_factor_2;             /* linear trans.                  */
-  REAL4 r_offset_2;
-  /* +++ character strings +++ */
-  CHARS c_name[HIS__HISNAMLEN]; /* spect's name                   */
-  CHARS c_dtype[4];             /* data flag                      */
-  CHARS c_data_time_cre[28];    /* creation time                  */
-  CHARS c_clear_date[28];       /* clearing time                  */
-  CHARS c_lettering_res[64];    /* lettering data content         */
-  CHARS c_lettering_1[64];      /* lettering 1st axis             */
-  CHARS c_lettering_2[64];      /* lettering 2nd axis             */
-} s_spe ;
diff --git a/MbsAPI/s_stdint.h b/MbsAPI/s_stdint.h
index 06e4aba..d1f73ea 100644
--- a/MbsAPI/s_stdint.h
+++ b/MbsAPI/s_stdint.h
@@ -1,16 +1,10 @@
-// $Id: s_stdint.h 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_STDINT_H
 #define S_STDINT_H
 
diff --git a/MbsAPI/s_ve10_1.h b/MbsAPI/s_ve10_1.h
index d2a7665..9ec9a66 100644
--- a/MbsAPI/s_ve10_1.h
+++ b/MbsAPI/s_ve10_1.h
@@ -1,16 +1,10 @@
-// $Id: s_ve10_1.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_VE10_1
 #define S_VE10_1
 
diff --git a/MbsAPI/s_ve10_1_swap.h b/MbsAPI/s_ve10_1_swap.h
index 762df41..c1b068e 100644
--- a/MbsAPI/s_ve10_1_swap.h
+++ b/MbsAPI/s_ve10_1_swap.h
@@ -1,16 +1,10 @@
-// $Id: s_ve10_1_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_VE10_1_SWAP
 #define S_VE10_1_SWAP
 
diff --git a/MbsAPI/s_ves10_1.h b/MbsAPI/s_ves10_1.h
index 172964b..5c68f36 100644
--- a/MbsAPI/s_ves10_1.h
+++ b/MbsAPI/s_ves10_1.h
@@ -1,16 +1,10 @@
-// $Id: s_ves10_1.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_VES10_1
 #define S_VES10_1
 
diff --git a/MbsAPI/s_ves10_1_swap.h b/MbsAPI/s_ves10_1_swap.h
index 12995ce..2b5fc3c 100644
--- a/MbsAPI/s_ves10_1_swap.h
+++ b/MbsAPI/s_ves10_1_swap.h
@@ -1,16 +1,10 @@
-// $Id: s_ves10_1_swap.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef S_VES10_1_SWAP
 #define S_VES10_1_SWAP
 
diff --git a/MbsAPI/s_win_cond.h b/MbsAPI/s_win_cond.h
deleted file mode 100644
index 9a0e200..0000000
--- a/MbsAPI/s_win_cond.h
+++ /dev/null
@@ -1,26 +0,0 @@
-// $Id: s_win_cond.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-typedef struct {
-  CHARS c_name[32];
-  CHARS c_desc[80];
-  INTU4 lu_used;
-  INTU4 lu_checked;
-  INTS4 l_freezed;
-  INTU4 lu_true;
-  REAL4 r_xmin;
-  REAL4 r_xmax;
-  REAL4 r_ymin;
-  REAL4 r_ymax;
-} s_win;
diff --git a/MbsAPI/sbs_def.h b/MbsAPI/sbs_def.h
deleted file mode 100644
index 8c89cc0..0000000
--- a/MbsAPI/sbs_def.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// $Id: sbs_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz:
- * global definitions for the single branch system (sbs)
- */
-
-#define SBS__STR_LEN_32      32
-#define SBS__STR_LEN_64      64
-#define SBS__STR_LEN_96      96
-#define SBS__STR_LEN_128     128
-#define SBS__N_CR            16 /* maximal nr. of crates in the sbs  */
-#define SBS__N_TRG_TYP       16 /* maximal nr. of different trigger types */
-#define SBS__B_TRG_TYP       1  /* first valid trigger type */
-
-#define TRIG__CLEARED 0x10
-
-#define SBS__SETUP_TAB       "setup"
-#define SBS__READOUT_TAB     "readout_table"
-#define SBS__DAQ_STATUS_TAB  "daq_status"
-#define REM__MEM_NAME        "rem_mem"
-#define REM__CAM_NAME        "rem_cam"
-#define LOC__MEM_NAME        "loc_crate_access"
-#define SE__MEB_ASY_NAME     "to be defined"
-#define SE__PIPE_NAME        "se_pipe"
-#define CVC__IRQ_NAME        "CVC_irq_control"
-#define EVT__BUF_STREAMS     "event_buffer_streams"
-
-#define LOC__ESONE_NAME      "loc_esone"
-#define REM__ESONE_NAME      "rem_esone"
-#define LOC__ESONE_LEN       0x50000
-#define REM__ESONE_LEN       0x2000000
-
-#define TRIG__VME_BASE       0x2000000L
-#define TRIG__VME_SIZE       0x1000L
-#define TRIG__VME_NAME       "VME_trig_mod"
-#define TRIG__VME_RIO2_OFF   0xE0000000L
-
-#define TRIG__REM_SIZE       0x2000L
-#define TRIG__REM_NAME       "rem_trig_mod"
diff --git a/MbsAPI/sys_def.h b/MbsAPI/sys_def.h
deleted file mode 100644
index 9228d14..0000000
--- a/MbsAPI/sys_def.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// $Id: sys_def.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-#include "typedefs.h"
-/*
- * N. Kurz
- * Lynx specific definitions
- */
-
-#define FALSE              0
-#define TRUE               1
-#define SYS__N_MAX_PROCS   30
-#define SYS__SEGM_BLK_SIZE 0x1000
-/* index in daqst-> bh_running[] */
-#define SYS__read_meb         0
-#define SYS__collector        1
-#define SYS__transport        2
-#define SYS__event_serv       3
-#define SYS__msg_log          4
-#define SYS__dispatch         5
-#define SYS__util             6
-#define SYS__sbs_mon          7
-#define SYS__read_cam_slav    8
-#define SYS__esone_serv       9
-#define SYS__stream_serv     10
-#define SYS__histogram       11
-#define SYS__prompt          12
-#define SYS__daq_rate        13
-#define SYS__smi             14
-#define SYS__ds              15
-#define SYS__dr              16
-#define SYS__ar              17
-#define SYS__rirec           18
-#define SYS__to              19
-#define SYS__vme_serv        20
diff --git a/MbsAPI/typedefs.h b/MbsAPI/typedefs.h
index cb8e2df..824120d 100644
--- a/MbsAPI/typedefs.h
+++ b/MbsAPI/typedefs.h
@@ -1,16 +1,10 @@
-// $Id: typedefs.h 595 2010-03-09 06:51:15Z adamczew $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /* This central include file defines data types for all platforms */
 
 #ifndef TYPEDEF_H
diff --git a/MbsAPI/typedefs_nt.h b/MbsAPI/typedefs_nt.h
deleted file mode 100644
index e0737cc..0000000
--- a/MbsAPI/typedefs_nt.h
+++ /dev/null
@@ -1,55 +0,0 @@
-// $Id: typedefs_nt.h 478 2009-10-29 12:26:09Z linev $
-//-----------------------------------------------------------------------
-//       The GSI Online Offline Object Oriented (Go4) Project
-//         Experiment Data Processing at EE department, GSI
-//-----------------------------------------------------------------------
-// Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
-//                     Planckstr. 1, 64291 Darmstadt, Germany
-// Contact:            http://go4.gsi.de
-//-----------------------------------------------------------------------
-// This software can be used under the license agreements as stated
-// in Go4License.txt file which is part of the distribution.
-//-----------------------------------------------------------------------
-
-/* This file called in typedefs.h defines data types for NT */
-
-#ifdef WIN32
-#define EWOULDBLOCK             WSAEWOULDBLOCK
-#define EINPROGRESS             WSAEINPROGRESS
-#define EALREADY                WSAEALREADY
-#define ENOTSOCK                WSAENOTSOCK
-#define EDESTADDRREQ            WSAEDESTADDRREQ
-#define EMSGSIZE                WSAEMSGSIZE
-#define EPROTOTYPE              WSAEPROTOTYPE
-#define ENOPROTOOPT             WSAENOPROTOOPT
-#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
-#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
-#define EOPNOTSUPP              WSAEOPNOTSUPP
-#define EPFNOSUPPORT            WSAEPFNOSUPPORT
-#define EAFNOSUPPORT            WSAEAFNOSUPPORT
-#define EADDRINUSE              WSAEADDRINUSE
-#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
-#define ENETDOWN                WSAENETDOWN
-#define ENETUNREACH             WSAENETUNREACH
-#define ENETRESET               WSAENETRESET
-#define ECONNABORTED            WSAECONNABORTED
-#define ECONNRESET              WSAECONNRESET
-#define ENOBUFS                 WSAENOBUFS
-#define EISCONN                 WSAEISCONN
-#define ENOTCONN                WSAENOTCONN
-#define ESHUTDOWN               WSAESHUTDOWN
-#define ETOOMANYREFS            WSAETOOMANYREFS
-#define ETIMEDOUT               WSAETIMEDOUT
-#define ECONNREFUSED            WSAECONNREFUSED
-#define ELOOP                   WSAELOOP
-/*#define ENAMETOOLONG            WSAENAMETOOLONG*/
-#define EHOSTDOWN               WSAEHOSTDOWN
-#define EHOSTUNREACH            WSAEHOSTUNREACH
-/*#define ENOTEMPTY               WSAENOTEMPTY*/
-#define EPROCLIM                WSAEPROCLIM
-#define EUSERS                  WSAEUSERS
-#define EDQUOT                  WSAEDQUOT
-#define ESTALE                  WSAESTALE
-#define EREMOTE                 WSAEREMOTE
-#endif
-
diff --git a/base/CMakeLists.txt b/base/CMakeLists.txt
index 2ea8057..9012767 100644
--- a/base/CMakeLists.txt
+++ b/base/CMakeLists.txt
@@ -1,80 +1,180 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base
+
+If(NOT DEFINED BUILD_MBS)
+  Set(BUILD_MBS TRUE)
+EndIf(NOT DEFINED BUILD_MBS)
+
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/fairtools
+  ${CMAKE_SOURCE_DIR}/geobase 
+  ${CMAKE_SOURCE_DIR}/parbase 
+  ${CMAKE_SOURCE_DIR}/base
+  ${CMAKE_SOURCE_DIR}/base/steer
+  ${CMAKE_SOURCE_DIR}/base/event
+  ${CMAKE_SOURCE_DIR}/base/field
+  ${CMAKE_SOURCE_DIR}/base/sim
+  ${CMAKE_SOURCE_DIR}/base/source
+)
+
+
+If(WITH_DBASE)
+  Set(INCLUDE_DIRECTORIES
+     ${INCLUDE_DIRECTORIES}
+     ${CMAKE_SOURCE_DIR}/dbase/dbInterface
+     ${CMAKE_SOURCE_DIR}/dbase/dbValidation
+     ${CMAKE_SOURCE_DIR}/dbase/dbUtils
+     ${CMAKE_SOURCE_DIR}/input/db
+     ${CMAKE_SOURCE_DIR}/dbase/dbInput
+   )
+EndIf(WITH_DBASE)
+
+
+If(BUILD_MBS)
+  Set(INCLUDE_DIRECTORIES
+     ${INCLUDE_DIRECTORIES} 
+     ${CMAKE_SOURCE_DIR}/MbsAPI
+  )
+EndIf(BUILD_MBS)
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+  ${Boost_INCLUDE_DIRS}
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Include_Directories(${INCLUDE_DIRECTORIES})
+
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
 # List of source files
 set(SRCS
-FairBaseContFact.cxx 
-FairBaseParSet.cxx
-FairLink.cxx
-FairMultiLinkedData.cxx 
-FairDetector.cxx 
-FairEventHeader.cxx 
-FairFileHeader.cxx 
-FairGenerator.cxx 
-FairHit.cxx 
-FairIon.cxx 
-FairMCApplication.cxx 
-FairGeaneApplication.cxx 
-FairMCEventHeader.cxx 
-FairMCPoint.cxx 
-FairModule.cxx 
-FairParticle.cxx 
-FairPrimaryGenerator.cxx 
-FairRootManager.cxx 
-FairRun.cxx 
-FairRunAna.cxx 
-FairRunIdGenerator.cxx 
-FairRunSim.cxx 
-FairGenericStack.cxx 
-FairTask.cxx 
-FairTrackParam.cxx 
-FairTrajFilter.cxx 
-FairVolume.cxx 
-FairVolumeList.cxx 
-FairField.cxx
-FairFieldFactory.cxx
-FairRadLenPoint.cxx
-FairRadMapManager.cxx
-FairRadMapPoint.cxx
-FairRadLenManager.cxx
-FairRadGridManager.cxx
-FairMesh.cxx
-FairRKPropagator.cxx
-FairTimeStamp.cxx
-FairTSBufferFunctional.cxx
-FairFileInfo.cxx
-FairRunInfo.cxx
-FairWriteoutBuffer.cxx
-FairRingSorter.cxx
-FairRingSorterTask.cxx
-FairAnaSelector.cxx
+
+steer/FairAnaSelector.cxx
+steer/FairRadGridManager.cxx
+steer/FairRadLenManager.cxx
+steer/FairRadMapManager.cxx
+steer/FairRingSorter.cxx
+steer/FairRingSorterTask.cxx
+steer/FairRootManager.cxx
+steer/FairRun.cxx
+steer/FairRunAna.cxx
+steer/FairRunAnaProof.cxx
+steer/FairRunSim.cxx
+steer/FairTSBufferFunctional.cxx
+steer/FairTask.cxx
+steer/FairTrajFilter.cxx
+steer/FairWriteoutBuffer.cxx
+steer/FairRunOnline.cxx
+steer/FairLinkManager.cxx
+
+sim/FairBaseContFact.cxx
+sim/FairBaseParSet.cxx
+sim/FairGeoParSet.cxx
+sim/FairDetector.cxx
+sim/FairGeaneApplication.cxx
+sim/FairGenerator.cxx
+sim/FairGenericStack.cxx
+sim/FairIon.cxx
+sim/FairMCApplication.cxx
+sim/FairModule.cxx
+sim/FairParticle.cxx
+sim/FairPrimaryGenerator.cxx
+sim/FairRunIdGenerator.cxx
+sim/FairVolume.cxx
+sim/FairVolumeList.cxx
+
+event/FairEventBuilder.cxx
+event/FairEventBuilderManager.cxx
+event/FairEventHeader.cxx
+event/FairFileHeader.cxx
+event/FairFileInfo.cxx
+event/FairHit.cxx
+event/FairLink.cxx
+event/FairMCEventHeader.cxx
+event/FairMCPoint.cxx
+event/FairMesh.cxx
+event/FairMultiLinkedData.cxx
+event/FairMultiLinkedData_Interface.cxx
+event/FairRadLenPoint.cxx
+event/FairRadMapPoint.cxx
+event/FairRecoEventHeader.cxx
+event/FairRunInfo.cxx
+event/FairTimeStamp.cxx
+event/FairTrackParam.cxx
+
+field/FairField.cxx
+field/FairFieldFactory.cxx
+field/FairRKPropagator.cxx
+
+source/FairSource.cxx
+source/FairFileSource.cxx
+source/FairMixedSource.cxx
+source/FairOnlineSource.cxx
 )
 
-Set(HEADERS )
+If(BUILD_MBS)
+  Set(SRCS
+      ${SRCS}
+      source/FairLmdSource.cxx
+      source/FairRemoteSource.cxx
+      source/FairMbsSource.cxx
+      source/FairUnpack.cxx
+      source/MRevBuffer.cxx
+      source/FairMbsStreamSource.cxx
+   )
+
+  Set(NO_DICT_SRCS 
+      source/exitCli.c
+      source/rclose.c
+      source/swaplw.c
+  )
+
+  Set(DEPENDENCIES 
+      ParBase GeoBase FairTools MbsAPI
+      Proof GeomPainter Geom VMC EG MathCore Physics 
+      Matrix Tree Hist RIO RHTTP Core
+  )
+
+  Set(DEFINITIONS BUILD_MBS)
+Else(BUILD_MBS)
+  Set(DEPENDENCIES 
+      ParBase GeoBase FairTools 
+      Proof GeomPainter Geom VMC EG MathCore Physics 
+      Matrix Tree Hist RIO RHTTP Core
+  )
+EndIf(BUILD_MBS)
+
+EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE} 
+    ARGS "--has-gdml"
+    OUTPUT_VARIABLE ROOT_HAS_GDML )
+
+If ( ${ROOT_HAS_GDML} STREQUAL yes )
+  Message(STATUS "Build CbmModule with Gdml support")
+  Add_Definitions(-DROOT_HAS_GDML)
+EndIf ( ${ROOT_HAS_GDML} STREQUAL yes )
+
+If ( ${ROOT_HAS_GDML} STREQUAL yes )
+ Set (DEPENDENCIES ${DEPENDENCIES} Gdml)
+EndIf ( ${ROOT_HAS_GDML} STREQUAL yes )
+
 Set(LINKDEF FairLinkDef.h)
 Set(LIBRARY_NAME Base)
-Set(DEPENDENCIES 
-    FairTools ParBase GeoBase 
-    Proof GeomPainter Geom VMC EG MathCore Physics 
-    Matrix Tree Hist RIO Cint Core
-)
 
 GENERATE_LIBRARY()
 
diff --git a/base/FairAnaSelector.cxx b/base/FairAnaSelector.cxx
deleted file mode 100644
index 6280e4e..0000000
--- a/base/FairAnaSelector.cxx
+++ /dev/null
@@ -1,317 +0,0 @@
-// -------------------------------------------------------------------------
-// -----            FairAnaSelector source file                        -----
-// -----            Created 14/10/11  by R. Karabowicz                 -----
-// -----            Updated 01/02/12  by R. Karabowicz                 -----
-// -------------------------------------------------------------------------
-
-#include "FairAnaSelector.h"
-
-
-#include "TFile.h"
-#include "TProofOutputFile.h"
-#include "TH2.h"
-#include "TSystem.h"
-#include "TStyle.h"
-#include "TCanvas.h"
-#include "TProofServ.h"
-
-#include "FairTask.h"
-#include "FairRunAna.h"
-#include "FairRuntimeDb.h"
-#include "FairParRootFileIo.h"
-#include "FairParAsciiFileIo.h"
-
-#include <iostream>
-#include <iomanip>
-#include <map>
-
-using std::cout;
-using std::cerr;
-using std::endl;
-using std::pair;
-using std::setw;
-using std::left;
-using std::right;
-using std::fixed;
-using std::setprecision;
-using std::map;
-
-//_____________________________________________________________________________
-void FairAnaSelector::Init(TTree* tree)
-{
-  // The Init() function is called when the selector needs to initialize
-  // a new tree or chain. Typically here the branch addresses and branch
-  // pointers of the tree will be set.
-  // It is normally not necessary to make changes to the generated
-  // code, but the routine can be extended by the user if needed.
-  // Init() will be called many times when running on PROOF
-  // (once per file to be processed).
-  if (!tree) {
-    cout << "-W- FairAnaSelector::Init(): There is no tree." << endl;
-    return;
-  } else {
-    cout << "-I- FairAnaSelector::Init(): Got tree     : \"" << tree << "\"" << endl;
-    cout << "-I- FairAnaSelector::Init(): Tree name    : \"" << tree->GetName() << "\"" << endl;
-    cout << "-I- FairAnaSelector::Init(): Tree title   : \"" << tree->GetTitle() << "\"" << endl;
-    cout << "-I- FairAnaSelector::Init(): Tree filename: \"" << tree->GetCurrentFile()->GetName() << "\"" << endl;
-  }
-
-  if ( fRunAna ) {
-    cout << "-I- FairAnaSelector::Init(): Already have fRunAna." << endl;
-
-    cout << "-I- FairAnaSelector::Init(): SetInTree(" << tree << ")" << endl;
-    fRunAna->SetInTree(tree);
-    cout << "-I- FairAnaSelector::Init(): SetInTree done" << endl;
-
-    FairRootManager* ioman = FairRootManager::Instance();
-    ioman->OpenInTree();
-
-    cout << "Containers static? " << (fRunAna->GetContainerStatic()?"YES":"NO") << endl;
-    if ( !fRunAna->GetContainerStatic() ) {
-      fRunAna->InitContainers();
-    }
-  } else {
-    cout << "-I- FairAnaSelector::Init(): Have to create fRunAna." << endl;
-
-    TString vmcPath = gSystem->Getenv("VMCWORKDIR");
-
-    TNamed* contStat    = (TNamed*) fInput->FindObject("FAIRRUNANA_fContainerStatic");
-    TNamed* outStat     = (TNamed*) fInput->FindObject("FAIRRUNANA_fProofOutputStatus");
-    TNamed* outFile     = (TNamed*) fInput->FindObject("FAIRRUNANA_fOutputFileName");
-    TNamed* outDir      = (TNamed*) fInput->FindObject("FAIRRUNANA_fOutputDirectory");
-    TNamed* par1Name    = (TNamed*) fInput->FindObject("FAIRRUNANA_fParInput1FName");
-    TNamed* par2Name    = (TNamed*) fInput->FindObject("FAIRRUNANA_fParInput2FName");
-    TString containerS  = contStat->GetTitle();
-    TString outputStat  = outStat->GetTitle();
-    TString par1Str     = par1Name->GetTitle();
-    TString par2Str     = par2Name->GetTitle();
-    TString outFileName = outFile->GetTitle();
-    TString outDirName  = outDir->GetTitle();
-
-    cout << "-I- FairAnaSelector::Init(): out status   : \"" << outputStat.Data() << "\"" << endl;
-    cout << "-I- FairAnaSelector::Init(): par1 file    : \"" << par1Str.Data() << "\"" << endl;
-    cout << "-I- FairAnaSelector::Init(): par2 file    : \"" << par2Str.Data() << "\"" << endl;
-
-    if ( outputStat != "copy" ) {
-      cout << "-I- FairAnaSelector::Init(): OutputFile option \"" << outputStat.Data() << "\" not yet supported, will \"copy\" anyways" << endl;
-    }
-
-    cout << "-I- FairAnaSelector::Init(): OutputFile option \"" << outputStat.Data() << "\" RECOGNIZED" << endl;
-
-    cout << "-I- FairAnaSelector::Init(): gSystem->WorkingDirectory() = \""
-         << gSystem->WorkingDirectory() << "\"" << endl;
-    TString workDir = gSystem->WorkingDirectory();
-
-    //KG right number of the workers
-    /*Int_t workerNumber = -1; // is there better way to get it?
-
-    for ( Int_t iposWork = 0 ; iposWork < 100 ; iposWork++ ) {
-      TString tempStr = Form("-0.%d",iposWork);
-      if ( workDir.Contains(tempStr.Data()) ) {
-        workerNumber = iposWork;
-        break;
-      }
-    }*/
-    Int_t workerNumber = -1;
-    TString strWorkerNumber = ((TString)gProofServ->GetOrdinal()).Remove(0,2);
-    if (strWorkerNumber.IsDigit()) workerNumber = strWorkerNumber.Atoi();
-
-    if ( workerNumber == -1 ) {
-      cout << "-E- FairAnaSelector::Init(): Did not recognize worker number." << endl;
-    } else {
-      cout << "-I- FairAnaSelector::Init(): worker number = " << workerNumber << endl;
-    }
-
-    outFileName.Remove(outFileName.Length()-5);
-    TString outputFileName = Form("%s/%s_worker_0.%d.root",outDirName.Data(),outFileName.Data(),workerNumber);
-
-    cout << "-I- FairAnaSelector::Init(): output will go to file: \"" << outputFileName.Data() << "\"" << endl;
-    fFile = TFile::Open(outputFileName.Data(),"RECREATE");
-
-    fRunAna = new FairRunAna();
-    fRunAna->SetRunOnProofWorker();
-
-    cout << "-I- FairAnaSelector::Init(): SetInTree(" << tree << ")" << endl;
-    fRunAna->SetInTree(tree);
-    cout << "-I- FairAnaSelector::Init(): SetInTree done" << endl;
-
-    fRunAna->SetOutputFile(fFile);
-    if ( containerS == "kTRUE" ) {
-      fRunAna->SetContainerStatic(kTRUE);
-    } else {
-      fRunAna->SetContainerStatic(kFALSE);
-    }
-
-    // -----  Parameter database   --------------------------------------------
-    FairRuntimeDb* rtdb = fRunAna->GetRuntimeDb();
-
-    if ( par1Str.Contains(".root") ) {
-      FairParRootFileIo* parInput1 = new FairParRootFileIo();
-      parInput1->open(par1Str.Data());
-      rtdb->setFirstInput (parInput1);
-    }
-    if ( par1Str.Contains(".par") ) {
-      FairParAsciiFileIo* parInput1 = new FairParAsciiFileIo();
-      parInput1->open(par1Str.Data(),"in");
-      rtdb->setFirstInput (parInput1);
-    }
-
-    if ( par2Str.Contains(".root") ) {
-      FairParRootFileIo* parInput2 = new FairParRootFileIo();
-      parInput2->open(par2Str.Data());
-      rtdb->setSecondInput(parInput2);
-    }
-    if ( par2Str.Contains(".par") ) {
-      FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
-      parInput2->open(par2Str.Data(),"in");
-      rtdb->setSecondInput(parInput2);
-    }
-
-    // ------------------------------------------------------------------------
-
-    FairTask* fairTaskList = dynamic_cast<FairTask*>(fInput->FindObject("FairTaskList"));
-    cout << "-I- FairAnaSelector::Init(): FairTask = \"" << fairTaskList << "\"" << endl;
-
-    if ( 1 == 0 ) {
-      cout << "fairTaskList->Print()" << endl;
-      fairTaskList->Print();
-      cout << "fairTaskList->ls()" << endl;
-      fairTaskList->ls();
-      cout << "fairTaskList finished" << endl;
-    }
-
-    fRunAna->SetTask(fairTaskList);
-
-    cout << "-I- FairAnaSelector::Init(): vvvvv fRunAna->Init() vvvvv" << endl;
-    fRunAna->Init();
-    cout << "-I- FairAnaSelector::Init(): ^^^^^ fRunAna->Init() ^^^^^" << endl;
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairAnaSelector::Notify()
-{
-  // The Notify() function is called when a new file is opened. This
-  // can be either for a new TTree in a TChain or when when a new TTree
-  // is started when using PROOF. It is normally not necessary to make changes
-  // to the generated code, but the routine can be extended by the
-  // user if needed. The return value is currently not used.
-  cout << "-I- FairAnaSelector::Notify()" << endl;
-
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairAnaSelector::Begin(TTree* /*tree*/)
-{
-  // The Begin() function is called at the start of the query.
-  // When running with PROOF Begin() is only called on the client.
-  // The tree argument is deprecated (on PROOF 0 is passed).
-  cout << "-I- FairAnaSelector::Begin()" << endl;
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairAnaSelector::SlaveBegin(TTree* tree)
-{
-  // The SlaveBegin() function is called after the Begin() function.
-  // When running with PROOF SlaveBegin() is called on each slave server.
-  // The tree argument is deprecated (on PROOF 0 is passed).
-  cout << "-I- FairAnaSelector::SlaveBegin(): Tree address   : \"" << tree << "\"" << endl;
-
-  // useless, because have no tree anyways in slavebegin, init will be anyways called whenever a new tree comes
-  //  Init(tree);
-
-  cout << "-I- FairAnaSelector::SlaveBegin(): finishing" << endl;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairAnaSelector::Process(Long64_t entry)
-{
-  // The Process() function is called for each entry in the tree (or possibly
-  // keyed object in the case of PROOF) to be processed. The entry argument
-  // specifies which entry in the currently loaded tree is to be processed.
-  // It can be passed to either FairAnaSelector::GetEntry() or TBranch::GetEntry()
-  // to read either all or the required parts of the data. When processing
-  // keyed objects with PROOF, the object is already loaded and is available
-  // via the fObject pointer.
-  //
-  // This function should contain the "body" of the analysis. It can contain
-  // simple or elaborate selection criteria, run algorithms on the data
-  // of the event and typically fill histograms.
-  //
-  // The processing can be stopped by calling Abort().
-  //
-  // Use fStatus to set the return value of TTree::Process().
-  //
-  // The return value is currently not used.
-  //  cout << "-I- FairAnaSelector::Process(): Proceeding to analyze event " << entry << "." << endl;
-
-  fRunAna->RunOneEvent(entry);
-
-  //  cout << "-I- FairAnaSelector::Process(): Event " << entry << " analyzed." << endl;
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairAnaSelector::SlaveTerminate()
-{
-  // The SlaveTerminate() function is called after all entries or objects
-  // have been processed. When running with PROOF SlaveTerminate() is called
-  // on each slave server.
-  if ( !fRunAna ) { return; }
-
-  if ( !fProofFile ) {
-    cout << "-I- FairAnaSelector::SlaveTerminate(): Calling fRunAna->TerminateRun()" << endl;
-    fRunAna->TerminateRun();
-  }
-
-  cout << "-I- FairAnaSelector::SlaveTerminate(): fProofFile = \"" << fProofFile << "\"" << endl;
-  cout << "-I- FairAnaSelector::SlaveTerminate():      fFile = \"" << fFile << "\"" << endl;
-
-  cout << "-I- FairAnaSelector::SlaveTerminate(): WorkingDirectory = \"" << gSystem->WorkingDirectory() << "\"" << endl;
-
-  if ( fProofFile ) {
-
-    cout << "-------------------------------- fOutput->ls()" << endl;
-    fOutput->ls();
-    cout << "-------------------------------- fOutput->Print()" << endl;
-    fOutput->Print();
-    cout << "-------------------------------- fProofFile->Print()" << endl;
-    fProofFile->Print();
-    cout << "--------------------------------" << endl;
-
-    cout << "-I- FairAnaSelector::SlaveTerminate(): fOutput->Add(fProofFile);" << endl;
-    fOutput->Add(fProofFile);
-
-    cout << "-------------------------------- fProofFile->Print()" << endl;
-    fProofFile->Print();
-    cout << "--------------------------------" << endl;
-
-    cout << "-I- FairAnaSelector::SlaveTerminate(): fFile->Close();" << endl;
-    fRunAna->TerminateRun();
-    //    fFile->Close();
-
-  }
-
-  cout << "-I- FairAnaSelector::SlaveTerminate(): Finishing..." << endl;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairAnaSelector::Terminate()
-{
-  // The Terminate() function is the last function to be called during
-  // a query. It always runs on the client, it can be used to present
-  // the results graphically or save the results to file.
-  cout << "-I- FairAnaSelector::Terminate(): fOutput->ls()" << endl;
-  fOutput->ls();
-  cout << "-I- FairAnaSelector::Terminate(): -------------" << endl;
-}
-//_____________________________________________________________________________
diff --git a/base/FairAnaSelector.h b/base/FairAnaSelector.h
deleted file mode 100644
index 5c1bbf5..0000000
--- a/base/FairAnaSelector.h
+++ /dev/null
@@ -1,64 +0,0 @@
-// -------------------------------------------------------------------------
-// -----            FairAnaSelector header file                        -----
-// -----            Created 14/10/11  by R. Karabowicz                 -----
-// -----            Updated 01/02/12  by R. Karabowicz                 -----
-// -------------------------------------------------------------------------
-
-#ifndef FAIRANASELECTOR_H
-#define FAIRANASELECTOR_H
-
-#include "TROOT.h"
-#include "TChain.h"
-#include "TFile.h"
-#include "TProofOutputFile.h"
-#include "TSelector.h"
-#include "TH1F.h"
-#include "TVector3.h"
-#include "TClonesArray.h"
-
-class FairRunAna;
-
-class FairAnaSelector : public TSelector
-{
-  public :
-    TProofOutputFile*     fProofFile;
-    TFile*          fFile;
-    TTree*          fChain;   //!pointer to the analyzed TTree or TChain
-    FairRunAna*     fRunAna;
-
-    FairAnaSelector(TTree* /*tree*/ =0) : fProofFile(0), fFile(0), fChain(0), fRunAna(NULL) { }
-    virtual ~FairAnaSelector() { }
-    virtual Int_t   Version() const {
-      return 1;
-    }
-    virtual void    Begin(TTree* tree);
-    virtual void    SlaveBegin(TTree* tree);
-    virtual void    Init(TTree* tree);
-    virtual Bool_t  Notify();
-    virtual Bool_t  Process(Long64_t entry);
-    virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) {
-      return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
-    }
-    virtual void    SetOption(const char* option) {
-      fOption = option;
-    }
-    virtual void    SetObject(TObject* obj) {
-      fObject = obj;
-    }
-    virtual void    SetInputList(TList* input) {
-      fInput = input;
-    }
-    virtual TList*  GetOutputList() const {
-      return fOutput;
-    }
-    virtual void    SlaveTerminate();
-    virtual void    Terminate();
-
-    void SetFairRunAna(FairRunAna* runAna) {
-      fRunAna = runAna;
-    }
-
-    ClassDef(FairAnaSelector,0);
-};
-
-#endif //FAIRANASELECTOR_H
diff --git a/base/FairBaseContFact.h b/base/FairBaseContFact.h
deleted file mode 100644
index fe28908..0000000
--- a/base/FairBaseContFact.h
+++ /dev/null
@@ -1,27 +0,0 @@
-#ifndef FAIRBASECONTFACT_H
-#define FAIRBASECONTFACT_H
-
-
-
-#include "FairContFact.h"
-
-class FairContainer;
-
-class FairBaseContFact : public FairContFact
-{
-    /** Factory for all Base parameter containers */
-  private:
-    void setAllContainers();
-  public:
-    /**default ctor*/
-    FairBaseContFact();
-    /**default dtor*/
-    ~FairBaseContFact() {}
-    /** Calls the constructor of the corresponding parameter container.
-     * For an actual context, which is not an empty string and not the default context
-     * of this container, the name is concatinated with the context. */
-    FairParSet* createContainer(FairContainer*);
-    ClassDef( FairBaseContFact,0)
-};
-
-#endif  /* !FAIRBASECONTFACT_H */
diff --git a/base/FairDetector.cxx b/base/FairDetector.cxx
deleted file mode 100644
index 9b98428..0000000
--- a/base/FairDetector.cxx
+++ /dev/null
@@ -1,93 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                    FairDetector source file                   -----
-// -----            Created 06/01/04  by M. Al-Turany/ D. Bertini      -----
-// -------------------------------------------------------------------------
-
-
-
-#include "FairDetector.h"
-
-
-#include "FairModule.h"
-#include "FairVolume.h"
-#include "FairGeoNode.h"
-
-
-#include "TVirtualMC.h"
-#include "TString.h"
-#include "TFolder.h"
-#include "TROOT.h"
-
-FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId )
-  :FairModule(Name, "FAIR Detector", Active),
-   fDetId(DetId)
-{
-  flGeoPar = new TList();
-  TString lname( GetName());
-  lname += "GeoPar";
-  flGeoPar->SetName(lname.Data());
-  kGeoSaved = kFALSE;
-
-
-}
-FairDetector::~FairDetector()
-{
-
-  if ( flGeoPar ) { delete flGeoPar; }
-
-}
-
-FairDetector::FairDetector()
-  :fDetId(0)
-{
-
-}
-
-void   FairDetector::Initialize()
-{
-// Registers hits collection in Root manager;
-// sets sensitive volumes.
-// ---
-  Int_t NoOfEntries=svList->GetEntries();
-  Int_t fMCid;
-  FairGeoNode* fN;
-  TString cutName;
-  TString copysign="#";
-  for (Int_t i = 0 ; i < NoOfEntries ; i++ )  {
-    FairVolume* aVol = (FairVolume*) svList->At(i);
-    cutName = aVol->GetName();
-    Ssiz_t pos = cutName.Index (copysign, 1);
-//      std::cout << " Ssiz_t= cutName" << pos << " Name  " << cutName << std::endl;
-    if(pos>1) { cutName.Resize(pos); }
-    if ( aVol->getModId() == GetModId()  ) {
-      fMCid=gMC->VolId(cutName.Data());
-      aVol->setMCid(fMCid);
-      fN=aVol->getGeoNode();
-      if (fN) { fN->setMCid(fMCid); }
-    }
-  }
-
-}
-
-void FairDetector::SaveGeoParams()
-{
-
-  if ( ! kGeoSaved  ) {
-    std::cout << " -I FairDetector: " << GetName() << " Geometry parameters saved ... " << std::endl;
-    TFolder* mf = (TFolder*) gROOT->FindObjectAny("cbmroot");
-    TFolder* stsf = NULL;
-    if (mf ) { stsf = (TFolder*) mf->FindObjectAny(GetName()); }
-    if (stsf) {
-      TFolder* newf = stsf->AddFolder("Parameters","Detector parameters",NULL);
-      newf->Add( flGeoPar ) ;
-    }
-    kGeoSaved = kTRUE;
-  }
-}
-
-
-ClassImp(FairDetector)
-
-
-
-
diff --git a/base/FairDoubleHit.cxx b/base/FairDoubleHit.cxx
deleted file mode 100644
index 1a0f516..0000000
--- a/base/FairDoubleHit.cxx
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Generated by Together */
-
-#include "FairDoubleHit.h"
-
-FairDoubleHit::FairDoubleHit():
-  fRefIndex(-1),
-  fDetectorID(-1),
-  fPosition_in(),
-  fPositionError_in(),
-  fPosition_out(),
-  fPositionError_out()
-{
-
-}
-
-FairDoubleHit::~FairDoubleHit()
-{
-
-}
-
-ClassImp(FairDoubleHit)
-
-
diff --git a/base/FairGenerator.cxx b/base/FairGenerator.cxx
deleted file mode 100644
index 0cc4b43..0000000
--- a/base/FairGenerator.cxx
+++ /dev/null
@@ -1,28 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                     FairGenerator source file                 -----
-// -------------------------------------------------------------------------
-
-
-#include "FairGenerator.h"
-
-
-// -----   Default constructor   -------------------------------------------
-FairGenerator::FairGenerator()
-  : TNamed() {}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Constructor with name and title   -------------------------------
-FairGenerator::FairGenerator(const char* name, const char* title)
-  : TNamed(name, title) {}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Destructor   ----------------------------------------------------
-FairGenerator::~FairGenerator() { }
-// -------------------------------------------------------------------------
-
-
-ClassImp(FairGenerator)
diff --git a/base/FairLink.h b/base/FairLink.h
deleted file mode 100644
index f24b217..0000000
--- a/base/FairLink.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * FairLink.h
- *
- *  Created on: Dec 23, 2009
- *      Author: stockman
- */
-
-#ifndef FAIRLINK_H_
-#define FAIRLINK_H_
-
-#include "TObject.h"
-#include "TString.h"
-
-#include <utility>
-#include <iostream>
-
-class FairLink : public TObject
-{
-  public:
-    FairLink();
-    FairLink(Int_t type, Int_t index, Float_t weight = 1.);
-    FairLink(TString branchName, Int_t index, Float_t weight = 1.);
-    FairLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.);
-    FairLink(Int_t file, Int_t entry, TString branchName, Int_t index, Float_t weight = 1.);
-    virtual ~FairLink();
-
-    void SetLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.) {
-      fFile = file;
-      fEntry = entry;
-      fType = type;
-      fIndex = index;
-      fWeight = weight;
-    };
-    void SetLink(Int_t type, Int_t index, Float_t weight = 1.) {
-      fFile = -1;
-      fEntry = -1;
-      fType = type;
-      fIndex = index;
-      fWeight = weight;
-    };
-    Int_t GetFile() const {return fFile;}
-    Int_t GetEntry() const {return fEntry;}
-    Int_t GetType() const {return fType;}
-    Int_t GetIndex() const {return fIndex;}
-    Float_t GetWeight() const {return fWeight;}
-
-    void SetWeight(Float_t weight) {fWeight = weight;}
-    void AddWeight(Float_t weight) {fWeight += weight;}
-
-    virtual void Print(std::ostream& out = std::cout) const;
-
-    virtual bool operator==(const FairLink& link) const {
-      if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType == link.GetType() && fIndex == link.GetIndex()) {
-        return true;
-      } else {
-        return false;
-      }
-    }
-
-    virtual bool operator<(const FairLink& link) const {
-      if (fFile < link.GetFile()) {
-        return true;
-      } else if (fFile == link.GetFile() && fEntry < link.GetEntry()) {
-        return true;
-      } else if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType < link.GetType()) {
-        return true;
-      } else if (fFile == link.GetFile() && fEntry == link.GetEntry() && fType == link.GetType() && fIndex < link.GetIndex()) {
-        return true;
-      } else {
-        return false;
-      }
-    }
-
-    friend std::ostream& operator<< (std::ostream& out, const FairLink& link) {
-      link.Print(out);
-      return out;
-    }
-
-    ClassDef(FairLink, 3);
-
-
-  private:
-    Int_t fFile;
-    Int_t fEntry;
-    Int_t fType;
-    Int_t fIndex;
-    Float_t fWeight;
-
-};
-
-#endif /* FAIRLINK_H_ */
diff --git a/base/FairLinkDef.h b/base/FairLinkDef.h
index 0f001b7..88be801 100644
--- a/base/FairLinkDef.h
+++ b/base/FairLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // $Id: FairLinkDef.h,v 1.4 2006/09/15 12:43:35 turany Exp $
 
 #ifdef __CINT__
@@ -8,7 +15,10 @@
 
 #pragma link C++ class FairBaseContFact;
 #pragma link C++ class FairBaseParSet;
+#pragma link C++ class FairGeoParSet;
 #pragma link C++ class FairDetector+;
+#pragma link C++ class FairEventBuilder+;
+#pragma link C++ class FairEventBuilderManager+;
 #pragma link C++ class FairEventHeader;
 #pragma link C++ class FairFileHeader+;
 #pragma link C++ class FairGeaneApplication+;
@@ -17,6 +27,7 @@
 //#pragma link C++ class FairLinkedData+;
 //#pragma link C++ class FairSingleLinkedData+;
 #pragma link C++ class FairMultiLinkedData+;
+#pragma link C++ class FairMultiLinkedData_Interface+;
 //#pragma link C++ class FairBasePoint+;
 #pragma link C++ class FairHit+;
 #pragma link C++ class FairIon+;
@@ -26,9 +37,11 @@
 #pragma link C++ class FairModule-;
 #pragma link C++ class FairParticle+;
 #pragma link C++ class FairPrimaryGenerator+;
+#pragma link C++ class FairRecoEventHeader+;
 #pragma link C++ class FairRootManager+;
 #pragma link C++ class FairRun+;
 #pragma link C++ class FairRunAna;
+#pragma link C++ class FairRunAnaProof;
 #pragma link C++ class FairRunIdGenerator;
 #pragma link C++ class FairRunSim;
 #pragma link C++ class FairTrackParam+;
@@ -54,6 +67,23 @@
 #pragma link C++ class FairRingSorter;
 #pragma link C++ class FairRingSorterTask;
 #pragma link C++ class FairAnaSelector+;
+#pragma link C++ class FairLinkManager+;
+
+
+#pragma link C++ class FairRunOnline;
+#pragma link C++ class FairSource;
+#pragma link C++ class FairFileSource;
+#pragma link C++ class FairMixedSource;
+#pragma link C++ class FairOnlineSource;
+#ifdef BUILD_MBS
+#pragma link C++ class FairMbsSource;
+#pragma link C++ class FairRemoteSource;
+#pragma link C++ class FairMbsStreamSource;
+#pragma link C++ class FairLmdSource;
+#pragma link C++ class FairUnpack;
+#pragma link C++ class MRevBuffer;
+#pragma link C++ class REvent;
+#endif
 
 #if ROOT_VERSION_CODE < 333824
 #pragma link C++ class TVirtualMagField+;
diff --git a/base/FairMCApplication.cxx b/base/FairMCApplication.cxx
deleted file mode 100644
index 701b945..0000000
--- a/base/FairMCApplication.cxx
+++ /dev/null
@@ -1,1098 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                    FairDetector source file                   -----
-// -----            Created 06/01/04  by M. Al-Turany                  -----
-// -------------------------------------------------------------------------
-
-
-#include "FairMCApplication.h"
-#include "FairGenericStack.h"
-#include "FairField.h"
-#include "FairModule.h"
-#include "FairDetector.h"
-#include "FairRunSim.h"
-#include "FairIon.h"
-#include "FairMCEventHeader.h"
-#include "FairEventHeader.h"
-#include "FairPrimaryGenerator.h"
-#include "FairTrajFilter.h"
-#include "FairRootManager.h"
-#include "FairTask.h"
-#include "FairVolume.h"
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
-#include "FairGeoMedia.h"
-#include "FairGeoMedium.h"
-#include "FairRadLenManager.h"
-#include "FairRadGridManager.h"
-#include "FairRadMapManager.h"
-#include "FairMesh.h"
-#include "FairRuntimeDb.h"
-#include "FairLogger.h"
-#include "FairRunInfo.h"
-
-#include "TObjArray.h"
-#include "TGeoTrack.h"
-#include "TGeoVolume.h"
-#include "TParticle.h"
-#include "TGeoManager.h"
-#include "TRefArray.h"
-#include "TROOT.h"
-#include "TInterpreter.h"
-#include "TVirtualMC.h"
-#include "TDatabasePDG.h"
-#include "TGeoTrack.h"
-#include "TGeoVolume.h"
-#include "TParticle.h"
-#include "TGeoManager.h"
-#include "TParticlePDG.h"
-#include "TMCParticleType.h"
-#include "THashList.h"
-#include "TSystem.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-using std::pair;
-//_____________________________________________________________________________
-FairMCApplication::FairMCApplication(const char* name, const char* title,
-                                     TObjArray* ModList, const char* MatName)
-  :TVirtualMCApplication(name,title),
-   fActDetIter(NULL),
-   fActiveDetectors(NULL),
-   fFairTaskList(NULL),
-   fDetIter(NULL),
-   fDetectors(NULL),
-   fDetMap(NULL),
-   fLogger(FairLogger::GetLogger()),
-   fModIter(NULL),
-   fModules(NULL),
-   fNoSenVolumes(0),
-   fPythiaDecayer(kFALSE),
-   fPythiaDecayerConfig(""),
-   fStack(NULL),
-   fRootManager(NULL),
-   fSenVolumes(NULL),
-   fxField(NULL),
-   fEvGen(NULL),
-   fMcVersion(-1),
-   fTrajFilter(NULL),
-   fTrajAccepted(kFALSE),
-   fUserDecay(kFALSE),
-   fUserDecayConfig(""),
-   fDebug(kFALSE),
-   fDisVol(NULL),
-   fDisDet(NULL),
-   fVolMap(),
-   fVolIter(NULL),
-   fModVolMap(),
-   fModVolIter(NULL),
-   fTrkPos(TLorentzVector(0,0,0,0)),
-   fRadLength(kFALSE),
-   fRadLenMan(NULL),
-   fRadMap(kFALSE),
-   fRadMapMan(NULL),
-   fRadGridMan(NULL),
-   fEventHeader(NULL),
-   fMCEventHeader(NULL),
-   fRunInfo()
-{
-// Standard Simulation constructor
-// Check if the Fair root manager exist!
-  fRootManager=FairRootManager::Instance();
-// Create an ObjArray of Modules and its iterator
-  fModules=ModList;
-  fModIter = fModules->MakeIterator();
-// Create and fill a list of active detectors
-  fDetectors=new TRefArray;
-  fActiveDetectors=new TRefArray();
-  fModIter->Reset();
-  FairDetector* detector;
-  TObject* obj;
-  while((obj=fModIter->Next())) {
-    if(obj->InheritsFrom("FairDetector")) {
-      detector=(FairDetector*)obj;
-      fDetectors->Add(detector);
-      if(detector->IsActive()) {
-        fActiveDetectors->Add(detector);
-      }
-    }
-  }
-  fDetIter=fDetectors->MakeIterator();
-  fActDetIter=fActiveDetectors->MakeIterator();
-// Create a Task list
-  fFairTaskList= new FairTask("Task List", 1);
-  gROOT->GetListOfBrowsables()->Add(fFairTaskList);
-  fMcVersion=-1;
-  // Initialise fTrajFilter pointer
-  fTrajFilter = NULL;
-  fDetMap=new TRefArray(1000);
-  fDisVol=0;
-  fDisDet=0;
-
-}
-//_____________________________________________________________________________
-FairMCApplication::FairMCApplication()
-  :TVirtualMCApplication(),
-   fActDetIter(0),
-   fActiveDetectors(0),
-   fFairTaskList(0),
-   fDetIter(0),
-   fDetectors(0),
-   fDetMap(0),
-   fLogger(FairLogger::GetLogger()),
-   fModIter(0),
-   fModules(0),
-   fNoSenVolumes(0),
-   fPythiaDecayer(kFALSE),
-   fPythiaDecayerConfig(""),
-   fStack(0),
-   fRootManager(0),
-   fSenVolumes(0),
-   fxField(0),
-   fEvGen(0),
-   fMcVersion(-1),
-   fTrajFilter(NULL),
-   fTrajAccepted(kFALSE),
-   fUserDecay(kFALSE),
-   fUserDecayConfig(""),
-   fDebug(kFALSE),
-   fDisVol(0),
-   fDisDet(0),
-   fVolMap(),
-   fVolIter(NULL),
-   fModVolMap(),
-   fModVolIter(NULL),
-   fTrkPos(TLorentzVector(0,0,0,0)),
-   fRadLength(kFALSE),
-   fRadLenMan(NULL),
-   fRadMap(kFALSE),
-   fRadMapMan(NULL),
-   fRadGridMan(NULL),
-   fEventHeader(NULL),
-   fMCEventHeader(NULL),
-   fRunInfo()
-{
-// Default constructor
-}
-//_____________________________________________________________________________
-FairMCApplication::~FairMCApplication()
-{
-// Destructor
-//   cout<<"Enter Destructor of FairMCApplication"<<endl;
-  delete fStack;
-  delete fActiveDetectors; // don't do fActiveDetectors->Delete() here
-  // the modules are already deleted in FairRunSim
-  delete fActDetIter;
-  delete fDetectors;
-  delete gMC;
-  gMC=0;
-  //   cout<<"Leave Destructor of FairMCApplication"<<endl;
-}
-//_____________________________________________________________________________
-void FairMCApplication::RegisterStack()
-{
-// Registers stack in Root manager.
-//  cout << "FairMCApplication::RegisterStack() " << endl;
-  if(fEvGen) {
-    fStack->Register();
-  }
-}
-//_____________________________________________________________________________
-void FairMCApplication::InitMC(const char* setup, const char* cuts)
-{
-// Initialize MC.
-// ---
-  fStack = (FairGenericStack*) gMC->GetStack();
-
-#if ROOT_VERSION_CODE >= 333824
-  gMC->SetMagField(fxField);
-#endif
-
-  gMC->Init();
-  gMC->BuildPhysics();
-  TString MCName=gMC->GetName();
-  if     (MCName == "TGeant3" || MCName == "TGeant3TGeo") {
-    fMcVersion = 0 ;
-  } else if(MCName == "TGeant4") {
-    fMcVersion = 1;
-  } else if(MCName == "TFluka") {
-    fMcVersion = 2;
-  } else {
-    fMcVersion = 3;  //Geane
-  }
-  fTrajFilter = FairTrajFilter::Instance();
-
-  fLogger->Info(MESSAGE_ORIGIN, "Monte carlo Engine Initialisation  with : %s  ", MCName.Data());
-}
-//_____________________________________________________________________________
-void FairMCApplication::RunMC(Int_t nofEvents)
-{
-  // Reset the time for FairRunInfo. Otherwise the time of the
-  // first event will include the time needed for initilization.
-  fRunInfo.Reset();
-  // MC run.
-  gMC->ProcessRun(nofEvents);
-  // finish run
-  FinishRun();
-  // Save histograms with memory and runtime information in the output file
-  if (FairRunSim::Instance()->GetWriteRunInfoFile()) {
-    fRunInfo.WriteInfo();
-  }
-}
-//____________________________________________________________________________
-void FairMCApplication::FinishRun()
-{
-// Finish MC run.
-// ---
-  if(fActDetIter) {
-    fActDetIter->Reset();
-    FairDetector* detector=NULL;
-    TObject* obj=0;
-    while((obj=fActDetIter->Next())) {
-      detector = dynamic_cast<FairDetector*>(obj);
-      if (detector) {
-        detector->FinishRun();
-      }
-    }
-  }
-  fFairTaskList->FinishTask();
-  //fRootManager->Fill();
-
-  FairPrimaryGenerator* gen = FairRunSim::Instance()->GetPrimaryGenerator();
-  //FairMCEventHeader* header = gen->GetEvent();
-  Int_t nprimary = gen->GetTotPrimary();
-  TObjArray* meshlist  = NULL;
-
-  if (fRadGridMan ) {
-    //      cout << "-I FairMCApplication::FinishRun scaling ... " << endl;
-    meshlist = fRadGridMan->GetMeshList();
-    //      cout << " entries " << meshlist->GetEntriesFast() << endl;
-    for(Int_t i=0; i<meshlist->GetEntriesFast(); i++ ) {
-      FairMesh* aMesh = (FairMesh*) meshlist->At(i);
-      aMesh->Scale(1./nprimary);
-    }
-  }
-  if (fRadGridMan) {
-    TH2D* tid = NULL;
-    TH2D* flu = NULL;
-    TH2D* seu = NULL;
-    //      cout << "-I FairMCApplication::FinishRun saving ... " << endl;
-    //      cout << " entries " << meshlist->GetEntriesFast() << endl;
-
-    cout << endl << endl;
-    cout << "======================================================="
-         << endl;
-    cout << "   Dosimetry  histos saving " << endl << endl;
-    cout << "======================================================="
-         << endl;
-    cout << endl << endl;
-
-    gDirectory->mkdir("Dosimetry");
-    gDirectory->cd("Dosimetry");
-    gDirectory->cd("");
-
-
-    for(Int_t i=0; i<meshlist->GetEntriesFast(); i++ ) {
-      FairMesh* aMesh = (FairMesh*) meshlist->At(i);
-      tid = aMesh->GetMeshTid();
-      flu = aMesh->GetMeshFlu();
-      seu = aMesh->GetMeshSEU();
-      //
-      // tid->Dump();
-      tid->Write();
-      flu->Write();
-      seu->Write();
-    }
-  }
-  gDirectory->cd("..");
-  if (!fRadGridMan) {
-    fRootManager->Write();
-  }
-
-  //  fRootManager->Write();
-
-}
-//_____________________________________________________________________________
-void FairMCApplication::BeginEvent()
-{
-// User actions at beginning of event
-// ---
-  if(fActDetIter) {
-    fActDetIter->Reset();
-    FairDetector* detector;
-    TObject* obj=0;
-    while((obj=fActDetIter->Next())) {
-      detector = dynamic_cast<FairDetector*>(obj);
-      if (detector) {
-        detector->BeginEvent();
-      }
-    }
-  }
-
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::BeginPrimary()
-{
-// User actions at beginning of a primary track
-// ---
-  if(fActDetIter) {
-    fActDetIter->Reset();
-    FairDetector* detector=NULL;
-    TObject* obj=0;
-    while((obj=fActDetIter->Next())) {
-      detector = dynamic_cast<FairDetector*>(obj);
-      if( detector ) {
-        detector->BeginPrimary();
-      }
-    }
-  }
-}
-//_____________________________________________________________________________
-void FairMCApplication::PreTrack()
-{
-
-// User actions at beginning of each track
-// ---
-
-  if(fActDetIter) {
-    fActDetIter->Reset();
-    FairDetector* detector=NULL;
-    TObject* obj=0;
-    while((obj=fActDetIter->Next())) {
-      detector = dynamic_cast<FairDetector*>(obj);
-      if (detector) {
-        detector->PreTrack();
-      }
-    }
-  }
-  fTrajAccepted=kFALSE;
-  if(NULL != fTrajFilter) {
-    // Get the pointer to current track
-    TParticle* particle = fStack->GetCurrentTrack();
-//  cout << " FairMCApplication::PreTrack()" << particle << endl;
-    // Apply cuts
-    fTrajAccepted = fTrajFilter->IsAccepted(particle);
-    if(fTrajAccepted) {
-      // Add trajectory to geo manager
-      //    Int_t trackId = fStack->GetCurrentTrackNumber();
-      TGeoTrack* fTrack=fTrajFilter->AddTrack(particle);
-      // TLorentzVector pos;
-      gMC->TrackPosition(fTrkPos);
-      fTrack->AddPoint(fTrkPos.X(), fTrkPos.Y(), fTrkPos.Z(), fTrkPos.T());
-    }
-  }
-}
-//_____________________________________________________________________________
-void FairMCApplication::Stepping()
-{
-// User actions at each step
-// ---
-  // Work around for Fluka VMC, which does not call
-  // MCApplication::PreTrack()
-  static Int_t TrackId = 0;
-  if ( fMcVersion ==2 && gMC->GetStack()->GetCurrentTrackNumber() != TrackId ) {
-    PreTrack();
-    TrackId = gMC->GetStack()->GetCurrentTrackNumber();
-  }
-  Int_t copyNo;
-  Int_t id = gMC->CurrentVolID(copyNo);
-  Bool_t InMap =kFALSE;
-  fDisVol=0;
-  fDisDet=0;
-  Int_t fCopyNo=0;
-  fVolIter =fVolMap.find(id);
-  if (fVolIter!=fVolMap.end()) {
-    do {
-      fDisVol=fVolIter->second;
-      fCopyNo=fDisVol->getCopyNo();
-      if(copyNo==fCopyNo) {
-        fDisDet=dynamic_cast<FairDetector*> (fDisVol->GetModule());
-        if (fDisDet) {
-          fDisDet->ProcessHits(fDisVol);
-        }
-        InMap=kTRUE;
-        break;
-      }
-      fVolIter++;
-    } while(fVolIter!=fVolMap.upper_bound(id));
-    if(fDisVol && !InMap) {
-      FairVolume* fNewV=new FairVolume( gMC->CurrentVolName(), id);
-      fNewV->setMCid(id);
-      fNewV->setModId(fDisVol->getModId());
-      fNewV->SetModule(fDisVol->GetModule());
-      fNewV->setCopyNo(copyNo);
-      fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
-      fDisDet=dynamic_cast<FairDetector*> (fDisVol->GetModule());
-      if ( fDisDet) {
-        fDisDet->ProcessHits(fNewV);
-      }
-    }
-  }
-  if(fTrajAccepted) {
-    if(gMC->TrackStep() > fTrajFilter->GetStepSizeCut()) {
-      gMC->TrackPosition(fTrkPos);
-      fTrajFilter->GetCurrentTrk()->AddPoint(fTrkPos.X(), fTrkPos.Y(), fTrkPos.Z(), fTrkPos.T());
-    }
-  }
-  if(fRadLenMan) {
-    id = gMC->CurrentVolID(copyNo);
-    fModVolIter =fModVolMap.find(id);
-    fRadLenMan->AddPoint(fModVolIter->second);
-  }
-  if(fRadMapMan) {
-    id = gMC->CurrentVolID(copyNo);
-    fModVolIter =fModVolMap.find(id);
-    fRadMapMan->AddPoint(fModVolIter->second);
-  }
-  if(fRadGridMan) {
-    fRadGridMan->FillMeshList();
-  }
-
-}
-//_____________________________________________________________________________
-void FairMCApplication::PostTrack()
-{
-// User actions after finishing of each track
-// ---
-  fActDetIter->Reset();
-  FairDetector* detector=NULL;
-  TObject* obj=0;
-  while((obj=fActDetIter->Next())) {
-    detector = dynamic_cast<FairDetector*>(obj);
-    if (detector ) {
-      detector->PostTrack();
-    }
-  }
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::FinishPrimary()
-{
-// User actions after finishing of a primary track
-// ---
-  if(fActDetIter) {
-    fActDetIter->Reset();
-    FairDetector* detector=NULL;
-    TObject* obj=0;
-    while((obj=fActDetIter->Next())) {
-      detector = dynamic_cast<FairDetector*>(obj);
-      if (detector) {
-        detector->FinishPrimary();
-      }
-    }
-  }
-}
-
-//_____________________________________________________________________________
-
-void FairMCApplication::StopRun()
-{
-  FinishEvent();
-  FinishRun();
-  fRootManager->Write();
-  fRootManager->CloseOutFile();
-  fLogger->Warning(MESSAGE_ORIGIN, "StopRun() exiting not safetly oopps !!!@@@!!!" );
-  exit(0) ;
-}
-//_____________________________________________________________________________
-void FairMCApplication::FinishEvent()
-{
-// User actions after finishing of an event
-// ---
-  // --> Fill the stack output array
-  fStack->FillTrackArray();
-  // --> Update track indizes in MCTracks and MCPoints
-  fStack->UpdateTrackIndex(fActiveDetectors);
-  // --> Screen output of stack
-  fFairTaskList->ExecuteTask("");
-  fFairTaskList->FinishEvent();
-  TObject* obj=NULL;
-  FairDetector* detector=NULL;
-  fActDetIter->Reset();
-
-  while((obj=fActDetIter->Next())) {
-    detector = dynamic_cast<FairDetector*>(obj);
-    if (detector) {
-      detector->FinishEvent();
-    }
-  }
-
-  fRootManager->Fill();
-  fActDetIter->Reset();
-  detector=NULL;
-  obj=NULL;
-  while((obj=fActDetIter->Next())) {
-    detector = dynamic_cast<FairDetector*>(obj);
-    if (detector) {
-      detector->EndOfEvent();
-    }
-  }
-  fStack->Reset();
-  if(NULL != fTrajFilter) {
-    fTrajFilter->Reset();
-    TObjArray* fListOfTracks=gGeoManager->GetListOfTracks();
-    fListOfTracks->Delete();
-  }
-  if(NULL !=fRadLenMan) {
-    fRadLenMan->Reset();
-  }
-  if(NULL !=fRadMapMan) {
-    fRadMapMan->Reset();
-  }
-
-  // Store information about runtime for one event and memory consuption
-  // for later usage.
-  fRunInfo.StoreInfo();
-}
-//_____________________________________________________________________________
-Double_t FairMCApplication::TrackingRmax() const
-{
-// No limit
-// ---
-  return DBL_MAX;
-}
-//_____________________________________________________________________________
-Double_t FairMCApplication::TrackingZmax() const
-{
-// No limit
-// ---
-  return DBL_MAX;
-}
-
-#if ROOT_VERSION_CODE < 333824
-//_____________________________________________________________________________
-void FairMCApplication::Field(const Double_t* x, Double_t* b) const
-{
-// put here a const magnetic field as 0th approx
-// ---
-// cout<< "FairMCApplication::Field" <<endl;
-  b[0]=0;
-  b[1]=0;
-  b[2]=0;
-  if(fxField) {
-    fxField->GetFieldValue(x,b);
-//     cout << " FairMCApplication::Field the old way of getting field " << endl;
-  }
-}
-#endif
-//_____________________________________________________________________________
-void FairMCApplication::SetField(FairField* field)
-{
-  fxField=field;
-}
-//_____________________________________________________________________________
-void FairMCApplication::ConstructOpGeometry()
-{
-  FairGeoLoader* loader=FairGeoLoader::Instance();
-  FairGeoInterface* GeoInterface =loader->getGeoInterface();
-  FairGeoMedia* media= GeoInterface->getMedia();
-  TList* MediaList= media->getListOfMedia();
-  TListIter iter(MediaList);
-  FairGeoMedium* medium;
-  Int_t NK=0;
-  Double_t p[4];
-  while((medium=(FairGeoMedium*)iter.Next())) {
-    NK=medium->getNpckov();
-    if(NK>0) {
-      Int_t Mid=0;
-      TGeoMedium* Med = 0;
-      if ( gGeoManager && (Med = gGeoManager->GetMedium(medium->GetName())) ) {
-        Mid=Med->GetId();
-      } else {
-        Mid=medium->getMediumIndex();
-        if(Mid<=0) {
-          continue;
-        }
-      }
-      Double_t ppckov[NK], absco[NK], effic[NK],rindex[NK];
-      for (Int_t i=0; i<NK; i++) {
-        medium->getCerenkovPar(i, p);
-        ppckov[i]=p[0]*1E-9;
-        absco[i]=p[1];
-        effic[i]=p[2];
-        rindex[i]=p[3];
-      }
-      gMC->SetCerenkov(Mid, NK, ppckov,absco, effic, rindex);
-    }
-  }
-  fModIter->Reset();
-  FairModule* Mod=NULL;
-  while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
-    Mod->ConstructOpGeometry();
-  }
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::ConstructGeometry()
-{
-
-  fModIter->Reset();
-  FairModule* Mod=NULL;
-  Int_t NoOfVolumes=0;
-  Int_t NoOfVolumesBefore=0;
-  Int_t ModId=0;
-  while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
-    NoOfVolumesBefore=gGeoManager->GetListOfVolumes()->GetEntriesFast();
-    Mod->ConstructGeometry();
-    ModId=Mod->GetModId();
-    NoOfVolumes=gGeoManager->GetListOfVolumes()->GetEntriesFast();
-    for (Int_t n=NoOfVolumesBefore; n <= NoOfVolumes; n++) {
-      fModVolMap.insert(pair<Int_t, Int_t >(n,ModId));
-    }
-  }
-  fSenVolumes=FairModule::svList;
-  if(fSenVolumes) {
-    fNoSenVolumes=fSenVolumes->GetEntries();
-  }
-  if (gGeoManager) {
-    //  cout << "FairMCApplication::ConstructGeometry() : Now closing the geometry"<<endl;
-    gGeoManager->CloseGeometry();   // close geometry
-    gMC->SetRootGeometry();         // notify VMC about Root geometry
-    gGeoManager->SetPdgName(22, "gamma");
-    gGeoManager->SetPdgName(211, "pi+");
-    gGeoManager->SetPdgName(321, "K+");
-    gGeoManager->SetPdgName(2212, "proton");
-    gGeoManager->SetPdgName(-211, "pi-");
-    gGeoManager->SetPdgName(-321, "K-");
-    gGeoManager->SetPdgName(111, "pi0");
-    gGeoManager->SetPdgName(310, "K0");
-    gGeoManager->SetPdgName(130, "K0");
-    gGeoManager->SetPdgName(2112, "neutron");
-    gGeoManager->SetPdgName(11, "e-");
-    gGeoManager->SetPdgName(13, "mu-");
-    gGeoManager->SetPdgName(-11, "e+");
-    gGeoManager->SetPdgName(-13, "mu+");
-    gGeoManager->SetPdgName(3312, "Xsi");
-    gGeoManager->SetPdgName(3334, "Omega");
-    gGeoManager->SetPdgName(50000050, "Ckov");
-    gGeoManager->SetPdgName(-421, "D0bar");
-    gGeoManager->SetPdgName(421, "D0");
-    gGeoManager->SetPdgName(-411, "D-");
-    gGeoManager->SetPdgName(411, "D+");
-    gGeoManager->SetPdgName(-213, "rho-");
-    gGeoManager->SetPdgName(213, "rho+");
-    gGeoManager->SetPdgName(113, "rho0");
-    gGeoManager->SetPdgName(1000010020, "Deuteron");
-    gGeoManager->SetPdgName(1000010030, "Triton");
-    gGeoManager->SetPdgName(1000020030, "HE3");
-    gGeoManager->SetPdgName(1000020040, "Alpha");
-  }
-}
-//_____________________________________________________________________________
-
-void FairMCApplication::InitGeometry()
-{
-  /// Initialize geometry
-  /** Register stack and detector collections*/
-  FairVolume* fv=0;
-  Int_t id=0;
-  fModIter->Reset();
-  FairDetector* detector=NULL;
-  if(fEvGen!=0 && fStack!=0) {
-    fStack->Register();
-  } else {
-    fLogger->Warning(MESSAGE_ORIGIN, "Stack is not registerd ");
-  }
-  /** Initialize the event generator */
-  // if(fEvGen)fEvGen->Init();
-  /** Initialize the detectors.    */
-  fActDetIter->Reset();
-  while((detector = dynamic_cast<FairDetector*>(fActDetIter->Next()))) {
-    detector->Initialize();                // initialize the detectors
-    detector->SetSpecialPhysicsCuts();     // set the detector specific detector cuts
-    detector->Register();                  //  add branches to tree
-  }
-  /**Tasks has to be initialized here, they have access to the detector branches and still can create objects in the tree*/
-  /// There is always a Main Task  !
-  /// so .. always a InitTasks() is called <D.B>
-  if (fFairTaskList) {
-    InitTasks();
-  }
-
-  // store the EventHeader Info
-  // Get and register EventHeader
-  UInt_t runId = FairRunSim::Instance()->GetRunId();
-
-  fLogger->Info(MESSAGE_ORIGIN, "Simulation RunID: %i  ", runId);
-
-  // Get and register the MCEventHeader
-  fMCEventHeader = FairRunSim::Instance()->GetMCEventHeader();
-  fMCEventHeader->SetRunID(runId);
-  fMCEventHeader->Register();
-
-  if(NULL !=fRadGridMan) {
-    fRadGridMan->Init();
-  }
-
-  if(fEvGen) {
-    fEvGen->SetEvent(fMCEventHeader);
-  }
-  fTrajFilter = FairTrajFilter::Instance();
-  if(NULL != fTrajFilter ) {
-    fTrajFilter->Init();
-  }
-  if(NULL !=fRadLenMan) {
-    fRadLenMan->Init();
-  }
-  if(NULL !=fRadMapMan) {
-    fRadMapMan->Init();
-  }
-  if(NULL !=fRadGridMan) {
-    fRadGridMan->Init();
-  }
-
-
-  /// save Geo Params in Output file
-  fRootManager->WriteFolder();
-  TTree* outTree =new TTree("cbmsim", "/cbmroot", 99);
-  fRootManager->TruncateBranchNames(outTree, "cbmroot");
-  fRootManager->SetOutTree(outTree);
-
-  for ( Int_t i = 0 ; i < fNoSenVolumes ; i++ ) {
-    fv= (FairVolume*)fSenVolumes->At(i);
-    id=fv->getMCid();
-    if(fv->getGeoNode()==0) {  //handel sensetive volumes created directly by user
-      TGeoNode* fN=0;
-      TGeoVolume* v=gGeoManager->GetVolume(fv->GetName());
-      TObjArray* fNs=0;
-      if(v) {
-        fNs=v->GetNodes();
-      }
-      if(fNs) {
-        for(Int_t k=0; k<fNs->GetEntriesFast(); k++) {
-          fN=(TGeoNode*)fNs->At(k);
-          FairVolume* fNewV=new FairVolume( fv->GetName(), id);
-          fNewV->setModId(fv->getModId());
-          fNewV->SetModule(fv->GetModule());
-          fNewV->setCopyNo(fN->GetNumber());
-          fNewV->setMCid(id);
-          fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
-        }
-      } else {
-        FairVolume* fNewV=new FairVolume( fv->GetName(), id);
-        fNewV->setModId(fv->getModId());
-        fNewV->SetModule(fv->GetModule());
-        fNewV->setCopyNo(1);
-        fNewV->setMCid(id);
-        fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
-      }
-    } else {
-      fVolMap.insert(pair<Int_t, FairVolume* >(id, fv));
-    }
-  }
-
-
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::GeneratePrimaries()
-{
-// Fill the user stack (derived from TVirtualMCStack) with primary particles.
-// ---
-  if(fEvGen) {
-//    cout << "FairMCApplication::GeneratePrimaries()" << endl;
-    if (!fEvGen->GenerateEvent( fStack) ) {
-      StopRun();
-    }
-  }
-}
-//_____________________________________________________________________________
-FairDetector* FairMCApplication::GetDetector(const char* DetName)
-{
-  return (FairDetector*)fModules->FindObject(DetName);
-}
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,17,4)
-//_____________________________________________________________________________
-void  FairMCApplication::AddIons()
-{
-  FairRunSim* fRun=FairRunSim::Instance();
-  TObjArray* NewIons=fRun->GetUserDefIons();
-  TIterator* Iter=NewIons->MakeIterator();
-  Iter->Reset();
-  TObject* obj=0;
-  FairIon* ion=0;
-  while((obj=Iter->Next())) {
-    ion=dynamic_cast <FairIon*> (obj);
-    if(ion) {
-      gMC->DefineIon(ion->GetName(), ion->GetZ(), ion->GetA(), ion->GetQ(),
-                     ion->GetExcEnergy(),ion->GetMass());
-      //Add Ion to gGeoManager visualization
-      if(gGeoManager) {
-        gGeoManager->SetPdgName(TDatabasePDG::Instance()->GetParticle(ion->GetName())->PdgCode(),ion->GetName() );
-      }
-      fLogger->Info(MESSAGE_ORIGIN, "Add Ion:  %s  with PDG  %i ", ion->GetName(), TDatabasePDG::Instance()->GetParticle(ion->GetName())->PdgCode());
-    }
-  }
-  delete   Iter;
-  /** Initialize the event generator */
-  if(fEvGen) {
-    fEvGen->Init();
-  }
-}
-#else
-void  FairMCApplication::AddIons()
-{
-  FairRunSim* fRun=FairRunSim::Instance();
-  TObjArray* NewIons=fRun->GetUserDefIons();
-  TIterator* Iter=NewIons->MakeIterator();
-  Iter->Reset();
-  TObject* obj=0;
-  FairIon* ion=0;
-  while((obj=Iter->Next())) {
-    ion=dynamic_cast <FairIon*> (obj);
-    if(ion) {
-      gMC->DefineIon(ion->GetName(), ion->GetZ(), ion->GetA(), ion->GetQ(),
-                     ion->GetExcEnergy(),ion->GetMass());
-      //Add Ion to gGeoManager visualization
-      if(gGeoManager) {
-        gGeoManager->SetPdgName(TDatabasePDG::Instance()->GetParticle(ion->GetName())->PdgCode(),ion->GetName() );
-      }
-      fLogger->Info(MESSAGE_ORIGIN, "Add Ion:  %s  with PDG  %i ", ion->GetName(), TDatabasePDG::Instance()->GetParticle(ion->GetName())->PdgCode());
-    }
-  }
-  delete   Iter;
-
-  /** Initialize the event generator */
-  if(fEvGen) {
-    fEvGen->Init();
-  }
-}
-#endif
-
-//_____________________________________________________________________________
-void  FairMCApplication::AddParticles()
-{
-
-  FairRunSim* fRun=FairRunSim::Instance();
-  TObjArray* NewIons=fRun->GetUserDefIons();
-  TIterator* Iter=NewIons->MakeIterator();
-  Iter->Reset();
-  TObject* obj=0;
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,17,4)
-  TObjArray* NewPart=fRun->GetUserDefParticles();
-  TIterator* parIter=NewPart->MakeIterator();
-  parIter->Reset();
-  obj=0;
-  FairParticle* particle=0;
-  while((obj=parIter->Next())) {
-    particle=dynamic_cast <FairParticle*> (obj);
-    if(particle) {                // (Int_t pdg, const char* name, TMCParticleType type,
-      //Double_t mass, Double_t charge, Double_t lifetime);
-      cout << "Add Particle: " << particle->GetName()  << " with PDG " <<   particle->GetPDG() << "\n"<<
-           particle->GetName() << "            // const TString& name \n" <<
-           particle->GetMCType()<<"             // TMCParticleType mcType \n" <<
-           particle->GetMass()<<"             // Double_t mass   \n" <<
-           particle->GetCharge()<<"           // Double_t charge \n" <<
-           particle->GetDecayTime()<<"        // Double_t lifetime  \n" <<
-           particle->GetPType()<<  "           // const TString& pType, \n" <<
-           particle->GetWidth()<<   "         // Double_t width   \n" <<
-           particle->GetSpin()<<    "         // Int_t iSpin  \n" <<
-           particle->GetiParity()<< "         // Int_t iParity \n" <<
-           particle->GetConjugation()<<"       // Int_t iConjugation  \n" <<
-           particle->GetIsospin()<<   "       // Int_t iIsospin   \n" <<
-           particle->GetIsospinZ()<<  "       // Int_t iIsospinZ    \n" <<
-           particle->GetgParity()<<   "       // Int_t gParity    \n" <<
-           particle->GetLepton()<<  "         // Int_t lepton  \n" <<
-           particle->GetBaryon()<<  "         // Int_t baryon   \n" <<
-           particle->IsStable() <<  "         // Bool_t stable   \n" << endl;
-      gMC->DefineParticle(particle->GetPDG(),              // Int_t pdg
-                          particle->GetName(),             // const TString& name
-                          particle->GetMCType(),             // TMCParticleType mcType
-                          particle->GetMass(),             // Double_t mass
-                          particle->GetCharge(),           // Double_t charge
-                          particle->GetDecayTime(),        // Double_t lifetime
-                          particle->GetPType(),             // const TString& pType,
-                          particle->GetWidth(),            // Double_t width
-                          particle->GetSpin(),             // Int_t iSpin
-                          particle->GetiParity(),          // Int_t iParity
-                          particle->GetConjugation(),       // Int_t iConjugation
-                          particle->GetIsospin(),          // Int_t iIsospin
-                          particle->GetIsospinZ(),         // Int_t iIsospinZ
-                          particle->GetgParity(),          // Int_t gParity
-                          particle->GetLepton(),           // Int_t lepton
-                          particle->GetBaryon(),           // Int_t baryon
-                          particle->IsStable()             // Bool_t stable
-                         );
-      //Add Ion to gGeoManager visualization
-      if(gGeoManager) {
-        gGeoManager->SetPdgName(particle->GetPDG(),particle->GetName() );
-      }
-    }
-  }
-  delete   parIter;
-  AddDecayModes();
-#else
-  AddIons();
-#endif
-  delete Iter;
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::AddDecayModes()
-{
-  TString work = getenv("VMCWORKDIR");
-  TString work_config=work+"/gconfig/";
-  TString config_dir= getenv("CONFIG_DIR");
-  Bool_t AbsPath=kFALSE;
-
-  if (!config_dir.EndsWith("/")) {
-    config_dir+="/";
-  }
-  // set Pythia as external decayer
-
-  if(fPythiaDecayer) {
-    TString decayConfig;
-    if(fPythiaDecayerConfig.IsNull()) {
-      decayConfig="DecayConfig.C";
-      fPythiaDecayerConfig= decayConfig;
-    } else {
-      if (fPythiaDecayerConfig.Contains("/")) {
-        AbsPath=kTRUE;
-      }
-      decayConfig=fPythiaDecayerConfig;
-    }
-
-    if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), decayConfig)) != TString("")) {
-      cout << "---User path for Configuration (DecayConfig.C) is used : " <<  config_dir.Data() << endl;
-    } else {
-      if(AbsPath) {
-        decayConfig=   fPythiaDecayerConfig;
-      } else {
-        decayConfig=work_config+ fPythiaDecayerConfig ;
-      }
-    }
-    // Add decay modes using an external configuration script
-    cout << "External Decay Modes with script \n "<<  decayConfig.Data() << endl;
-    // Load configuration script and execute it
-    Int_t pyt= gROOT->LoadMacro(decayConfig.Data());
-    if(pyt==0) {
-      gInterpreter->ProcessLine("DecayConfig()");
-    }
-  }
-  // set user defined phase space decay for particles (ions)
-  AbsPath=kFALSE;
-  if(fUserDecay) {
-    TString Userdecay;
-    if(fUserDecayConfig.IsNull()) {
-      Userdecay="UserDecay.C";
-      fUserDecayConfig =Userdecay;
-    } else {
-      if(fUserDecayConfig.Contains("/")) {
-        AbsPath=kTRUE;
-      }
-      Userdecay=  fUserDecayConfig;
-    }
-
-
-    if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), Userdecay)) != TString("")) {
-      cout << "---User path for Configuration (UserDecay.C) is used : " <<  config_dir.Data() << endl;
-    } else {
-      if(AbsPath) {
-        Userdecay=fUserDecayConfig;
-      } else {
-        Userdecay=work_config+fUserDecayConfig;
-      }
-    }
-    cout << "User Decay Modes with script \n "<<  Userdecay.Data() << endl;
-    Int_t dec= gROOT->LoadMacro(Userdecay.Data());
-    if(dec==0) {
-      gInterpreter->ProcessLine("UserDecayConfig()");
-    }
-  }
-}
-//_____________________________________________________________________________
-FairPrimaryGenerator* FairMCApplication::GetGenerator()
-{
-  return fEvGen;
-}
-//_____________________________________________________________________________
-void FairMCApplication::SetGenerator(FairPrimaryGenerator* pGen)
-{
-  fEvGen=pGen;
-}
-//_____________________________________________________________________________
-void FairMCApplication::AddTask(TTask* fTask)
-{
-  if (! fFairTaskList ) {
-    fFairTaskList= new FairTask("Task List", 1);
-    gROOT->GetListOfBrowsables()->Add(fFairTaskList);
-  }
-  fFairTaskList->Add(fTask);
-  SetParTask();
-}
-//_____________________________________________________________________________
-FairGenericStack* FairMCApplication::GetStack()
-{
-  return fStack;
-}
-//_____________________________________________________________________________
-TTask* FairMCApplication::GetListOfTasks()
-{
-  return fFairTaskList;
-}
-
-//_____________________________________________________________________________
-void FairMCApplication::SetParTask()
-{
-  // Only RTDB init when more than Main Task list
-  if(FairRun::Instance()->GetNTasks() >= 1 ) {
-    fFairTaskList->SetParTask();
-    FairRuntimeDb* fRTdb=  FairRun::Instance()->GetRuntimeDb();
-    fRTdb->initContainers(FairRunSim::Instance()->GetRunId());
-
-  }
-}
-//_____________________________________________________________________________
-void FairMCApplication::InitTasks()
-{
-
-  // Only RTDB init when more than Main Task list
-  if(FairRun::Instance()->GetNTasks() >= 1 ) {
-    fLogger->Info(MESSAGE_ORIGIN, "Initialize Tasks--------------------------");
-    fFairTaskList->InitTask();
-
-  }
-
-
-}
-//_____________________________________________________________________________
-TChain* FairMCApplication::GetChain()
-{
-  return fRootManager->GetInChain();
-}
-//_____________________________________________________________________________
-
-void  FairMCApplication::SetRadiationLengthReg(Bool_t RadLen)
-{
-  fRadLength=RadLen;
-  if(fRadLength) {
-    fRadLenMan= new FairRadLenManager();
-  }
-}
-//_____________________________________________________________________________
-
-
-void  FairMCApplication::SetRadiationMapReg(Bool_t RadMap)
-{
-  fRadMap=RadMap;
-  if(fRadMap) {
-    fRadMapMan= new FairRadMapManager();
-  }
-}
-//_____________________________________________________________________________
-
-
-void  FairMCApplication::AddMeshList(TObjArray* meshList)
-{
-  if (!fRadGridMan) {
-    fRadGridMan = new FairRadGridManager();
-  }
-  fRadGridMan->AddMeshList (meshList);
-}
-//_____________________________________________________________________________
-
-ClassImp(FairMCApplication)
-
-
diff --git a/base/FairMCEventHeader.h b/base/FairMCEventHeader.h
deleted file mode 100644
index f8de21c..0000000
--- a/base/FairMCEventHeader.h
+++ /dev/null
@@ -1,105 +0,0 @@
- /********************************************************************************
- *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
- *                                                                              *
- *              This software is distributed under the terms of the             * 
- *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
- *                  copied verbatim in the file "LICENSE"                       *
- ********************************************************************************/
-#ifndef FAIRMCEVENTHEADER_H
-#define FAIRMCEVENTHEADER_H 1
-
-#include "TNamed.h"                     // for TNamed
-
-#include "Rtypes.h"                     // for Double_t, UInt_t, etc
-#include "TVector3.h"                   // for TVector3
-
-class FairMCEventHeader : public TNamed
-{
-
-  public:
-
-    FairMCEventHeader();
-
-
-    FairMCEventHeader(Int_t iEvent, Double_t x, Double_t y, Double_t z,
-                      Double_t t, Double_t b, Int_t nPrim);
-
-
-    FairMCEventHeader(UInt_t runId);
-
-
-    virtual ~FairMCEventHeader();
-
-
-    UInt_t GetRunID()   const { return fRunId; }     
-    UInt_t GetEventID() const { return fEventId; }   
-    Double_t GetX()     const { return fX; }         
-    Double_t GetY()     const { return fY; }         
-    Double_t GetZ()     const { return fZ; }         
-    Double_t GetT()     const { return fT; }         
-    Double_t GetB()     const { return fB; }         
-    Int_t GetNPrim()    const { return fNPrim; }     
-    Bool_t IsSet()      const { return fIsSet; }     
-    Double_t GetRotX()     const { return fRotX; } 
-    Double_t GetRotY()     const { return fRotY; } 
-    Double_t GetRotZ()     const { return fRotZ; } 
-
-    void GetVertex(TVector3& vertex) { vertex.SetXYZ(fX, fY, fZ); }
-
-
-    void SetEventID(UInt_t eventId) { fEventId = eventId; }
-    void SetRunID(UInt_t runId) { fRunId = runId; }
-    void SetTime(Double_t t)       { fT = t; }
-    void SetB(Double_t b)          { fB = b; }
-    void SetNPrim(Int_t nPrim)     { fNPrim = nPrim; }
-    void MarkSet(Bool_t isSet)     { fIsSet = isSet; }
-    void SetVertex(Double_t x, Double_t y, Double_t z);
-    void SetVertex(const TVector3& vertex);
-    void SetRotX(Double_t rotx) { fRotX = rotx; }
-    void SetRotY(Double_t roty) { fRotY = roty; }
-    void SetRotZ(Double_t rotz) { fRotZ = rotz; }
-
-    void Reset();
-
-    virtual void Register();
-
-  protected:
-
-
-    UInt_t     fRunId;       
-    UInt_t     fEventId;     
-    Double32_t fX;           
-    Double32_t fY;           
-    Double32_t fZ;           
-    Double32_t fT;           
-    Double32_t fB;           
-    Int_t      fNPrim;       
-    Bool_t     fIsSet;       
-    Double32_t fRotX;        
-    Double32_t fRotY;        
-    Double32_t fRotZ;        
-
-
-    ClassDef(FairMCEventHeader,2);
-
-};
-
-
-inline void FairMCEventHeader::SetVertex(Double_t x, Double_t y,
-    Double_t z)
-{
-  fX = x;
-  fY = y;
-  fZ = z;
-}
-
-
-inline void FairMCEventHeader::SetVertex(const TVector3& vertex)
-{
-  fX = vertex.X();
-  fY = vertex.Y();
-  fZ = vertex.Z();
-}
-
-
-#endif
diff --git a/base/FairModule.cxx b/base/FairModule.cxx
deleted file mode 100644
index f410325..0000000
--- a/base/FairModule.cxx
+++ /dev/null
@@ -1,429 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                     FairModule source file                    -----
-// -----            Created 06/01/04  by M. Al-Turany                  -----
-// -------------------------------------------------------------------------
-/* Generated by Together */
-
-#include "FairModule.h"
-
-
-#include "FairVolume.h"
-#include "FairVolumeList.h"
-#include "FairBaseParSet.h"
-#include "FairRun.h"
-
-#include "FairGeoNode.h"
-#include "FairRuntimeDb.h"
-
-#include "FairGeoInterface.h"
-#include "FairGeoLoader.h"
-#include "FairGeoNode.h"
-#include "FairGeoRootBuilder.h"
-#include "FairGeoMedia.h"
-
-
-#include "TString.h"
-#include "TObjArray.h"
-#include "TGeoVolume.h"
-#include "TFile.h"
-#include "TList.h"
-#include "TKey.h"
-#include "TGeoManager.h"
-#include "TGeoVoxelFinder.h"
-#include "TGeoMatrix.h"
-
-
-#include "TSystem.h"
-#include <fstream>
-#include <iostream>
-
-
-TArrayI* FairModule::volNumber=0;
-Int_t FairModule::fNbOfVolumes=0;
-FairVolumeList*  FairModule::vList=0;
-TRefArray*    FairModule::svList=0;
-
-
-
-//__________________________________________________________________________
-void FairModule::ConstructGeometry()
-{
-  fLogger->Warning(MESSAGE_ORIGIN,"FairModule::ConstructGeometry() : this method has to be implimented in detector class");
-
-}
-//__________________________________________________________________________
-void FairModule::ConstructOpGeometry()
-{
-  fLogger->Debug2(MESSAGE_ORIGIN,"FairModule::ConstructOpGeometry : this method has to be implimented in detector class");
-
-}
-//__________________________________________________________________________
-FairModule::~FairModule()
-{
-
-}
-//__________________________________________________________________________
-FairModule::FairModule(const char* Name, const char* title ,Bool_t Active)
-  :TNamed(Name, title),
-   fMotherVolumeName(""),
-   fgeoVer("Not defined"),
-   fgeoName("Not defined"),
-   fModId(-1),
-   fActive(Active),
-   fNbOfSensitiveVol(0),
-   fVerboseLevel(0),
-   flGeoPar(0),
-   kGeoSaved(kFALSE),
-   fLogger(FairLogger::GetLogger())
-{
-  if(!svList) { svList=new TRefArray(); }
-  if(!vList) { vList=new FairVolumeList(); }
-
-}
-
-//__________________________________________________________________________
-
-FairModule::FairModule()
-  : TNamed(),
-    fMotherVolumeName(""),
-    fgeoVer("Not defined"),
-    fgeoName("Not defined"),
-    fModId(-1),
-    fActive(kFALSE),
-    fNbOfSensitiveVol(0),
-    fVerboseLevel(0),
-    flGeoPar(0),
-    kGeoSaved(kFALSE),
-    fLogger(FairLogger::GetLogger())
-{
-
-}
-
-//__________________________________________________________________________
-void FairModule::Streamer(TBuffer& b)
-{
-  TNamed::Streamer(b);
-
-
-  if (b.IsReading()) {
-    fgeoVer.Streamer(b);
-    fgeoName.Streamer(b);
-    b >> fActive;
-    b >> fModId;
-  } else {
-    fgeoVer.Streamer(b);
-    fgeoName.Streamer(b);
-    b << fActive;
-    b << fModId;
-  }
-
-}
-//__________________________________________________________________________
-void FairModule::SetGeometryFileName(TString fname, TString geoVer)
-{
-  fgeoVer=geoVer;
-  TString FileName = fname;
-  TString work = getenv("VMCWORKDIR");
-  TString userwork = getenv("GEOMPATH");
-  if(userwork != "") {
-    fgeoName=userwork;
-    if (!fgeoName.EndsWith("/")) { fgeoName+="/"; }
-    //fgeoName+=fname;
-    if (TString(gSystem->FindFile(fgeoName.Data(),fname)) != TString("")) {
-      fgeoName=fname;
-      fLogger->Info(MESSAGE_ORIGIN, "User path for detector geometry : %s ", fgeoName.Data());
-    } else {
-      fLogger->Warning(MESSAGE_ORIGIN, "Detector geometry was not found in user path : %s ", FileName.Data());
-      fgeoName=work+"/geometry/";
-      fLogger->Info(MESSAGE_ORIGIN, "Try the standard path : %s ",fgeoName.Data());
-      if (TString(gSystem->FindFile(fgeoName.Data(),FileName)) != TString("")) {
-        fgeoName=FileName;
-        fLogger->Info(MESSAGE_ORIGIN, "Reading detector geometry from : %s ", FileName.Data());
-      } else {
-        fLogger->Fatal(MESSAGE_ORIGIN,"Detector geometry not found.");
-      }
-    }
-  } else {
-    fgeoName=work+"/geometry/";
-    fgeoName+=fname;
-  }
-}
-//__________________________________________________________________________
-void FairModule::ProcessNodes(TList* aList)
-{
-
-  TListIter iter(aList);
-  FairGeoNode* node   = NULL;
-  FairGeoNode* MotherNode =NULL;
-  FairVolume*  volume = NULL;
-  FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
-  FairBaseParSet* par=(FairBaseParSet*)(rtdb->getContainer("FairBaseParSet"));
-  TObjArray* fNodes = par->GetGeoNodes();
-  while( (node = (FairGeoNode*)iter.Next()) ) {
-
-    node->calcLabTransform();
-    MotherNode=node->getMotherNode();
-    volume = new FairVolume( node->getTruncName(), fNbOfVolumes++);
-    volume->setRealName(node->GetName());
-    vList->addVolume(volume);
-    volume->setGeoNode(node);
-    volume->setCopyNo(  node->getCopyNo());
-
-    if(MotherNode!=0) {
-      volume->setMotherId(node->getMCid());
-      volume->setMotherCopyNo(MotherNode->getCopyNo());
-    }
-    FairGeoVolume* aVol=NULL;
-
-    if ( node->isSensitive() && fActive ) {
-      volume->setModId(fModId);
-      volume->SetModule(this);
-      svList->Add(volume);
-      aVol = dynamic_cast<FairGeoVolume*> ( node );
-      fNodes->AddLast( aVol );
-      fNbOfSensitiveVol++;
-    }
-
-  }
-}
-//__________________________________________________________________________
-void  FairModule::AddSensitiveVolume(TGeoVolume* v)
-{
-
-  fLogger->Debug2(MESSAGE_ORIGIN, "FairModule::AddSensitiveVolume", v->GetName());
-  FairVolume*  volume = NULL;
-  volume = new FairVolume(v->GetName(), fNbOfVolumes++);
-  vList->addVolume(volume);
-  volume->setModId(fModId);
-  volume->SetModule(this);
-  svList->Add(volume);
-  fNbOfSensitiveVol++;
-
-}
-
-
-//__________________________________________________________________________
-FairVolume* FairModule::getFairVolume(FairGeoNode* fN)
-{
-  FairVolume* fv;
-  FairVolume*  fvol=0;
-  for(Int_t i=0; i<vList->getEntries(); i++) {
-    fv=vList->At(i);
-    if((fv->getGeoNode())==fN) {
-      fvol=fv;
-      return fvol;
-      break;
-    }
-  }
-  return fvol;
-}
-//__________________________________________________________________________
-void FairModule::ConstructRootGeometry()
-{
-  /** Construct the detector geometry from ROOT files, possible inputs are:
-   * 1. A TGeoVolume as a mother (master) volume containing the detector geometry
-   * 2. A TGeoManager with the detector geometry
-   * 3. A TGeoVolume as a mother or Master volume which is the output of the CAD2ROOT geometry, in this case
-   *    the materials are not proprely defined and had to be reset
-   *  In all cases we have to check that the material properties are the same or is the materials defined in
-   *  the current simulation session
-   */
-  TGeoManager* OldGeo=gGeoManager;
-  TGeoManager* NewGeo=0;
-  TGeoVolume* volume=0;;
-  TFile* f=new TFile(GetGeometryFileName().Data());
-  TList* l= f->GetListOfKeys();
-  TKey* key;
-  TIter next( l);
-  TGeoNode* n=0;
-  TGeoVolume* v1=0;
-  while ((key = (TKey*)next())) {
-    /**loop inside the delivered root file and try to fine a TGeoManager object
-     * the first TGeoManager found will be read
-     */
-    if (strcmp(key->GetClassName(),"TGeoManager") != 0) { continue; }
-    gGeoManager=0;
-    NewGeo = (TGeoManager*)key->ReadObj();
-    break;
-  }
-  if (NewGeo!=0) {
-    /** in case a TGeoManager was found get the top most volume and the node
-     */
-
-    NewGeo->cd();
-    volume=(TGeoVolume*)NewGeo->GetNode(0)->GetDaughter(0)->GetVolume();
-    v1=volume->MakeCopyVolume(volume->GetShape());
-    // n=NewGeo->GetTopNode();
-    n=v1->GetNode(0);
-    //  NewGeo=0;
-    // delete NewGeo; //move it to the end of the method
-
-  } else {
-    /** The file does not contain any TGeoManager, so we assume to have a file with a TGeoVolume
-     * try to look for a TGeoVolume inside the file
-     */
-
-    key=(TKey*) l->At(0);  //Get the first key in the list
-    volume=dynamic_cast<TGeoVolume*> (key->ReadObj());
-    if(volume!=0) { n=volume->GetNode(0); }
-    if(n!=0) { v1=n->GetVolume(); }
-  }
-
-  if(v1==0) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "\033[5m\033[31mFairModule::ConstructRootGeometry(): could not find any geometry in File!!  \033[0m", GetGeometryFileName().Data());
-  }
-  gGeoManager=OldGeo;
-  gGeoManager->cd();
-  // If AddToVolume is empty add the volume to the top volume Cave
-  // If it is defined check i´f the volume exists and if it exists add the volume from the root file
-  // to the already existing volume
-  TGeoVolume* Cave=NULL;
-  if ( 0 == fMotherVolumeName.Length() ) {
-    Cave= gGeoManager->GetTopVolume();
-  } else {
-    Cave = gGeoManager->GetVolume(fMotherVolumeName);
-    if ( NULL == Cave ) {
-      fLogger->Fatal(MESSAGE_ORIGIN,"\033[5m\033[31mFairModule::ConstructRootGeometry(): could not find the given mother volume \033[0m   %s \033[5m\033[31m where the geomanger should be added. \033[0m", fMotherVolumeName.Data());
-    }
-  }
-  /**Every thing is OK, we have a TGeoVolume and now we add it to the simulation TGeoManager  */
-  gGeoManager->AddVolume(v1);
-  /** force rebuilding of voxels */
-  TGeoVoxelFinder* voxels = v1->GetVoxels();
-  if (voxels) { voxels->SetNeedRebuild(); }
-  /**To avoid having different names of the default matrices because we could have get the volume from another
-   * TGeoManager, we reset the default matrix name
-   */
-  TGeoMatrix* M = n->GetMatrix();
-  SetDefaultMatrixName(M);
-
-  /** NOw we can remove the matrix so that the new geomanager will rebuild it properly*/
-  gGeoManager->GetListOfMatrices()->Remove(M);
-  TGeoHMatrix* global = gGeoManager->GetHMatrix();
-  gGeoManager->GetListOfMatrices()->Remove(global); //Remove the Identity matrix
-  /**Now we can add the node to the existing cave */
-  Cave->AddNode(v1,0, M);
-  /** correction from O. Merle: in case of a TGeoVolume (v1) set the material properly */
-  AssignMediumAtImport(v1);
-  /** now go through the herachy and set the materials properly, this is important becase the CAD converter
-   *  produce TGeoVolumes with materials that have only names and no properties
-   */
-  ExpandNode(n);
-  if(NewGeo!=0) { delete NewGeo; }
-  delete f;
-}
-//__________________________________________________________________________
-void FairModule::ConstructASCIIGeometry()
-{
-  fLogger->Warning(MESSAGE_ORIGIN,"FairModule::ConstructASCIIGeometry() : this method has to be implimented in detector class");
-
-}
-//__________________________________________________________________________
-Bool_t FairModule::CheckIfSensitive(std::string name)
-{
-  fLogger->Warning(MESSAGE_ORIGIN,"FairModule::CheckIfSensitive(std::string name): this method has to be implimented in detector class");
-  return kFALSE;
-}
-//__________________________________________________________________________
-void FairModule::ExpandNode(TGeoNode* fN)
-{
-  //FairGeoLoader* geoLoad = FairGeoLoader::Instance();
-  //FairGeoInterface* geoFace = geoLoad->getGeoInterface();
-  //FairGeoMedia* Media =  geoFace->getMedia();
-  //FairGeoBuilder* geobuild=geoLoad->getGeoBuilder();
-  TGeoMatrix* Matrix =fN->GetMatrix();
-  if(gGeoManager->GetListOfMatrices()->FindObject(Matrix)) { gGeoManager->GetListOfMatrices()->Remove(Matrix); }
-  TGeoVolume* v1=fN->GetVolume();
-  TObjArray* NodeList=v1->GetNodes();
-  for (Int_t Nod=0; Nod<NodeList->GetEntriesFast(); Nod++) {
-    TGeoNode* fNode =(TGeoNode*)NodeList->At(Nod);
-    TGeoMatrix* M =fNode->GetMatrix();
-    //M->SetDefaultName();
-    SetDefaultMatrixName(M);
-    if(fNode->GetNdaughters()>0) { ExpandNode(fNode); }
-    TGeoVolume* v= fNode->GetVolume();
-    AssignMediumAtImport(v);
-    if (!gGeoManager->FindVolumeFast(v->GetName())) {
-      fLogger->Debug2(MESSAGE_ORIGIN,"Register Volume : %s ", v->GetName());
-      v->RegisterYourself();
-    }
-    if (CheckIfSensitive(v->GetName())) {
-      fLogger->Debug2(MESSAGE_ORIGIN,"Sensitive Volume : %s ", v->GetName());
-      AddSensitiveVolume(v);
-    }
-  }
-}
-//__________________________________________________________________________
-void FairModule::SetDefaultMatrixName(TGeoMatrix* matrix)
-{
-  // Copied from root TGeoMatrix::SetDefaultName() and modified (memory leak)
-  // If no name was supplied in the ctor, the type of transformation is checked.
-  // A letter will be prepended to the name :
-  //   t - translation
-  //   r - rotation
-  //   s - scale
-  //   c - combi (translation + rotation)
-  //   g - general (tr+rot+scale)
-  // The index of the transformation in gGeoManager list of transformations will
-  // be appended.
-  if (!gGeoManager) { return; }
-  if (strlen(matrix->GetName())) { return; }
-  char type = 'n';
-  if (matrix->IsTranslation()) { type = 't'; }
-  if (matrix->IsRotation()) { type = 'r'; }
-  if (matrix->IsScale()) { type = 's'; }
-  if (matrix->IsCombi()) { type = 'c'; }
-  if (matrix->IsGeneral()) { type = 'g'; }
-  TObjArray* matrices = gGeoManager->GetListOfMatrices();
-  Int_t index = 0;
-  if (matrices) { index =matrices->GetEntriesFast() - 1; }
-  matrix->SetName(Form("%c%i", type, index));
-}
-
-//__________________________________________________________________________
-
-void FairModule::AssignMediumAtImport(TGeoVolume* v)
-{
-
-  /**
-   * Assign medium to the the volume v, this has to be done in all cases:
-   * case 1: For CAD converted volumes they have no mediums (only names)
-   * case 2: TGeoVolumes, we need to be sure that the material is defined in this session
-   */
-  FairGeoMedia* Media       = FairGeoLoader::Instance()->getGeoInterface()->getMedia();
-  FairGeoBuilder* geobuild  = FairGeoLoader::Instance()->getGeoBuilder();
-
-  TGeoMedium* med1=v->GetMedium();
-  if(med1) {
-    TGeoMaterial* mat1=v->GetMaterial();
-    TGeoMaterial* newMat = gGeoManager->GetMaterial(mat1->GetName());
-    if( newMat==0) {
-      /**The Material is not defined in the TGeoManager, we try to create one if we have enough information about it*/
-      FairGeoMedium* FairMedium=Media->getMedium(mat1->GetName());
-      if (!FairMedium) {
-        fLogger->Fatal(MESSAGE_ORIGIN,"Material %s is not defined in ASCII file nor in Root file we Stop creating geometry", mat1->GetName());
-        //     FairMedium=new FairGeoMedium(mat1->GetName());
-        //      Media->addMedium(FairMedium);
-      }
-
-      Int_t nmed=geobuild->createMedium(FairMedium);
-      v->SetMedium(gGeoManager->GetMedium(nmed));
-      gGeoManager->SetAllIndex();
-    } else {
-      /**Material is already available in the TGeoManager and we can set it */
-      TGeoMedium* med2= gGeoManager->GetMedium(mat1->GetName());
-      v->SetMedium(med2);
-    }
-  } else {
-    if (strcmp(v->ClassName(),"TGeoVolumeAssembly") != 0) {
-      //[R.K.-3.3.08]  // When there is NO material defined, set it to avoid conflicts in Geant
-      fLogger->Fatal(MESSAGE_ORIGIN,"The volume  %s  Has no medium information and not an Assembly so we have to quit", v->GetName());
-    }
-  }
-}
-
-//__________________________________________________________________________
-ClassImp(FairModule)
-
-
-
diff --git a/base/FairModule.h b/base/FairModule.h
deleted file mode 100644
index 139c5fb..0000000
--- a/base/FairModule.h
+++ /dev/null
@@ -1,112 +0,0 @@
-#ifndef FAIRMODULE_H
-#define FAIRMODULE_H
-
-#include "FairLogger.h"
-
-#include "TString.h"
-#include "TNamed.h"
-#include "TRefArray.h"
-#include "TGeoMatrix.h"
-#include <map>
-
-class FairVolumeList;
-class FairVolume;
-class FairGeoNode;
-class TGeoNode;
-class TGeoMatrix;
-class TGeoVolume;
-class TList;
-class TArrayI;
-/**
- * Base class for constructing all detecors and passive volumes
- * @author M. Al-Turany, Denis Bertini
- * @version 1.0
- * @since 01.04.08 M.Al-Turany
- * Add methods to construct geometry via ROOT files
- * Add some documentation
- *
- * Changelog: 29.02.2012 [O.Merle] Fixed missing material assignment for top volume.
- *                                 ... and please - add some documentation to your code.
- */
-class FairModule:  public TNamed
-{
-  public:
-    /**default ctor*/
-    FairModule();
-    /**Standard ctor*/
-    FairModule(const char* Name, const char* title, Bool_t Active=kFALSE);
-    /**default dtor*/
-    virtual  ~FairModule();
-    /**Print method sould be implimented in detector or module*/
-    virtual void        Print(Option_t* option="") const {;}
-    /**Set the geometry file name o be used*/
-    virtual void        SetGeometryFileName(TString fname, TString geoVer="0");
-    /**Get the Geometry file name*/
-    virtual TString     GetGeometryFileName() {return  fgeoName ;}
-    /**Get the geometry file version if used*/
-    virtual TString     GetGeometryFileVer() {return   fgeoVer ;}
-    /**method called from the MC application to construct the geometry, has to be implimented by user*/
-    virtual void        ConstructGeometry();
-    /**method called from the MC application to set optical geometry properties*/
-    virtual void        ConstructOpGeometry();
-    /**construct geometry from root files (TGeo)*/
-    virtual void        ConstructRootGeometry();
-    /**construct geometry from standard ASSCII files (Hades Format)*/
-    virtual void        ConstructASCIIGeometry();
-    /**Set the sensitivity flag fro volumes, called from ConstructASCIIRootGeometry(), and has to be implimented for detectors
-     * which use ConstructASCIIRootGeometry() to build the geometry */
-    virtual Bool_t      CheckIfSensitive(std::string name);
-    /**called from ConstructRootGeometry()*/
-    virtual void        ExpandNode(TGeoNode* Node);
-    /**return the MC id of a volume named vname*/
-    virtual Int_t       getVolId( const TString& vname ) const {return 0;}
-    /**return the detector/Module id (which was set in the sim macro for the detector)*/
-    Int_t               GetModId() {return fModId;}
-    /**Set the verbose level in this detector*/
-    void                SetVerboseLevel(Int_t level) {fVerboseLevel=level;}
-    /**return the detector status */
-    Bool_t              IsActive() {return fActive;}
-    /**set the detector/module id*/
-    void                SetModId(Int_t id) {fModId=id;}
-    /** Set the name of the mother volume to which a new geometry is added.
-     ** This function is needed for geometries which are defined as ROOT geometry manager.
-     **/
-    void                SetMotherVolume(TString volName) {fMotherVolumeName=volName;}
-    /**called from ConstuctASCIIGeometry*/
-    void                ProcessNodes ( TList* aList );
-    /**return the geo parameter of this detector/module*/
-    TList* GetListOfGeoPar() { return flGeoPar;}
-    /**list of volumes in a simulation session*/
-    static              FairVolumeList*   vList; //!
-    /**total number of volumes in a simulaion session*/
-    static Int_t        fNbOfVolumes;  //!
-    /**list of all sensitive volumes in  a simulaion session*/
-    static TRefArray*   svList;   //!
-
-    static TArrayI*     volNumber; //!
-    TString             fMotherVolumeName; //!
-    FairVolume*   getFairVolume(FairGeoNode* fNode);
-    void    AddSensitiveVolume(TGeoVolume* v);
-  private:
-    FairModule(const FairModule&);
-    FairModule& operator=(const FairModule&);
-    /** Re-implimented from ROOT:  TGeoMatrix::SetDefaultName()  */
-    void SetDefaultMatrixName(TGeoMatrix* matrix);
-    void AssignMediumAtImport(TGeoVolume* v);  // O.Merle, 29.02.2012 - see impl.
-
-  protected:
-    TString             fgeoVer;
-    TString             fgeoName;
-    Int_t               fModId;
-    Bool_t              fActive;
-    Int_t               fNbOfSensitiveVol; //!
-    Int_t               fVerboseLevel;
-    TList*              flGeoPar; //!  list of Detector Geometry parameters
-    Bool_t              kGeoSaved; //! flag for initialisation
-    /** Fair Logger */
-    FairLogger*            fLogger;//!
-
-    ClassDef( FairModule,1)
-};
-
-#endif //FAIRMODULE_H
diff --git a/base/FairPrimaryGenerator.cxx b/base/FairPrimaryGenerator.cxx
deleted file mode 100644
index 709af28..0000000
--- a/base/FairPrimaryGenerator.cxx
+++ /dev/null
@@ -1,352 +0,0 @@
-#include "FairPrimaryGenerator.h"
-#include "FairGenerator.h"
-#include "FairMCEventHeader.h"
-#include "FairGenericStack.h"
-
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
-#include "TRandom.h"
-#include "TMath.h"
-#include "TF1.h"
-
-#include <iostream>
-
-Int_t FairPrimaryGenerator::fTotPrim=0;
-using std::cout;
-using std::cerr;
-using std::endl;
-
-
-// -----   Default constructor   -------------------------------------------
-FairPrimaryGenerator::FairPrimaryGenerator()
-  :TNamed(),
-   fBeamX0(0),
-   fBeamY0(0),
-   fBeamSigmaX(0),
-   fBeamSigmaY(0),
-   fTargetZ (new Double_t[1]),
-   fNrTargets(1),
-   fTargetDz(0),
-   fVertex(TVector3(0.,0.,0.)),
-   fNTracks(0),
-   fSmearVertexZ(kFALSE),
-   fSmearGausVertexZ(kFALSE),
-   fSmearVertexXY(kFALSE),
-   fStack(NULL),
-   fGenList(new TObjArray()),
-   fListIter(fGenList->MakeIterator()),
-   fEvent(NULL),
-   fdoTracking(kTRUE),
-   fEventTimeMin(0),
-   fEventTimeMax(0),
-   fEventTime(0),
-   fEventMeanTime(0),
-   fTimeProb(0),
-   fMCIndexOffset(0),
-   fLogger(FairLogger::GetLogger()),
-   fEventNr(0)
-{
-  fTargetZ[0] = 0.;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Constructor with title and name   -------------------------------
-FairPrimaryGenerator::FairPrimaryGenerator(const char* name, const char* title)
-  :TNamed(name,title),
-   fBeamX0(0),
-   fBeamY0(0),
-   fBeamSigmaX(0),
-   fBeamSigmaY(0),
-   fTargetZ (new Double_t[1]),
-   fNrTargets(1),
-   fTargetDz(0),
-   fVertex(TVector3(0.,0.,0.)),
-   fNTracks(0),
-   fSmearVertexZ(kFALSE),
-   fSmearGausVertexZ(kFALSE),
-   fSmearVertexXY(kFALSE),
-   fStack(NULL),
-   fGenList(new TObjArray()),
-   fListIter(fGenList->MakeIterator()),
-   fEvent(NULL),
-   fdoTracking(kTRUE),
-   fEventTimeMin(0),
-   fEventTimeMax(0),
-   fEventTime(0),
-   fEventMeanTime(0),
-   fTimeProb(NULL),
-   fMCIndexOffset(0),
-   fLogger(FairLogger::GetLogger()),
-   fEventNr(0)
-{
-  fTargetZ[0] = 0.;
-}
-// -------------------------------------------------------------------------
-Bool_t FairPrimaryGenerator::Init()
-{
-  /** Initialize list of generators*/
-  for(Int_t i=0; i<fGenList->GetEntries(); i++ ) {
-    FairGenerator* gen= (FairGenerator*) fGenList->At(i);
-    if(gen) { gen->Init(); }
-  }
-  return kTRUE;
-}
-
-
-// -----   Destructor   ----------------------------------------------------
-FairPrimaryGenerator::~FairPrimaryGenerator()
-{
-  //  cout<<"Enter Destructor of FairPrimaryGenerator"<<endl;
-  // the stack is deleted by FairMCApplication
-  if (1 == fNrTargets) {
-    delete fTargetZ;
-  } else {
-    delete [] fTargetZ;
-  }
-  fGenList->Delete();
-  delete fGenList;
-  delete fListIter;
-
-  delete fTimeProb;
-  //  cout<<"Leave Destructor of FairPrimaryGenerator"<<endl;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Public method GenerateEvent   -----------------------------------
-Bool_t FairPrimaryGenerator::GenerateEvent(FairGenericStack* pStack)
-{
-  // Check for MCEventHeader
-  if ( ! fEvent) {
-    fLogger->Fatal(MESSAGE_ORIGIN,"FairPrimaryGenerator::GenerateEvent: No MCEventHeader branch!");
-    Fatal("GenerateEvent", "No MCEventHeader branch");
-  }
-
-  // Initialise
-  fStack   = pStack;
-  fNTracks = 0;
-  fEvent->Reset();
-
-  // Create event vertex
-  MakeVertex();
-  fEvent->SetVertex(fVertex);
-
-  // Call the ReadEvent methods from all registered generators
-  fListIter->Reset();
-  TObject* obj = 0;
-  FairGenerator* gen = 0;
-  while( (obj = fListIter->Next()) ) {
-    gen = dynamic_cast<FairGenerator*> (obj);
-    if ( ! gen ) { return kFALSE; }
-    const char* genName = gen->GetName();
-    fMCIndexOffset = fNTracks;// number tracks before generator is called
-    Bool_t test = gen->ReadEvent(this);
-    if ( ! test ) {
-      fLogger->Error(MESSAGE_ORIGIN,"FairPrimaryGenerator: ReadEvent failed for generator ", genName );
-      return kFALSE;
-    }
-  }
-
-  if(fTimeProb!=0) {
-    fEventTime = fEventTime + fTimeProb->GetRandom();
-  } else {
-    fEventTime = fEventTime + gRandom->Uniform( fEventTimeMin,  fEventTimeMax);
-  }
-
-  fEvent->SetTime(fEventTime);
-
-  fTotPrim += fNTracks;
-  // Screen output
-
-  // Set the event number if not set already by one of the dedicated generators
-  if (-1 == fEvent->GetEventID()) {
-    fEventNr++;
-    fEvent->SetEventID(fEventNr);
-  }
-
-  fLogger->Info(MESSAGE_ORIGIN,"FairPrimaryGenerator: (Event %i) %i  primary tracks from vertex (%f, %f, %f )  Event Time = %f (ns)" ,fEvent->GetEventID(), fNTracks, fVertex.X(), fVertex.Y(), fVertex.Z(), fEventTime);
-
-  fEvent->SetNPrim(fNTracks);
-
-
-  return kTRUE;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Public method AddTrack   ----------------------------------------
-void FairPrimaryGenerator::AddTrack(Int_t pdgid, Double_t px, Double_t py,
-                                    Double_t pz, Double_t vx, Double_t vy,
-                                    Double_t vz, Int_t parent,Bool_t wanttracking,Double_t e)
-{
-
-  // ---> Add event vertex to track vertex
-  vx += fVertex.X();
-  vy += fVertex.Y();
-  vz += fVertex.Z();
-
-  // ---> Convert K0 and AntiK0 into K0s and K0L
-  if ( pdgid == 311 || pdgid == -311 ) {
-    Double_t test = gRandom->Uniform(0.,1.);
-    if (test >= 0.5) { pdgid = 310; }    // K0S
-    else { pdgid = 130; }   // K0L
-  }
-
-  // ---> Check whether particle type is in PDG Database
-  TDatabasePDG* pdgBase = TDatabasePDG::Instance();
-  if ( ! pdgBase ) Fatal("FairPrimaryGenerator",
-                           "No TDatabasePDG instantiated");
-  TParticlePDG* pdgPart = pdgBase->GetParticle(pdgid);
-  if ( ! pdgPart ) {
-    if( e<0) {
-      cerr << "\033[5m\033[31m -E FairPrimaryGenerator: PDG code " << pdgid << " not found in database.\033[0m " << endl;
-      cerr << "\033[5m\033[31m -E FairPrimaryGenerator: Discarding particle \033[0m " << endl;
-      cerr << "\033[5m\033[31m -E FairPrimaryGenerator: now MC Index is corrupted \033[0m " << endl;
-      return;
-    } else {
-      cout << "\033[5m\033[31m -W FairPrimaryGenerator: PDG code " << pdgid << " not found in database. This warning can be savely ignored.\033[0m " << endl;
-    }
-  }
-
-  // ---> Get mass and calculate energy of particle
-  if(e<0) {
-    Double_t mass = pdgBase->GetParticle(pdgid)->Mass();
-    e = TMath::Sqrt( px*px + py*py + pz*pz + mass*mass );
-  }// else, use the value of e given to the function
-
-  // ---> Set all other parameters required by PushTrack
-  Int_t    doTracking =  0;   // Go to tracking
-  if(fdoTracking && wanttracking) { doTracking = 1 ; }
-  Int_t    dummyparent     = -1;   // Primary particle (now the value is -1 by default)
-  Double_t tof        =  0.;  // Time of flight
-  Double_t polx       =  0.;  // Polarisation
-  Double_t poly       =  0.;
-  Double_t polz       =  0.;
-  Int_t    ntr        =  0;   // Track number; to be filled by the stack
-  Double_t weight     =  1.;  // Weight
-  Int_t    status     =  0;   // Generation status
-
-  if( parent!=-1) { parent+=fMCIndexOffset; }// correct for tracks which are in list before generator is called
-  // Add track to stack
-  fStack->PushTrack(doTracking, dummyparent, pdgid, px, py, pz, e, vx, vy, vz,
-                    tof, polx, poly, polz, kPPrimary, ntr, weight, status, parent);
-  fNTracks++;
-
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Public method SetBeam   -----------------------------------------
-void FairPrimaryGenerator::SetBeam(Double_t x0, Double_t y0,
-                                   Double_t sigmaX, Double_t sigmaY)
-{
-  fBeamX0     = x0;
-  fBeamY0     = y0;
-  fBeamSigmaX = sigmaX;
-  fBeamSigmaY = sigmaY;
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Public method SetTarget   ---------------------------------------
-void FairPrimaryGenerator::SetTarget(Double_t z, Double_t dz)
-{
-
-  fTargetZ[0] = z;
-  fTargetDz = dz;
-}
-// -------------------------------------------------------------------------
-
-// -----   Public method SetMultTarget   -----------------------------------
-void FairPrimaryGenerator::SetMultTarget(Int_t nroftargets, Double_t* targetpos, Double_t dz)
-{
-
-  if (1 == fNrTargets) {
-    delete fTargetZ;
-  } else {
-    delete[] fTargetZ;
-  }
-
-  fNrTargets = nroftargets;
-
-  fTargetZ = new Double_t[nroftargets];
-  for (Int_t i=0; i<nroftargets; i++) {
-    fTargetZ[i]  = targetpos[i];
-  }
-  fTargetDz = dz;
-
-}
-// -------------------------------------------------------------------------
-
-
-
-// -----   Private method MakeVertex   -------------------------------------
-void FairPrimaryGenerator::MakeVertex()
-{
-  Double_t vx = fBeamX0;
-  Double_t vy = fBeamY0;
-  Double_t vz;
-  if (1 == fNrTargets) {
-    vz = fTargetZ[0];
-  } else {
-    Int_t Target = (Int_t)gRandom->Uniform(fNrTargets);
-    vz = fTargetZ[Target];
-  }
-
-  if (fSmearVertexZ) vz = gRandom->Uniform(vz - fTargetDz/2.,
-                            vz + fTargetDz/2.);
-
-  if (fSmearGausVertexZ) { vz = gRandom->Gaus(vz, fTargetDz); }
-  if (fSmearVertexXY) {
-    if (fBeamSigmaX != 0.) { vx = gRandom->Gaus(fBeamX0, fBeamSigmaX); }
-    if (fBeamSigmaY != 0.) { vy = gRandom->Gaus(fBeamY0, fBeamSigmaY); }
-  }
-
-  fVertex = TVector3(vx,vy,vz);
-}
-// -------------------------------------------------------------------------
-
-void FairPrimaryGenerator::SetEventTimeInterval(Double_t min, Double_t max)
-{
-  fEventTimeMin=min;
-  fEventTimeMax=max;
-
-}
-// -------------------------------------------------------------------------
-
-void  FairPrimaryGenerator::SetEventMeanTime(Double_t mean)
-{
-  fEventMeanTime =mean;
-  TString form="(1/";
-  form+= mean;
-  form+=")*exp(-x/";
-  form+=mean;
-  form+=")";
-  fTimeProb= new TF1("TimeProb.", form.Data(), 0., mean*10);
-
-}
-// -------------------------------------------------------------------------
-
-
-void  FairPrimaryGenerator::SetEventTime(TF1* timeProb)
-{
-  if (timeProb!=0) {
-    fTimeProb= timeProb;
-  } else {
-    cout << " \033[5m\033[31m -E FairPrimaryGenerator: invalid time function, Event time is not SET \033[0m " << endl;
-  }
-}
-
-
-
-
-
-
-ClassImp(FairPrimaryGenerator)
-
diff --git a/base/FairPrimaryGenerator.h b/base/FairPrimaryGenerator.h
deleted file mode 100644
index 6faab0d..0000000
--- a/base/FairPrimaryGenerator.h
+++ /dev/null
@@ -1,219 +0,0 @@
-/** FairPrimaryGenerator.h
- *@author V.Friese  <v.friese@gsi.de>
- *
-The FairPrimaryGenerator is responsible for the handling of the MC input.
-Several input generators can be registered to it; these have to be
-derived from the FairGenerator class. The FairPrimaryGenerator defines
-position and (optionally) smearing of the primary vertex.
-This class should be instantised only once.
-
-Modified 05.06.07:  add a method DoTracking(Bool_t) to be able to switch on/off
-the tracking from the macro (M. Al-Turany)
-
-**/
-
-
-#ifndef FAIRPRIMARYGENERATOR_H
-#define FAIRPRIMARYGENERATOR_H
-
-#include "FairGenerator.h"
-#include "FairLogger.h"
-
-#include "TNamed.h"
-#include "TObjArray.h"
-#include "TVector3.h"
-
-#include <iostream>
-
-class TF1;
-class FairGenericStack;
-class FairMCEventHeader;
-//class FairGenerator;
-
-class FairPrimaryGenerator : public TNamed
-
-{
-
-  public:
-
-    /** Default constructor. **/
-    FairPrimaryGenerator();
-
-
-    /** Constructor with name and title **/
-    FairPrimaryGenerator(const char* name, const char* title="FAIR Generator");
-
-
-    /** Destructor. **/
-    virtual ~FairPrimaryGenerator();
-
-    /** Initialize the generater (if needed!)*/
-    virtual Bool_t Init();
-
-    /** Register a generator derived from FairGenerator.  **/
-    void AddGenerator(FairGenerator* generator) {
-      if ( ! fGenList ) {
-        std::cout << "Empty fGenList pointer ! " << std::endl;
-        return;
-      }
-      fGenList->Add(generator);
-    }
-
-
-    /** Public method GenerateEvent
-        To be called at the beginning of each event from FairMCApplication.
-        Generates an event vertex and calls the ReadEvent methods from the
-        registered generators.
-        *@param pStack The particle stack
-        *@return kTRUE if successful, kFALSE if not
-    **/
-    virtual Bool_t GenerateEvent(FairGenericStack* pStack);
-
-
-    /** Public method AddTrack
-        Adding a track to the MC stack. To be called within the ReadEvent
-        methods of the registered generators.
-        *@param pdgid Particle ID (PDG code)
-        *@param px,py,pz Momentum coordinates [GeV]
-        *@param vx,vy,vz Track origin relative to event vertex
-    **/
-    virtual void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
-                          Double_t vx, Double_t vy, Double_t vz, Int_t parent=-1,Bool_t wanttracking=true,Double_t e=-9e9);
-
-
-    /** Set beam position and widths.
-     *@param beamX0      mean x position of beam at target
-     *@param beamY0      mean y position of beam at target
-     *@param beamSigmaX  Gaussian beam width in x
-     *@param beamSigmaY  Gaussian beam width in y
-     **/
-    void SetBeam(Double_t beamX0, Double_t beamY0,
-                 Double_t beamSigmaX, Double_t beamSigmaY);
-
-
-    /** Set target position and thickness.
-     *@param targetZ   z position of target center
-     *@param targetDz  full target thickness
-     **/
-    void SetTarget(Double_t targetZ, Double_t targetDz);
-
-    /** Set target position for multiple tagets. The thickness
-     * is the same for all targets.
-     *@param nroftargets   number of targets
-     *@param *targetZ      z positions of target center
-     *@param targetDz      full target thickness
-     **/
-    void SetMultTarget(Int_t nroftargets, Double_t* targetZ, Double_t targetDz);
-
-
-    /** Enable vertex smearing in z and/or xy direction **/
-    void SmearVertexZ(Bool_t flag)  { fSmearVertexZ  = flag; };
-    void SmearGausVertexZ(Bool_t flag)  { fSmearGausVertexZ  = flag; };
-    void SmearVertexXY(Bool_t flag) { fSmearVertexXY = flag; };
-
-    TObjArray* GetListOfGenerators() { return fGenList;}
-
-
-    /** Set the pointer to the MCEvent **/
-    void SetEvent(FairMCEventHeader* event) { fEvent = event; };
-
-
-    /** Accessor to the MCEvent **/
-    FairMCEventHeader* GetEvent() { return fEvent; };
-
-    /** Swich on/off the tracking of a particle*/
-
-    void DoTracking(Bool_t doTracking= kTRUE) {fdoTracking=doTracking ;}
-
-    /** Set the min and max limit for event time in ns */
-    void SetEventTimeInterval(Double_t min, Double_t max);
-
-    /** Set the mean time for the event in ns */
-    void SetEventMeanTime(Double_t mean);
-
-    /** Set the time function for event */
-    void SetEventTime(TF1* timeProb);
-
-    Int_t GetTotPrimary() { return fTotPrim;}
-
-
-
-
-  protected:
-    /**  Nominal beam position at target in x [cm] */
-    Double_t    fBeamX0;
-    /** Nominal beam position at target in y [cm]*/
-    Double_t    fBeamY0;
-    /** Beam width (Gaussian) in x [cm]*/
-    Double_t    fBeamSigmaX;
-    /**  Beam width (Gaussian) in y [cm]*/
-    Double_t    fBeamSigmaY;
-    /**  Nominal z position of center of targets [cm]*/
-    Double_t*   fTargetZ;       //!
-    /**  Number of targets;*/
-    Int_t       fNrTargets;
-    /**  Full target thickness [cm]*/
-    Double_t    fTargetDz;
-    /** Vertex position of current event [cm]*/
-    TVector3    fVertex;
-    /** Number of primary tracks in current event*/
-    Int_t       fNTracks;
-    /**  Flag for uniform vertex smearing in z*/
-    Bool_t      fSmearVertexZ;
-    /**  Flag for gaus vertex smearing in z*/
-    Bool_t      fSmearGausVertexZ;
-    /**  Flag for vertex smearing in xy*/
-    Bool_t      fSmearVertexXY;
-    /**  Pointer to MC stack*/
-    FairGenericStack*   fStack; //!
-    /**  List of registered generators */
-    TObjArray*  fGenList;
-    /**  Iterator over generator list */
-    TIterator*  fListIter;      //!
-    /**  Pointer to MCEventHeader */
-    FairMCEventHeader* fEvent;  //!
-    /** go to tracking  */
-    Bool_t      fdoTracking;    //!
-    /** min time for one event (ns) */
-    Double_t    fEventTimeMin;  //!
-    /** max time for one Event (ns) */
-    Double_t    fEventTimeMax;  //!
-    /** Time of event since th start (ns) */
-    Double_t    fEventTime;     //!
-    /** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
-    Double_t    fEventMeanTime; //!
-    /** used to generate random numbers for event time; */
-    TF1*        fTimeProb;      //!
-    /** Number of MC tracks before a Generator is called, needed for MC index update */
-    Int_t       fMCIndexOffset; //!
-    /** Fair Logger */
-    FairLogger*            fLogger;//!
-    /** Number of all primaries of this run*/
-    static Int_t fTotPrim; //!
-    /** Event number (Set by the primary generator if not set already by one of
-        the specific generators
-     **/
-    Int_t fEventNr;
-
-    /** Private method MakeVertex. If vertex smearing in xy is switched on,
-        the event vertex is smeared Gaussianlike in x and y direction
-        according to the mean beam positions and widths set by the
-        SetBeam method. If vertex smearing in z is switched on, the z
-        coordinate of the event vertex is flatly distributed over the
-        extension of the target.
-        To be called at the beginning of the event from the
-        GenerateEvent method.
-    **/
-    void MakeVertex();
-
-  private:
-    FairPrimaryGenerator(const FairPrimaryGenerator&);
-    FairPrimaryGenerator& operator=(const  FairPrimaryGenerator&);
-
-    ClassDef(FairPrimaryGenerator,4);
-
-};
-
-#endif
-
-
diff --git a/base/FairRootManager.cxx b/base/FairRootManager.cxx
deleted file mode 100644
index 075fb38..0000000
--- a/base/FairRootManager.cxx
+++ /dev/null
@@ -1,2229 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                   FairRootManager source file                 -----
-// -----            Created 06/01/04  by M. Al-Turany/D. Bertini       -----
-// -------------------------------------------------------------------------
-
-// Class FairRootManager
-// ------------------
-// Class that takes care of Root IO.
-#include "FairRootManager.h"
-#include "FairDetector.h"
-#include "FairRunAna.h"
-#include "FairRun.h"
-#include "FairMCApplication.h"
-#include "FairGeoNode.h"
-#include "FairTSBufferFunctional.h"
-#include "FairLogger.h"
-#include "FairMCEventHeader.h"
-#include "FairEventHeader.h"
-#include "FairFileHeader.h"
-#include "FairEventHeader.h"
-#include "FairWriteoutBuffer.h"
-#include "FairLink.h"
-#include "TFriendElement.h"
-#include "TObjArray.h"
-#include "TFolder.h"
-#include "TCollection.h"
-#include "TParticle.h"
-#include "TList.h"
-#include "TGeoManager.h"
-#include "TROOT.h"
-#include "TClonesArray.h"
-#include "TList.h"
-#include "TChainElement.h"
-#include "TPRegexp.h"
-#include "TArray.h"
-#include "TF1.h"
-#include "TRandom.h"
-
-#include <iostream>
-#include <map>
-#include <list>
-#include <set>
-#include <vector>
-
-#ifdef XROOTD
- #include "TXNetFile.h"
-#endif
-
-using std::flush;
-using std::cout;
-using std::endl;
-using std::map;
-using std::list;
-using std::pair;
-using std::set;
-
-FairRootManager* FairRootManager::fgInstance = 0;
-//_____________________________________________________________________________
-FairRootManager* FairRootManager::Instance()
-{
-// Returns singleton instance.
-// ---
-  return fgInstance;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairRootManager::FairRootManager()
-  : TObject(),
-    fCbmout(NULL),
-    fCbmroot(NULL),
-    fCurrentTime(0),
-    fInFile(NULL),
-    fInChain( new TChain("cbmsim", "/cbmroot")),
-    fInTree(NULL),
-    fOutFile(NULL),
-    fOutTree(NULL),
-    fListFolder(0),
-    fObj2(new TObject*[1000]),
-    fNObj(-1),
-    fMap(),
-    fPtrTree(NULL),
-    fCurrentEntries(0),
-    fBranchSeqId(0),
-    fBranchNameList(new TList()),
-    fDataContainer(),
-    fActiveContainer(),
-    fTSBufferMap(),
-    fWriteoutBufferMap(),
-    fCompressData(kFALSE),
-    fTimeStamps(kFALSE),
-    fBranchPerMap(kFALSE),
-    fBrPerMap(),
-    fBrPerMapIter(),
-    fFriendFileList(),
-    fInputFileName(""),
-    fInputChainList(),
-    fFriendTypeList(),
-    fCheckInputBranches(),
-    fInputLevel(),
-    fRunIdInfoAll(),
-    fLogger(FairLogger::GetLogger()),
-    fMixedInput(kFALSE),
-    fActualSignalIdentifier(0),
-    fNoOfSignals(0),
-    fSignalChainList(NULL),
-    fBackgroundChain(NULL),
-    fBackgroundFile(NULL),
-    fSignalTypeList(),
-    fEventTimeMin(0.),
-    fEventTimeMax(0.),
-    fEventTime(0.),
-    fEventMeanTime(0.),
-    fTimeProb(0),
-    fMCHeader(0),
-    fEvtHeader(0),
-    fFileHeader(0),
-    fSignalBGN(),
-    fEventTimeInMCHeader(kTRUE),
-    fSBRatiobyN(kFALSE),
-    fSBRatiobyT(kFALSE),
-    fCurrentEntryNo(0),
-    fTimeforEntryNo(0),
-    fNoOfBGEntries(0),
-    fCurrentEntry(),
-    fEvtHeaderIsNew(kFALSE),
-    fFillLastData(kFALSE),
-    fEntryNr(0)
-{
-  if (fgInstance) {
-    Fatal("FairRootManager", "Singleton instance already exists.");
-    return;
-  }
-  fgInstance = this;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairRootManager::~FairRootManager()
-{
-//
-  fLogger->Debug(MESSAGE_ORIGIN,"Enter Destructor of FairRootManager");
-// if(fCbmout) delete fCbmout;
-// if(fCbmroot) delete fCbmroot;
-  if(fInFile) {
-    delete fInFile;
-  }
-  if(fInChain) {
-    delete fInChain;
-  }
-  if(fOutTree) {
-    delete fOutTree;
-  }
-  if(fOutFile) {
-    fOutFile->cd();
-    delete fOutFile;
-  }
-  //  fObj2->Delete();
-  delete fObj2;
-// if(fPtrTree)delete fPtrTree;
-  fBranchNameList->Delete();
-  delete fBranchNameList;
-  fgInstance = 0;
-  fLogger->Debug(MESSAGE_ORIGIN, "Leave Destructor of FairRootManager");
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SetSignalFile(TString name, UInt_t identifier )
-{
-  TFile* SignalInFile = new TFile(name.Data());
-  if (SignalInFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the Signal file");
-  } else {
-    /** Set a signal file of certain type (identifier) if already exist add the file to the chain*/
-    if(fSignalTypeList[identifier]==0) {
-      TChain* chain = new TChain("cbmsim", "/cbmroot");
-      fSignalTypeList[identifier]=chain;
-      fCurrentEntry[identifier]= 0;
-      fNoOfSignals++;
-      fActualSignalIdentifier= identifier;
-      chain->AddFile(name.Data());
-      fFileHeader->AddInputFile(SignalInFile, identifier, 0); //First file in the Chain
-    } else {
-      TChain* CurrentChain=fSignalTypeList[identifier];
-      CurrentChain->AddFile(name.Data());
-      TObjArray* fileElements=CurrentChain->GetListOfFiles();
-      fFileHeader->AddInputFile(SignalInFile, identifier, fileElements->GetEntries());
-    }
-    fMixedInput=kTRUE;
-
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AddSignalFile(TString name, UInt_t identifier )
-{
-  SetSignalFile(name, identifier);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TChain* FairRootManager::GetSignalChainNo(UInt_t i)
-{
-  if(i<<fNoOfSignals) {
-    return fSignalTypeList[i];
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "Error signal identifier %i does not exist ", i);
-    return 0;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SetBackgroundFile(TString name)
-{
-  if (name.IsNull() ) {
-    fLogger->Info(MESSAGE_ORIGIN, "No background file defined.");
-  }
-  fBackgroundFile =  new TFile(name);
-  if (fBackgroundFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the Background file  %s ", name.Data());
-  } else {
-    fBackgroundChain = new TChain("cbmsim", "/cbmroot");
-    fBackgroundChain->AddFile(name.Data());
-    fFileHeader->AddInputFile(fBackgroundFile,0,0 );
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AddBackgroundFile(TString name)
-{
-  if (name.IsNull() ) {
-    fLogger->Info(MESSAGE_ORIGIN, "No background file defined.");
-  }
-  TFile* BGFile =  new TFile(name);
-  if (BGFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the Background file  %s ", name.Data());
-  } else {
-    if(fBackgroundChain!=0) {
-      fBackgroundChain->AddFile(name.Data());
-      TObjArray* fileElements=fBackgroundChain->GetListOfFiles();
-      fFileHeader->AddInputFile(BGFile,0, fileElements->GetEntries());
-    } else {
-      fLogger->Fatal(MESSAGE_ORIGIN, "Use SetBackGroundFile first, then add files to background");
-    }
-
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SetInputFile(TString name)
-{
-  if(!fMixedInput) {
-    fInputFileName=name;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::OpenBackgroundChain()
-{
-  // Get the folder structure from file which describes the input tree.
-  // There are two different names possible, so check both.
-  fCbmroot= dynamic_cast <TFolder*> (fBackgroundFile->Get("cbmroot"));
-  if(!fCbmroot) {
-    fCbmroot= dynamic_cast <TFolder*> (fBackgroundFile->Get("cbmout"));
-    if(!fCbmroot) {
-      fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
-    } else {
-      fCbmroot->SetName("cbmroot");
-    }
-  }
-
-  // Get The list of branches from the input file and add it to the
-  // actual list of existing branches.
-  // Add this list of branches also to the map of input trees, which
-  // stores the information which branches belong to which input tree.
-  // There is at least one primary input tree, but there can be many
-  // additional friend trees.
-  // This information is needed to add new files to the correct friend
-  // tree. With this information it is also possible to check if the
-  // input files which are added to the input chain all have the same
-  // branch structure. Without this check it is possible to add trees
-  // with a different branch structure but the same tree name. ROOT
-  // probably only checks if the name of the tree is the same.
-
-  TList* list= dynamic_cast <TList*> (fBackgroundFile->Get("BranchList"));
-  TString chainName = "BGInChain";
-  fInputLevel.push_back(chainName);
-  fCheckInputBranches[chainName] = new std::list<TString>;
-  if(list) {
-    TObjString* Obj=0;
-    for(Int_t i =0; i< list->GetEntries(); i++) {
-      Obj=dynamic_cast <TObjString*> (list->At(i));
-      fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
-      if(fBranchNameList->FindObject(Obj->GetString().Data())==0) {
-        fBranchNameList->AddLast(Obj);
-        fBranchSeqId++;
-      }
-    }
-  }
-
-  gROOT->GetListOfBrowsables()->Add(fCbmroot);
-  fListFolder.Add( fCbmroot );
-  return kTRUE;
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::OpenSignalChain()
-{
-  std::map<UInt_t, TChain*>::const_iterator iter;
-  for(iter = fSignalTypeList.begin(); iter != fSignalTypeList.end(); iter++) {
-    TChain* currentChain=iter->second;
-    // cout << "Signal chain is : " << currentChain->GetName()<< endl;
-    //   currentChain->Dump();
-    TFile* ChainFirstFile = currentChain->GetFile();
-    //cout << "First file in signal chain is : " << ChainFirstFile << endl;
-    // Check if the branchlist is the same as for the first input file.
-    Bool_t isOk = CompareBranchList(ChainFirstFile,"BGInChain");
-    if ( !isOk ) {
-      fLogger->Fatal(MESSAGE_ORIGIN, "Branch structure of the signal chain is different than the back ground one");
-    }
-  }
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::OpenInChain()
-{
-  if(fMixedInput) {
-    return OpenBackgroundChain();
-  }
-  if ( fInputFileName.IsNull() ) {
-    fLogger->Info(MESSAGE_ORIGIN, "No input file defined.");
-    return kFALSE;
-  }
-
-  // Temporarily open the input file to extract information which
-  // is needed to bring the friend trees in the correct order
-  fInFile = new TFile(fInputFileName);
-
-#ifdef XROOTD
-  if (!fInFile->IsOpen()) fInFile = new TXNetFile(fInputFileName);
-#endif
-
-  if (fInFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the Input file");
-  }
-
-  if (!fInChain ) {
-    fInChain = new TChain("cbmsim", "/cbmroot");
-  }
-  fInChain->Add( fInFile->GetName() );
-
-
-
-  // Get the folder structure from file which describes the input tree.
-  // There are two different names possible, so check both.
-  fCbmroot= dynamic_cast <TFolder*> (fInFile->Get("cbmroot"));
-  if(!fCbmroot) {
-    fCbmroot= dynamic_cast <TFolder*> (fInFile->Get("cbmout"));
-    if(!fCbmroot) {
-      fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
-    } else {
-      fCbmroot->SetName("cbmroot");
-    }
-  }
-
-
-
-  // Get The list of branches from the input file and add it to the
-  // actual list of existing branches.
-  // Add this list of branches also to the map of input trees, which
-  // stores the information which branches belong to which input tree.
-  // There is at least one primary input tree, but there can be many
-  // additional friend trees.
-  // This information is needed to add new files to the correct friend
-  // tree. With this information it is also possible to check if the
-  // input files which are added to the input chain all have the same
-  // branch structure. Without this check it is possible to add trees
-  // with a different branch structure but the same tree name. ROOT
-  // probably only checks if the name of the tree is the same.
-  TList* list= dynamic_cast <TList*> (fInFile->Get("BranchList"));
-  TString chainName = "InputChain";
-  fInputLevel.push_back(chainName);
-  fCheckInputBranches[chainName] = new std::list<TString>;
-  if(list) {
-    TObjString* Obj=0;
-    for(Int_t i =0; i< list->GetEntries(); i++) {
-      Obj=dynamic_cast <TObjString*> (list->At(i));
-      fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
-      if(fBranchNameList->FindObject(Obj->GetString().Data())==0) {
-        fBranchNameList->AddLast(Obj);
-        fBranchSeqId++;
-      }
-    }
-  }
-
-  gROOT->GetListOfBrowsables()->Add(fCbmroot);
-  fListFolder.Add( fCbmroot );
-
-  // Store the information about the unique runids in the input file
-  // together with the filename and the number of events for each runid
-  // this information is needed later to check if inconsitencies exist
-  // between the main input chain and any of the friend chains.
-
-  //  GetRunIdInfo(fInFile->GetName(), chainName);
-
-  // Add all additional input files to the input chain and do a
-  // consitency check
-  std::list<TString>::const_iterator iter;
-  for(iter = fInputChainList.begin(); iter != fInputChainList.end(); iter++) {
-    // Store global gFile pointer for safety reasons.
-    // Set gFile to old value at the end of the routine.R
-    TFile* temp = gFile;
-
-    // Temporarily open the input file to extract information which
-    // is needed to bring the friend trees in the correct order
-    TFile* inputFile = new TFile((*iter));
-    if (inputFile->IsZombie()) {
-      fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the file %s which should be added to the input chain or as friend chain", (*iter).Data());
-    }
-
-    // Check if the branchlist is the same as for the first input file.
-    Bool_t isOk = CompareBranchList(inputFile, chainName);
-    if ( !isOk ) {
-      fLogger->Fatal(MESSAGE_ORIGIN, "Branch structure of the input file %s and the file to be added %s are different.", fInputFileName.Data(), (*iter).Data());
-    }
-
-    // Add the runid information for all files in the chain.
-    //GetRunIdInfo(inputFile->GetName(), chainName);
-    // Add the file to the input chain
-    fInChain->Add( (*iter) );
-
-    // Close the temporarly file and restore the gFile pointer.
-    inputFile->Close();
-    gFile = temp;
-
-  }
-
-//  fCurrentEntries =  (Int_t) fInChain->GetTree()->GetEntries();
-//  cout<<"Input Chain has "<<fCurrentEntries<<" entries"<<endl;
-
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::OpenInTree()
-{
-  cout << "-I- FairRootManager::OpenInTree() Opening fInTree: \"" << fInTree->GetCurrentFile()->GetName() << "\"" << endl;
-  // Temporarily open the input file to extract information which
-  // is needed to bring the friend trees in the correct order
-  fInputFileName = fInTree->GetCurrentFile()->GetName();
-  fInFile        = fInTree->GetCurrentFile();
-  if (fInFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the Input file");
-  }
-
-  // Get the folder structure from file which describes the input tree.
-  // There are two different names possible, so check both.
-  fCbmroot= dynamic_cast <TFolder*> (fInFile->Get("cbmroot"));
-  if(!fCbmroot) {
-    fCbmroot= dynamic_cast <TFolder*> (fInFile->Get("cbmout"));
-    if(!fCbmroot) {
-      fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
-    } else {
-      fCbmroot->SetName("cbmroot");
-    }
-  }
-
-  // Get The list of branches from the input file and add it to the
-  // actual list of existing branches.
-  // Add this list of branches also to the map of input trees, which
-  // stores the information which branches belong to which input tree.
-  // There is at least one primary input tree, but there can be many
-  // additional friend trees.
-  // This information is needed to add new files to the correct friend
-  // tree. With this information it is also possible to check if the
-  // input files which are added to the input chain all have the same
-  // branch structure. Without this check it is possible to add trees
-  // with a different branch structure but the same tree name. ROOT
-  // probably only checks if the name of the tree is the same.
-  TList* list= dynamic_cast <TList*> (fInFile->Get("BranchList"));
-  TString chainName = "InputChain";
-  fInputLevel.push_back(chainName);
-  fCheckInputBranches[chainName] = new std::list<TString>;
-  if(list) {
-    TObjString* Obj=0;
-    for(Int_t i =0; i< list->GetEntries(); i++) {
-      Obj=dynamic_cast <TObjString*> (list->At(i));
-      fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
-      if(fBranchNameList->FindObject(Obj->GetString().Data())==0) {
-        fBranchNameList->AddLast(Obj);
-        fBranchSeqId++;
-      }
-    }
-  }
-
-  gROOT->GetListOfBrowsables()->Add(fCbmroot);
-  fListFolder.Add( fCbmroot );
-
-  // Store the information about the unique runids in the input file
-  // together with the filename and the number of events for each runid
-  // this information is needed later to check if inconsitencies exist
-  // between the main input chain and any of the friend chains.
-
-  //  GetRunIdInfo(fInFile->GetName(), chainName);
-
-  for ( Int_t iobj = 0 ; iobj <= fNObj ; iobj++ ) {
-    if ( fObj2[iobj] ) {
-      cout << "-I- FairRootManager::OpenInTree(): Updating branch \"" << fObj2[iobj]->GetName()
-           << "\" (\"" << fObj2[iobj]->GetTitle() << "\") in the new fInTree \"" << fInTree << "\"" << endl;
-      TString tempBranchName = fObj2[iobj]->GetName();
-      fInTree->SetBranchStatus (tempBranchName.Data(),1);
-      fInTree->SetBranchAddress(tempBranchName.Data(),&fObj2[iobj]);
-    }
-  }
-
-  Int_t nofEnt =  (Int_t) fInTree->GetEntries();
-
-  cout << "-I- FairRootManager::OpenInTree() Input TREE has " << nofEnt << " entries." << endl;
-
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AddFile(TString name)
-{
-  if(!fMixedInput) {
-    fInputChainList.push_back(name);
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN, "You cannot use this method with mixed input!");
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::PrintFriendList( )
-{
-  // Print information about the input structure
-  // List files from the input chain together with all files of
-  // all friend chains
-
-  fLogger->Info(MESSAGE_ORIGIN,
-                "The input consists out of the following trees and files:");
-  fLogger->Info(MESSAGE_ORIGIN," - %s",fInChain->GetName());
-  TObjArray* fileElements=fInChain->GetListOfFiles();
-  TIter next(fileElements);
-  TChainElement* chEl=0;
-  while (( chEl=(TChainElement*)next() )) {
-    fLogger->Info(MESSAGE_ORIGIN,"    - %s",chEl->GetTitle());
-  }
-
-  map< TString, TChain* >::iterator mapIterator;
-  for (mapIterator = fFriendTypeList.begin();
-       mapIterator != fFriendTypeList.end(); mapIterator++ ) {
-    TChain* chain = (TChain*)mapIterator->second;
-    fLogger->Info(MESSAGE_ORIGIN," - %s",chain->GetName());
-    fileElements=chain->GetListOfFiles();
-    TIter next1(fileElements);
-    chEl=0;
-    while (( chEl=(TChainElement*)next1() )) {
-      fLogger->Info(MESSAGE_ORIGIN,"    - %s",chEl->GetTitle());
-    }
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::CheckFriendChains()
-{
-  std::multimap< TString, std::multimap<TString,TArrayI> >::iterator it1;
-  std::multimap<TString,TArrayI> map1;
-
-  // Get the structure from the input chain
-  it1=fRunIdInfoAll.find("InputChain");
-  map1 = it1->second;
-  std::vector<Int_t> runid;
-  std::vector<Int_t> events;
-  std::multimap<TString,TArrayI>::iterator it;
-  for ( it=map1.begin() ; it != map1.end(); it++ ) {
-    TArrayI bla = (*it).second;
-    runid.push_back(bla[0]);
-    events.push_back(bla[1]);
-  }
-
-  // Now loop over all chains except the input chain and comapare the
-  // runids and event numbers.
-  // If there is a mismatch stop the execution.
-  Int_t errorFlag = 0;
-  TString inputLevel;
-  std::list<TString>::iterator listit;
-  for ( listit=fInputLevel.begin() ; listit != fInputLevel.end(); listit++ ) {
-    inputLevel = (*listit);
-    if ( !inputLevel.Contains("InputChain") ) {
-      it1=fRunIdInfoAll.find(inputLevel);
-      map1 = it1->second;
-      if ( runid.size() != map1.size()) {
-        errorFlag = 1;
-//        goto error_label;
-        break;
-      }
-      Int_t counter = 0;
-      for ( it=map1.begin() ; it != map1.end(); it++ ) {
-        TArrayI bla = (*it).second;
-        if ( (bla[0] != runid[counter]) || (bla[1] != events[counter]) ) {
-          errorFlag = 2;
-//          goto error_label;
-          break;
-        }
-        counter++;
-      }
-      if (errorFlag>0) {
-        break;
-      }
-    }
-  }
-
-  // Use goto to leave double loop at once in case of error
-// error_label:
-  if (errorFlag>0) {
-    fLogger->Error(MESSAGE_ORIGIN,"The input chain and the friend chain %s have a different structure:", inputLevel.Data());
-    if (errorFlag == 1) {
-      fLogger->Error(MESSAGE_ORIGIN,"The input chain has the following runids and event numbers:");
-      for ( Int_t i=0; i<runid.size(); i++) {
-        fLogger->Error(MESSAGE_ORIGIN," - Runid %i with %i events", runid[i], events[i]);
-      }
-      fLogger->Error(MESSAGE_ORIGIN,"The %s chain has the following runids and event numbers:", inputLevel.Data());
-      for ( it=map1.begin() ; it != map1.end(); it++ ) {
-        TArrayI bla = (*it).second;
-        fLogger->Error(MESSAGE_ORIGIN," - Runid %i with %i events", bla[0], bla[1]);
-      }
-    }
-    if (errorFlag == 2) {
-      Int_t counter = 0;
-      for ( it=map1.begin() ; it != map1.end(); it++ ) {
-        TArrayI bla = (*it).second;
-        fLogger->Error(MESSAGE_ORIGIN,"Runid Input Chain, %s chain: %i, %i", inputLevel.Data(), bla[0], runid[counter]);
-        fLogger->Error(MESSAGE_ORIGIN,"Event number Input Chain, %s chain: %i, %i", inputLevel.Data(), bla[1], events[counter]);
-        counter++;
-      }
-    }
-    fLogger->Fatal(MESSAGE_ORIGIN,"Event structure mismatch");
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t  FairRootManager::DataContainersEmpty()
-{
-  for(std::map<TString, std::queue<TClonesArray*> >::iterator it = fDataContainer.begin(); it != fDataContainer.end(); it++) {
-    if (it->second.empty() == false) {
-      return kFALSE;
-    }
-  }
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t  FairRootManager::DataContainersFilled()
-{
-  for(std::map<TString, std::queue<TClonesArray*> >::iterator it = fDataContainer.begin(); it != fDataContainer.end(); it++) {
-    if (it->second.empty() == true) {
-      return kFALSE;
-    }
-  }
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TFile* FairRootManager::OpenOutFile(TFile* f)
-{
-
-  fLogger->Debug(MESSAGE_ORIGIN,"Check the output file");
-  fOutFile=f;
-  /**Check the output file, if anything wronge with it exit!*/
-  if (fOutFile->IsZombie()) {
-    fLogger->Fatal(MESSAGE_ORIGIN,"FairRootManager: Error opening output file ");
-    exit(-1);
-  }
-  FairRun* fRun = FairRun::Instance();
-  /**Check if a simulation run!*/
-  if(!fRun->IsAna()) {
-    fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
-    gROOT->GetListOfBrowsables()->Add(fCbmroot);
-  } else {
-    fCbmout= gROOT->GetRootFolder()->AddFolder("cbmout", "Main Output Folder");
-    gROOT->GetListOfBrowsables()->Add(fCbmout);
-  }
-  return fOutFile;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TFile* FairRootManager::OpenOutFile(const char* fname)
-{
-  fLogger->Debug(MESSAGE_ORIGIN,"Opening output file, %s", fname);
-  if(fOutFile) {
-    CloseOutFile();
-  }
-  cout << "FairRootManager::OpenOutFile(\"" << fname << "\")" << endl;
-  fOutFile = new TFile(fname, "recreate");
-
-#ifdef XROOTD
-  if (!fOutFile->IsOpen()) fOutFile = new TXNetFile(fname, "recreate");
-#endif
-
-  return OpenOutFile(fOutFile);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::Register(const char* name, const char* folderName , TNamed* obj, Bool_t toFile)
-{
-
-  // Security check. If the the name is equal the folder name there are problems with reading
-  // back the data. Instead of the object inside the folder the RootManger will return a pointer
-  // to the folder. To avoid such problems we check here if both strings are equal and stop the
-  // execution with some error message if this is the case.
-  if (strcmp (name, folderName) == 0 ) {
-    fLogger->Fatal(MESSAGE_ORIGIN,"The names for the object name %s and the folder name %s are equal. This isn't allowed. So we stop the execution at this point. Pleae change either the name or the folder name.", name, folderName);
-  }
-
-  if(toFile) { /**Write the Object to the Tree*/
-    TFolder* folder=0;
-    TFolder* f=0;
-    if(fCbmout==0) {
-      f=(TFolder*)fCbmroot->FindObjectAny(folderName);
-      if(f==0) {
-        folder= fCbmroot->AddFolder(folderName,folderName);
-      } else {
-        folder=f;
-      }
-    } else {
-      f=(TFolder*)fCbmout->FindObjectAny(folderName);
-      if(f==0) {
-        folder= fCbmout->AddFolder(folderName,folderName);
-      } else {
-        folder=f;
-      }
-    }
-    obj->SetName(name);
-    folder->Add(obj);
-  }
-  AddMemoryBranch(name, obj );
-  //cout << " FairRootManager::Register Adding branch:(Obj) " << name << " In folder : " << folderName << endl;
-  if(fBranchNameList->FindObject(name)==0) {
-    fBranchNameList->AddLast(new TObjString(name));
-    fBranchSeqId++;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::Register(const char* name,const char* Foldername ,TCollection* obj, Bool_t toFile)
-{
-  /**
-  * This method do exactly the same as the one before but for TCollection which is a TObject and not a TNamed (MT)
-  */
-  // Security check. If the the name is equal the folder name there are problems with reading
-  // back the data. Instead of the object inside the folder the RootManger will return a pointer
-  // to the folder. To avoid such problems we check here if both strings are equal and stop the
-  // execution with some error message if this is the case.
-  if (strcmp (name, Foldername) == 0 ) {
-    fLogger->Fatal(MESSAGE_ORIGIN,"The names for the object name %s and the folder name %s are equal. This isn't allowed. So we stop the execution at this point. Pleae change either the name or the folder name.", name, Foldername);
-  }
-
-  if(toFile) { /**Write the Object to the Tree*/
-    TFolder* folder=0;
-    TFolder* f=0;
-    if(fCbmout==0) {
-      f=(TFolder*)fCbmroot->FindObjectAny(Foldername);
-      if(f==0) {
-        folder= fCbmroot->AddFolder(Foldername,Foldername);
-      } else {
-        folder=f;
-      }
-    } else {
-      f=(TFolder*)fCbmout->FindObjectAny(Foldername);
-      if(f==0) {
-        folder= fCbmout->AddFolder(Foldername,Foldername);
-      } else {
-        folder=f;
-      }
-    }
-    obj->SetName(name);
-    folder->Add(obj);
-  }
-  /**Keep the Object in Memory, and do not write it to the tree*/
-  AddMemoryBranch(name, obj );
-  if(fBranchNameList->FindObject(name)==0) {
-    fBranchNameList->AddLast(new TObjString(name));
-    fBranchSeqId++;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::Register(TString branchName, TString className, TString folderName, Bool_t toFile)
-{
-
-  TClonesArray* outputArray;
-  if (fActiveContainer.find(branchName) == fActiveContainer.end()) {
-    fActiveContainer[branchName] = new TClonesArray(className);
-    if (fCompressData) {
-      std::queue<TClonesArray*> myQueue;
-      fDataContainer[branchName] = myQueue;
-      outputArray = new TClonesArray(className);
-    } else {
-      outputArray = fActiveContainer[branchName];
-    }
-    Register(branchName, folderName, outputArray, toFile);
-  }
-  return fActiveContainer[branchName];
-}
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::GetEmptyTClonesArray(TString branchName)
-{
-  if (fActiveContainer.find(branchName) != fActiveContainer.end()) {          //if a TClonesArray is registered in the active container
-    if (fActiveContainer[branchName] == 0) {                      //the address of the TClonesArray is still valid
-      std::cout << "-E- FairRootManager::GetEmptyTClonesArray: Container deleted outside FairRootManager!" << std::endl;
-    } else if (!fCompressData) {                          //if the data is not compressed the existing TClonesArray is just emptied
-      fActiveContainer[branchName]->Delete();
-    } else if (fActiveContainer[branchName]->GetEntries() > 0) {    //if the container is not empty push it into the DataContainer storage and create a new one
-      fDataContainer[branchName].push(fActiveContainer[branchName]);
-      fLogger->Info(MESSAGE_ORIGIN, "GetEmptyTClonesArray moved %s with  %i to data container ",
-                    branchName.Data(),  fActiveContainer[branchName]->GetEntries());
-      fActiveContainer[branchName] = new TClonesArray(fActiveContainer[branchName]->GetClass()->GetName());
-    } else {
-      fLogger->Info(MESSAGE_ORIGIN, "GetEmptyTClonesArray not moved %s  %s  with %i to data container ",
-                    branchName.Data(),fActiveContainer[branchName]  , fActiveContainer[branchName]->GetEntries());
-    }
-    return fActiveContainer[branchName];                        // return the container
-  } else {
-    std::cout << "-E- Branch: " << branchName << " not registered!" << std::endl;  // error if the branch is not registered
-  }
-  return 0;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::GetTClonesArray(TString branchName)
-{
-  if (fActiveContainer.find(branchName) != fActiveContainer.end()) {
-    /**if a TClonesArray is registered in the active container*/
-    if (fCompressData && fActiveContainer[branchName]->GetEntries() > 0) {
-      /**if the container is not empty push it into the DataContainer storage and create a new one*/
-      fDataContainer[branchName].push(fActiveContainer[branchName]);
-      fActiveContainer[branchName] = new TClonesArray(fActiveContainer[branchName]->GetClass()->GetName());
-    }
-    return fActiveContainer[branchName]; // return the container
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN,  "Branch: %s not registered!" , branchName.Data());
-  }
-  // error if the branch is not registered
-  return 0;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::GetDataContainer(TString branchName)
-{
-  if (DataContainersFilled()) {
-    return fDataContainer[branchName].front();
-  }
-  return 0;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::ForceGetDataContainer(TString branchName)
-{
-  TClonesArray* result = 0;
-  if (fDataContainer.find(branchName)!= fDataContainer.end()) {
-    if (!fDataContainer[branchName].empty()) {
-      result = fDataContainer[branchName].front();
-      fDataContainer[branchName].pop();
-    }
-  }
-  return result;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TString FairRootManager::GetBranchName(Int_t id)
-{
-  /**Return the branch name from the id*/
-  if(id < fBranchSeqId) {
-    TObjString* ObjStr= (TObjString*) fBranchNameList->At(id);
-    return ObjStr->GetString();
-  } else {
-    TString NotFound("Branch not found");
-    return NotFound;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Int_t FairRootManager::GetBranchId(TString BrName)
-{
-  /**Return the branch id from the name*/
-  TObjString* ObjStr;
-  Int_t Id=-1;
-  for(Int_t t=0; t<fBranchNameList->GetEntries(); t++) {
-    ObjStr= (TObjString*) fBranchNameList->At(t);
-    if(BrName==ObjStr->GetString()) {
-      Id=t;
-      break;
-    }
-  }
-  return Id;
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray*    FairRootManager::GetData(TString branchName, BinaryFunctor* function, Double_t parameter)
-{
-  if (fTSBufferMap[branchName] == 0) {
-    fTSBufferMap[branchName] = new FairTSBufferFunctional(branchName, GetInTree(), function);
-  }
-  fTSBufferMap[branchName]->SetStopFunction(function);
-  return fTSBufferMap[branchName]->GetData(parameter);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TClonesArray* FairRootManager::GetData(TString branchName, BinaryFunctor* startFunction, Double_t startParameter, BinaryFunctor* stopFunction, Double_t stopParameter)
-{
-  if (fTSBufferMap[branchName] == 0) {
-    fTSBufferMap[branchName] = new FairTSBufferFunctional(branchName, GetInTree(), stopFunction, startFunction);
-  }
-  fTSBufferMap[branchName]->SetStopFunction(stopFunction);
-  fTSBufferMap[branchName]->SetStartFunction(startFunction);
-  return fTSBufferMap[branchName]->GetData(startParameter, stopParameter);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::AllDataProcessed()
-{
-  for(std::map<TString, FairTSBufferFunctional*>::iterator it = fTSBufferMap.begin(); it != fTSBufferMap.end(); it++) {
-    if (it->second->AllDataProcessed() == kFALSE && it->second->TimeOut() == kFALSE) {
-      return kFALSE;
-    }
-  }
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::Fill()
-{
-// Fills the tree.
-// ---
-  if (fCompressData) {
-    if (DataContainersFilled()) {
-      AssignTClonesArrays();
-      ForceFill();
-    }
-  } else {
-    ForceFill();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::ForceFill()
-{
-  if (fOutTree != 0) {
-    fOutTree->Fill();
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN,  " No Output Tree");
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::LastFill()
-{
-  if (fFillLastData) {
-    Fill();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager:: Write()
-{
-  /** Writes the tree in the file.*/
-  if (fCompressData) {
-    SaveAllContainers();
-  }
-  if(fOutTree!=0) {
-    /** Get the file handle to the current output file from the tree.
-      * If ROOT splits the file (due to the size of the file) the file
-      * handle fOutFile is lost and the program crash while writing the
-      * last part of the last file.
-    */
-    fOutFile = fOutTree->GetCurrentFile();
-    fOutFile->cd();
-    fOutTree->Write();
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "No Output Tree" );
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager:: WriteGeometry()
-{
-  /** Writes the geometry in the current output file.*/
-
-  if(fOutTree!=0) {
-    fOutFile = fOutTree->GetCurrentFile();
-    fOutFile->cd();
-    gGeoManager->Write();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::CreateGeometryFile(const char* geofile)
-{
-  /** Writes the geometry in a separate file.
-   *  This is only to have a file which can be read without the
-   *  framework. The geomanager used by the framework is still
-   *  stored in the parameter file or database
-  */
-  TFile* oldfile=gFile;
-  TFile* file=new TFile(geofile,"RECREATE");
-  file->cd();
-  gGeoManager->Write();
-  file->Close();
-  file->Delete();
-  gFile=oldfile;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager:: WriteFolder()
-{
-  fOutFile->cd();
-  if(fCbmroot!=0 && fInFile==0) {
-    fCbmroot->Write();
-  }
-  if(fCbmout!=0) {
-    fCbmout->Write();
-  }
-  fBranchNameList->Write("BranchList", TObject::kSingleKey);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::ReadEvent(Int_t i)
-{
-  SetEntryNr(i);
-  if ( fInTree ) {
-    cout << "FairRootManager::ReadEvent(" << i << "): FROM THE TREE " << fInTree << endl;
-    if(0==fCurrentEntryNo) {
-      Int_t totEnt = fInTree->GetEntries();
-      fLogger->Info(MESSAGE_ORIGIN,"The number of entries in the tree is %i",totEnt);
-      cout << "FairRootManager::ReadEvent(" << i << "): The tree has " << totEnt << " entries" << endl;
-
-      fEvtHeader = (FairEventHeader*) GetObject("EventHeader.");
-
-      SetEventTime();
-    }
-    fCurrentEntryNo=i;
-    fInTree->GetEntry(i);
-
-    if(fEvtHeader !=0) {
-      fEvtHeader->SetMCEntryNumber(i);
-      fEvtHeader->SetEventTime(GetEventTime());
-      fEvtHeader->SetInputFileId(0);
-    } else { fLogger->Info(MESSAGE_ORIGIN, " No event Header was found!!!"); }
-    return;
-  }
-
-  if(!fMixedInput) {
-    /**Check for fCurrentEntryNo because it always starts from Zero, i could have any value! */
-    if(0==fCurrentEntryNo) {
-      Int_t totEnt = fInChain->GetEntries();
-      fLogger->Info(MESSAGE_ORIGIN,"The number of entries in chain is %i",totEnt);
-
-      fEvtHeader = (FairEventHeader*) GetObject("EventHeader.");
-
-      SetEventTime();
-    }
-    fCurrentEntryNo=i;
-    fInChain->GetEntry(i);
-
-    if(fEvtHeader !=0) {
-      fEvtHeader->SetMCEntryNumber(i);
-      fEvtHeader->SetEventTime(GetEventTime());
-      fEvtHeader->SetInputFileId(0);
-    } else {
-      fLogger->Info(MESSAGE_ORIGIN, " No event Header was found!!!");
-    }
-
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN,"Read mixed event number  %i", i);
-    ReadMixedEvent(i);
-
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::ReadMixedEvent(Int_t i)
-{
-  /**Privat method used for event mixing*/
-
-  /**Check for fCurrentEntryNo because it always starts from Zero, i could have any value! */
-  if(0==fCurrentEntryNo) {
-    fEvtHeader = (FairEventHeader*) GetObject("EventHeader.");
-    SetEventTime();
-  }
-  Double_t SBratio=gRandom->Uniform(0,1);
-  Bool_t GetASignal=kFALSE;
-
-  if(fSBRatiobyN || fSBRatiobyT ) {
-    std::map<UInt_t, Double_t>::const_iterator iterN;
-    Double_t ratio=0;
-    if(fCurrentEntryNo==0) {
-      for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
-        ratio+=iterN->second;
-        fSignalBGN[iterN->first]=ratio;
-        fLogger->Debug(MESSAGE_ORIGIN,"--------------Set signal no. %i  weight  %f   ", iterN->first, ratio);
-      }
-    }
-    ratio=0;
-    for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
-      ratio=iterN->second;
-      fLogger->Debug(MESSAGE_ORIGIN,"---Check signal no. %i  SBratio %f  :  ratio %f ", iterN->first , SBratio, ratio);
-      if(SBratio <=ratio) {
-        TChain* chain = fSignalTypeList[iterN->first];
-        UInt_t entry = fCurrentEntry[iterN->first];
-        chain->GetEntry(entry);
-        fEvtHeader->SetMCEntryNumber(entry);
-        fEvtHeader->SetInputFileId(iterN->first);
-        fEvtHeader->SetEventTime(GetEventTime());
-        GetASignal=kTRUE;
-        fCurrentEntry[iterN->first]=entry+1;
-        fLogger->Debug(MESSAGE_ORIGIN,"---Get entry No. %i from signal chain number --- %i --- ",entry, iterN->first);
-        break;
-      }
-    }
-    if(!GetASignal) {
-      fBackgroundChain->GetEntry(i);
-      fEvtHeader->SetMCEntryNumber(i);
-      fEvtHeader->SetInputFileId(0); //Background files has always 0 as Id
-      fEvtHeader->SetEventTime(GetEventTime());
-      fLogger->Debug(MESSAGE_ORIGIN,"---Get entry from background chain  --- ");
-    }
-
-  }
-  fCurrentEntryNo=i;
-  fEvtHeader->SetEventTime(GetEventTime());
-  fLogger->Debug(MESSAGE_ORIGIN,"--Event number --- %i  with time ----%f",fCurrentEntryNo, GetEventTime());
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::ReadBKEvent(Int_t i)
-{
-  if(fMixedInput) {
-    if(0==i) {
-      Int_t totEnt = fBackgroundChain->GetEntries();
-      fLogger->Info(MESSAGE_ORIGIN,"The number of entries in background chain is %i",totEnt);
-    }
-    fBackgroundChain->GetEntry(i);
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::ReadNextEvent(Double_t dt)
-{
-  Bool_t readentry=kFALSE;
-  ///TODO
-  return readentry;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TObject* FairRootManager::GetObject(const char* BrName)
-{
-  /**Get Data object by name*/
-  TObject* Obj =NULL;
-  fLogger->Debug2(MESSAGE_ORIGIN, " Try to find if the object %s  already activated by other task or call", BrName);
-  /**Try to find the object in the folder structure, object already activated by other task or call*/
-  if(fCbmout) {
-    Obj = fCbmout->FindObjectAny(BrName);
-    if (Obj) {
-      fLogger->Debug2(MESSAGE_ORIGIN, "object %s was already activated by another task", BrName);
-    }
-  }
-
-  /**if the object does not exist then it could be a memory branch */
-  if(!Obj) {
-    fLogger->Debug2(MESSAGE_ORIGIN, " Try to find if the object %s  is a memory branch", BrName);
-    Obj=GetMemoryBranch(BrName);
-    if (Obj) {
-      fLogger->Debug2(MESSAGE_ORIGIN, "Object  %s  is a memory branch", BrName);
-    }
-  }
-  /**if the object does not exist then look in the input tree */
-  if(fCbmroot && !Obj) {
-    /** there is an input tree and the object was not in memory */
-    fLogger->Debug2(MESSAGE_ORIGIN, " Object %s  is not a memory branch and not yet activated, try the Input Tree (Chain)", BrName);
-    Obj=fCbmroot->FindObjectAny(BrName);
-    Obj=ActivateBranch(BrName);
-  }
-  if(!Obj) {
-    Obj=ActivateBranch(BrName);
-  }
-  return Obj;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TObject* FairRootManager::GetObjectFromInTree(const char* BrName)
-{
-  if ( !fInTree ) {
-    return GetObject(BrName);
-  }
-  /**Get Data object by name*/
-  TObject* Obj =NULL;
-  fLogger->Debug2(MESSAGE_ORIGIN, " Try to find if the object %s  already activated by other task or call", BrName);
-
-  /**Try to find the object in the folder structure, object already activated by other task or call*/
-  /**if the object does not exist then look in the input tree */
-  if(fCbmroot && !Obj) {
-    /** there is an input tree and the object was not in memory */
-    fLogger->Debug2(MESSAGE_ORIGIN, " Object %s  is not a memory branch and not yet activated, try the Input Tree (Chain)", BrName);
-    Obj=fCbmroot->FindObjectAny(BrName);
-    Obj=ActivateBranchInInTree(BrName);
-  }
-  if(!Obj) {
-    Obj=ActivateBranch(BrName);
-  }
-  return Obj;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-
-TObject* FairRootManager::GetLinkData(const FairLink link)
-{
-  Int_t fileId = link.GetFile();
-  Int_t entryNr = link.GetEntry();
-  Int_t type = link.GetType();
-  Int_t index = link.GetIndex();
-
-//  std::cout << "GetLinkData: " << link << std::endl;
-
-  TTree* dataTree;          //get the correct Tree
-  if (fileId < 0) {
-    dataTree = GetInTree();
-  } else if (fileId == 0) {
-    dataTree = GetBGChain();
-  } else {
-    dataTree = GetSignalChainNo(fileId);
-  }
-
-  if (dataTree == 0) {
-    dataTree = GetInTree();
-  }
-
-  if (type < 0) {
-    return 0;
-  }
-
-  TBranch* dataBranch = 0;
-
-  if (fileId < 0 && fInputBranchMap[type] != 0) {
-    dataBranch = fInputBranchMap[type];
-  } else if (fileId < 0) {
-    fInputBranchMap[type] = dataTree->GetBranch(GetBranchName(type));
-    dataBranch = fInputBranchMap[type];
-  } else {
-    dataBranch = dataTree->GetBranch(GetBranchName(type));
-  }
-
-  if (dataBranch == 0) {
-    return 0;
-  }
-
-  if (entryNr > -1) {         //get the right entry (if entryNr < 0 then the current entry is taken
-    if (entryNr < dataBranch->GetEntries()) {
-      dataBranch->GetEntry(entryNr);
-    } else {
-      return 0;
-    }
-  } else {        //the link entry nr is negative --> take the actual one
-    dataBranch->GetEntry(GetEntryNr());
-  }
-  if (index < 0) {                //if index is -1 then this is not a TClonesArray so only the Object is returned
-    return GetObject(GetBranchName(type));
-  }
-
-  TClonesArray* dataArray = (TClonesArray*)GetObject(GetBranchName(type));
-//  std::cout << "BranchName: " << GetBranchName(type) << std::endl;
-//  std::cout << "DataBranch EntryNr: " << dataBranch->GetEntryNumber() << std::endl;
-//  std::cout << "DataArray size: " << dataArray->GetEntriesFast() << std::endl;
-
-  if (index < dataArray->GetEntriesFast()) {
-    return dataArray->At(index);
-  }
-  return 0;
-}
-
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairGeoNode*  FairRootManager::GetGeoParameter(const char* detname, const char* gname)
-{
-  TFolder* detf= NULL;
-  FairGeoNode* node = NULL;
-  TList* lgeo=NULL;
-  TString lname(detname);
-  lname+="GeoPar";
-  TFolder* froot =  dynamic_cast<TFolder*> (gROOT->FindObject("cbmroot"));
-  if ( froot ) {
-    detf = dynamic_cast<TFolder*> (froot->FindObjectAny( detname ));
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "GetGeoParameter() Main Folder not found ! ");
-  }
-  if ( detf    ) {
-    lgeo = dynamic_cast<TList*> (detf->FindObjectAny( lname.Data() ));
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "GetGeoParameter() GeoPar: %s " , lname.Data() );
-  }
-  if ( lgeo    ) {
-    node = dynamic_cast<FairGeoNode*> (lgeo->FindObject(gname));
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "GetGeoParameter() GeoList not found " );
-  }
-  return node;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::TruncateBranchNames(TTree* fTree, const char* folderName)
-{
-  /** If a object is created in a folder the corresponding branch
-  * in the tree is crated with a wrong name.
-  * The name of the branch is created as follows
-  * mainFolder.subFolder.nameOfStoredObject
-  * e.g. cbmroot.Event.ExampleClass.
-  * The name which is wanted is only nameOfStoredObject
-  * e.g. ExampleClass.
-  * This is corrected in this function
-  * If the folder does not exist don't do anything
-  */
-  TFolder* cbm=(TFolder*)gROOT->FindObjectAny(folderName);
-  if(cbm) {
-    TCollection* lf=cbm->GetListOfFolders();
-    TIterator* iter= lf->MakeIterator();
-    TObjArray* Br= fTree->GetListOfBranches();
-    TIterator* BrIter= Br->MakeIterator();
-    TObject* obj;
-    TObject* BrObj;
-
-    /** correct branch names in all folders below the main output folder*/
-    while((obj=iter->Next())) {
-
-      /** Create TString with the part of the branch name which should be
-      * removed. This is mainFolderName.folderName. e.g. cbmroot.Event.
-      * This part of the branch name is obsolete, so it is removed from
-      * the branch name.
-      */
-      TString ffn=cbm->GetName();
-      ffn=ffn+".";
-      ffn=ffn+obj->GetName();
-      ffn=ffn+".";
-
-      /** Correct name of all branches and leaves which correspond to
-      * the subfolder. To do so loop over all branches and check
-      * if the branch corresponds with the folder. If it corresponds
-      * correct the branch names of all sub branches.
-      * Only correct branch names for up to now uncorrected branches.
-      */
-      BrIter->Reset();
-
-      while((BrObj=BrIter->Next())) {
-        TBranch* b=(TBranch*)BrObj;
-        TruncateBranchNames(b, ffn);
-      }
-    }
-
-    // Remove all occurence of FairMCEventHeader and FairEventHeader from
-    // all branches containing that string.
-    // This is not the correct way to do it, but up tonow we don't understand
-    // why this part comes in when storing a derrived class from
-    // FairMCEventHeader or FairEventHeader.
-
-    iter->Reset();
-    while((obj=iter->Next())) {
-
-      TString ffn=".FairMCEventHeader";
-      BrIter->Reset();
-
-      while((BrObj=BrIter->Next())) {
-        TBranch* b=(TBranch*)BrObj;
-        TruncateBranchNames(b, ffn);
-      }
-    }
-
-    iter->Reset();
-    while((obj=iter->Next())) {
-
-      TString ffn=".FairEventHeader";
-      BrIter->Reset();
-
-      while((BrObj=BrIter->Next())) {
-        TBranch* b=(TBranch*)BrObj;
-        TruncateBranchNames(b, ffn);
-      }
-    }
-
-    delete  iter;
-    delete  BrIter;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::TruncateBranchNames(TBranch* b, TString ffn)
-{
-  /** Get the branch name from the branch object, remove common
-  *  and wrong part of the name and and set branch name to
-  *  the new corrected name. This has to be done recursivly for
-  *  all subbranches/leaves
-  *  Remove wrong part of branch name
-  */
-  TObject* BrObj;
-  TString nn= b->GetName();
-  //  cout<<"nn.Data before: "<<nn.Data()<<endl;
-  nn.ReplaceAll(ffn.Data(),"");
-  //  cout<<"nn.Data after: "<<nn.Data()<<endl;
-  //  cout <<"##################"<<endl;
-  b->SetName(nn.Data());
-  TObjArray* Br= b->GetListOfBranches();
-  TIterator* BrIter= Br->MakeIterator();
-  BrIter->Reset();
-
-  while((BrObj=BrIter->Next())) {
-    TBranch* bb=(TBranch*)BrObj;
-    TruncateBranchNames(bb, ffn);
-  }
-  delete  BrIter;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Int_t FairRootManager::CheckBranch(const char* BrName)
-{
-  /**The first time this method is called the map is generated and then used*/
-  if(!fBranchPerMap) {
-    CreatePerMap();
-    return CheckBranchSt(BrName);
-  } else {
-    fBrPerMapIter=fBrPerMap.find(BrName);
-    if(fBrPerMapIter!=fBrPerMap.end()) {
-      return fBrPerMapIter->second;
-    } else {
-      return 0;
-    }
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::SetBranchNameList(TList* list)
-{
-  for(Int_t t=0; t<list->GetEntries(); t++) {
-    fBranchNameList->AddAt(list->At(t),t);
-  }
-}
-
-
-
-
-
-
-//_____________________________________________________________________________
-/** Private functions*/
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TObject* FairRootManager::ActivateBranch(const char* BrName)
-{
-  /** Set the branch address for a given branch name and return a TObject pointer,
-   the user have to cast this pointer to the right type.
-   The function has been revisited ! Now it test if in the task init() mutilple
-   calls to activate branch is done , and then just forward the pointer.
-   <DB>
-   **/
-  fNObj++;
-  fObj2[fNObj]  =  GetMemoryBranch ( BrName );
-  if ( fObj2[fNObj]   ) {
-    return  fObj2[fNObj];
-  }
-  /**try to find the object decribing the branch in the folder structure in file*/
-  fLogger->Debug2(MESSAGE_ORIGIN, " Try to find an object %s decribing the branch in the folder structure in file", BrName);
-  for(Int_t i=0; i<fListFolder.GetEntriesFast(); i++) {
-    TFolder* fold = (TFolder*) fListFolder.At(i);
-    fObj2[fNObj] = fold->FindObjectAny(BrName);
-    if (fObj2[fNObj] ) {
-      fLogger->Debug(MESSAGE_ORIGIN, "object %s decribing the branch in the folder structure was found", BrName);
-      break;
-    }
-  }
-
-  if(!fObj2[fNObj]) {
-    /** if we do not find an object corresponding to the branch in the folder structure
-    *  then we have no idea about what type of object is this and we cannot set the branch address
-    */
-    fLogger->Info(MESSAGE_ORIGIN, " Branch: %s  not found in Tree ", BrName);
-    //Fatal(" No Branch in the tree", BrName );
-    return 0;
-  } else {
-    if(fMixedInput) {
-      /** All branches has the same types in background and signal chains, thus
-       * we can set the branch address to aal of them with one TClonesarray and then we call the proper
-       * fill in the read (event) entry
-       */
-
-      fLogger->Debug2(MESSAGE_ORIGIN, "Set the Branch address for background branch %s", BrName);
-      fBackgroundChain->SetBranchStatus(BrName,1);
-      fBackgroundChain->SetBranchAddress(BrName,&fObj2[fNObj]);
-
-      std::map<UInt_t, TChain*>::const_iterator iter;
-      Int_t no=0;
-      for(iter = fSignalTypeList.begin(); iter != fSignalTypeList.end(); iter++) {
-        TChain* currentChain=iter->second;
-        fLogger->Debug2(MESSAGE_ORIGIN, "Set the Branch address for signal file number %i  and  branch %s ", no++ , BrName);
-        currentChain->SetBranchStatus(BrName,1);
-        currentChain->SetBranchAddress(BrName,&fObj2[fNObj]);
-      }
-
-
-    } else {
-
-      if ( fInTree ) {
-        fInTree->SetBranchStatus (BrName,1);
-        fInTree->SetBranchAddress(BrName,&fObj2[fNObj]);
-      } else {
-        fInChain->SetBranchStatus(BrName,1);
-        fInChain->SetBranchAddress(BrName,&fObj2[fNObj]);
-      }
-    }
-  }
-
-  AddMemoryBranch( BrName , fObj2[fNObj] );
-  return  fObj2[fNObj];
-
-}
-
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TObject* FairRootManager::ActivateBranchInInTree(const char* BrName)
-{
-  fNObj++;
-
-  for(Int_t i=0; i<fListFolder.GetEntriesFast(); i++) {
-    TFolder* fold = (TFolder*) fListFolder.At(i);
-    fObj2[fNObj] = fold->FindObjectAny(BrName);
-    if (fObj2[fNObj] ) {
-      break;
-    }
-  }
-
-  if(!fObj2[fNObj]) {
-    /** if we do not find an object corresponding to the branch in the folder structure
-    *  then we have no idea about what type of object is this and we cannot set the branch address
-    */
-    fLogger->Info(MESSAGE_ORIGIN, " Branch: %s  not found in Tree ", BrName);
-    //Fatal(" No Branch in the tree", BrName );
-    return 0;
-  } else {
-    fInTree->SetBranchStatus (BrName,1);
-    fInTree->SetBranchAddress(BrName,&fObj2[fNObj]);
-  }
-
-  AddMemoryBranch( BrName , fObj2[fNObj] );
-  return  fObj2[fNObj];
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::AddMemoryBranch( const char* fName, TObject* pObj )
-{
-  /**branch will be available ionly in Memory, will not be written to disk */
-  map < TString, TObject*>::iterator p;
-  TString BrName=fName;
-  p=fMap.find(BrName);
-  if(p!=fMap.end()) {
-  } else {
-    fMap.insert(pair<TString, TObject*> (BrName, pObj));
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AssignTClonesArrays()
-{
-  for(std::map<TString, std::queue<TClonesArray*> >::iterator it = fDataContainer.begin(); it != fDataContainer.end(); it++) {
-    AssignTClonesArray(it->first);
-  }
-}
-//_____________________________________________________________________________
-void FairRootManager::AssignTClonesArray(TString branchName)
-{
-  TClonesArray* output = (TClonesArray*)GetObject(branchName);
-  TClonesArray* input = ForceGetDataContainer(branchName);
-  output->Clear();
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)
-  if (input != 0) {
-    output->AbsorbObjects(input, 0, input->GetEntries() - 1);
-  }
-#else
-  fLogger->Info(MESSAGE_ORIGIN, "FairRootManager::AssignTClonesArray(TString branchName) ");
-  fLogger->Info(MESSAGE_ORIGIN, "Is only available in ROOT 5.27-04 ");
-#endif
-}
-//_____________________________________________________________________________
-Int_t FairRootManager::CheckBranchSt(const char* BrName)
-{
-  Int_t returnvalue=0;
-  TObject* Obj1 =NULL;
-  if (fCbmroot) {
-    Obj1 = fCbmroot->FindObjectAny(BrName);
-  }
-  if(fCbmout && !Obj1) {
-    Obj1 = fCbmout->FindObjectAny(BrName);  //Branch in output folder
-  }
-  if(!Obj1) {
-    for(Int_t i=0; i<fListFolder.GetEntriesFast(); i++) {
-//      cout << "Search in Folder: " << i << "  " <<  listFolder.At(i) << endl;
-      TFolder* fold = dynamic_cast<TFolder*> (fListFolder.At(i));
-      if(fold!=0) {
-        Obj1= fold->FindObjectAny(BrName);
-      }
-      if (Obj1) {
-        break;
-      }
-    }
-  }
-  TObject* Obj2 =NULL;
-  Obj2=GetMemoryBranch(BrName);  // Branch in Memory
-  if (Obj1!=0) {
-    returnvalue=1;
-  } else if(Obj2!=0) {
-    returnvalue=2;
-  } else {
-    returnvalue= 0;
-  }
-
-  /**  1 : Branch is Persistance
-       2 : Memory Branch
-       0 : Branch does not exist
-  */
-  return returnvalue;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::CreatePerMap()
-{
-//   cout << " FairRootManager::CreatePerMap() " << endl;
-  fBranchPerMap=kTRUE;
-  for (Int_t i=0; i<fBranchSeqId; i++) {
-    TObjString* name= (TObjString*)(fBranchNameList->At(i));
-//      cout << " FairRootManager::CreatePerMap() Obj At " << i << "  is "  << name->GetString() << endl;
-    TString BrName=name->GetString();
-    fBrPerMap.insert(pair<TString, Int_t> (BrName, CheckBranchSt(BrName.Data())));
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-TObject*  FairRootManager::GetMemoryBranch( const char* fName )
-{
-
-//return fMap[BrName];
-  TString BrName=fName;
-  map < TString, TObject*>::iterator p;
-  p=fMap.find(BrName);
-
-  if(p!=fMap.end()) {
-    return p->second;
-  } else {
-    return 0;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SaveAllContainers()
-{
-  while(!DataContainersEmpty()) {
-    AssignTClonesArrays();
-    ForceFill();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AddFriend(TString Name)
-{
-  fFriendFileList.push_back(Name);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::AddFriendsToChain()
-{
-  // Loop over all Friend files and extract the type. The type is defined by
-  // the tree which is stored in the file. If there is already a chain of with
-  // this type of tree then the file will be added to this chain.
-  // If there is no such chain it will be created.
-  //
-  // Check if the order of runids and the event numbers per runid for all
-  // friend chains is the same as the one defined by the input chain.
-  // TODO: Should the order be corrected or should the execution be stopped.
-  // The order in the input tree defined by the order in which the files have
-  // been added. A file is defined by the runid.
-
-  // In the old way it was needed sometimes to add a freind file more
-  // than once. This is not needed any longer, so we remove deuplicates
-  // from the list and display a warning.
-  std::list<TString> friendList;
-  std::list<TString>::iterator iter1;
-  for(iter1 = fFriendFileList.begin();
-      iter1 != fFriendFileList.end(); iter1++) {
-    if (find(friendList.begin(), friendList.end(), (*iter1))
-        == friendList.end()) {
-      friendList.push_back(*iter1);
-    }
-  }
-  // TODO: print a warning if it was neccessary to remove a filname from the
-  // list. This can be chacked by comparing the size of both list
-
-  TFile* temp = gFile;
-
-  Int_t friendType = 1;
-  // Loop over all files which have been added as friends
-  for(iter1 = friendList.begin();
-      iter1 != friendList.end(); iter1++) {
-    std::list<TString>::iterator iter;
-    TString inputLevel;
-    // Loop over all already defined input levels to check if this type
-    // of friend tree is already added.
-    // If this type of friend tree already exist add the file to the
-    // then already existing friend chain. If this type of friend tree
-    // does not exist already create a new friend chain and add the file.
-    Bool_t inputLevelFound = kFALSE;
-    TFile* inputFile;
-    for ( iter = fInputLevel.begin(); iter !=fInputLevel.end(); iter++ ) {
-      inputLevel = (*iter);
-
-      inputFile = new TFile((*iter1));
-      if (inputFile->IsZombie()) {
-        fLogger->Fatal(MESSAGE_ORIGIN, "Error opening the file %s which should be added to the input chain or as friend chain", (*iter).Data());
-      }
-
-      // Check if the branchlist is already stored in the map. If it is
-      // already stored add the file to the chain.
-      Bool_t isOk = CompareBranchList(inputFile, inputLevel);
-      if ( isOk ) {
-        inputLevelFound = kTRUE;
-        inputFile->Close();
-        continue;
-      }
-      inputFile->Close();
-    }
-    if (!inputLevelFound) {
-      inputLevel= Form("FriendTree_%i",friendType);
-      CreateNewFriendChain((*iter1), inputLevel);
-      friendType++;
-    }
-
-    TChain* chain = (TChain*) fFriendTypeList[inputLevel];
-    chain->AddFile((*iter1), 1234567890, "cbmsim");
-  }
-  gFile=temp;
-
-  // Check if all friend chains have the same runids and the same
-  // number of event numbers as the corresponding input chain
-// CheckFriendChains();
-
-  // Add all the friend chains which have been created to the
-  // main input chain.
-  map< TString, TChain* >::iterator mapIterator;
-  for (mapIterator = fFriendTypeList.begin();
-       mapIterator != fFriendTypeList.end(); mapIterator++ ) {
-
-    TChain* chain = (TChain*)mapIterator->second;
-    fInChain->AddFriend(chain);
-  }
-
-  // Print some output about the input structure
-  PrintFriendList();
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::CreateNewFriendChain(TString inputFile, TString inputLevel)
-{
-
-  TFile* temp = gFile;
-  TFile* f = new TFile(inputFile);
-
-  TFolder* added=NULL;
-  TString folderName = "/cbmout";
-  TString folderName1 = "cbmout";
-  added = dynamic_cast <TFolder*> (f->Get("cbmout"));
-  if(added==0) {
-    folderName = "/cbmroot";
-    folderName1 = "cbmroot";
-    added = dynamic_cast <TFolder*> (f->Get("cbmroot"));
-  }
-  folderName1=folderName1+"_"+inputLevel;
-  added->SetName(folderName1);
-  fListFolder.Add( added );
-
-  /**Get The list of branches from the friend file and add it to the actual list*/
-  TList* list= dynamic_cast <TList*> (f->Get("BranchList"));
-  TString chainName = inputLevel;
-  fInputLevel.push_back(chainName);
-  fCheckInputBranches[chainName] = new std::list<TString>;
-  if(list) {
-    TObjString* Obj=0;
-    for(Int_t i =0; i< list->GetEntries(); i++) {
-      Obj=dynamic_cast <TObjString*> (list->At(i));
-      fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
-      if(fBranchNameList->FindObject(Obj->GetString().Data())==0) {
-        fBranchNameList->AddLast(Obj);
-        fBranchSeqId++;
-      }
-    }
-  }
-
-  TChain* chain = new TChain(inputLevel,folderName);
-  fFriendTypeList[inputLevel]=chain;
-
-  f->Close();
-  gFile = temp;
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Bool_t FairRootManager::CompareBranchList(TFile* fileHandle, TString inputLevel)
-{
-  // fill a set with the original branch structure
-  // This allows to use functions find and erase
-  std::set<TString> branches;
-  list<TString>::const_iterator iter;
-  for(iter = fCheckInputBranches[inputLevel]->begin();
-      iter != fCheckInputBranches[inputLevel]->end(); iter++) {
-    branches.insert(*iter);
-  }
-
-  // To do so we have to loop over the branches in the file and to compare
-  // the branches in the file with the information stored in
-  // fCheckInputBranches["InputChain"]. If both lists are equal everything
-  // is okay
-
-  // Get The list of branches from the input file one by one and compare
-  // it to the reference list of branches which is defined for this tree.
-  // If a branch with the same name is found, this branch is removed from
-  // the list. If in the end no branch is left in the list everything is
-  // fine.
-  set<TString>::iterator iter1;
-  TList* list= dynamic_cast <TList*> (fileHandle->Get("BranchList"));
-  if(list) {
-    TObjString* Obj=0;
-    for(Int_t i =0; i< list->GetEntries(); i++) {
-      Obj=dynamic_cast <TObjString*> (list->At(i));
-      iter1=branches.find(Obj->GetString().Data());
-      if (iter1 != branches.end() ) {
-        branches.erase (iter1);
-      } else {
-        // Not found is an error because branch structure is
-        // different. It is impossible to add to tree with a
-        // different branch structure
-        return kFALSE;
-      }
-    }
-  }
-  // If the size of branches is !=0 after removing all branches also in the
-  // reference list, this is also a sign that both branch list are not the
-  // same
-  if (branches.size() != 0 ) {
-    return kFALSE;
-  }
-
-  return kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-//void FairRootManager::GetRunIdInfo(TFile* fileHandle, TString inputLevel)
-void FairRootManager::GetRunIdInfo(TString fileName, TString inputLevel)
-{
-  TFile* temp=gFile;
-  TFile* fileHandle = new TFile(fileName);
-
-#ifdef XROOTD
-  if (!fileHandle->IsOpen()) fileHandle = new TXNetFile(fileName);
-#endif
-
-  TTree* testTree = dynamic_cast<TTree*>(fileHandle->Get("cbmsim"));
-  TFolder* folder = dynamic_cast<TFolder*>(fileHandle->Get("cbmroot"));
-  if (!folder) {
-    folder = dynamic_cast<TFolder*>(fileHandle->Get("cbmout"));
-  }
-
-  // Get the information about runid and start and stop event number
-  // If there is a branch with this information use this information
-  // directly. If not loop over all events and read the MCEventHeader
-  // information to extract all different runids and start/stop event
-  // numbers.
-
-  FairEventHeader* header =
-    (FairEventHeader*)folder->FindObjectAny("EventHeader.");
-  // With the follwing two lines the MCEventHeader is not filled
-  // correctely. The runid is correct but the event numbers are
-  // zero all the time. This must be a bug.
-  // TODO: Create example and submit a bug report to the ROOT team
-  //   testTree->SetBranchStatus("*",0); //disable all branches
-  //   testTree->SetBranchStatus("MCEventHeader.",1);
-  testTree->SetBranchAddress("EventHeader.", &header);
-
-  Int_t entries =  (Int_t) testTree->GetEntriesFast();
-
-
-  TArrayI runidInfo(2);
-
-  testTree->GetEntry(0);
-
-  Int_t runid;
-  Int_t counter = 1;
-  runid = header->GetRunId();
-  runidInfo.AddAt(runid,0);
-
-  std::map<TString, std::multimap<TString,TArrayI> >::iterator it;
-
-  std::multimap<TString, TArrayI>  myRunIdInfo;
-  it=fRunIdInfoAll.find(inputLevel);
-  if ( it != fRunIdInfoAll.end()) {
-    myRunIdInfo=it->second;
-  }
-
-  for (Int_t i=1; i<entries ; i++) {
-    testTree->GetEntry(i);
-    runid = header->GetRunId();
-    if ( runid != runidInfo[0] ) {
-      runidInfo.AddAt(counter,1);
-      // Fill info to structure
-      myRunIdInfo.insert(pair<TString,TArrayI>(fileName,runidInfo));
-      runidInfo.Reset();
-      runid = header->GetRunId();
-      runidInfo.AddAt(runid,0);
-      counter = 0;
-    }
-    counter++;
-  }
-
-  runidInfo.AddAt(counter,1);
-  myRunIdInfo.insert(pair<TString,TArrayI>(fileName,runidInfo));
-  fRunIdInfoAll.erase(inputLevel);
-  fRunIdInfoAll.insert(pair<TString, std::multimap<TString,TArrayI> >
-                       (inputLevel, myRunIdInfo));
-
-  fileHandle->Close();
-  gFile=temp;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Double_t FairRootManager::GetEventTime()
-{
-  fLogger->Debug(MESSAGE_ORIGIN,"-- Get Event Time --");
-  if(!fEvtHeaderIsNew && fEvtHeader!=0) {
-    Double_t EvtTime=fEvtHeader->GetEventTime();
-    if( !(EvtTime<0)) {
-      return   EvtTime;
-    }
-  }
-
-  if (fEventTimeInMCHeader && !fMCHeader) {
-    fLogger->Debug(MESSAGE_ORIGIN," No MCEventHeader, time is set to 0");
-    return 0;
-  } else if(fEventTimeInMCHeader && fMCHeader) {
-    fEventTime=fMCHeader->GetT();
-    fLogger->Debug(MESSAGE_ORIGIN," Get event time from MCEventHeader : %f ns", fEventTime);
-    return fEventTime;
-  } else {
-
-    if(fTimeforEntryNo!=fCurrentEntryNo) {
-      SetEventTime();
-    }
-    fLogger->Debug(MESSAGE_ORIGIN," Calculate event time from user input : %f ns", fEventTime);
-    return fEventTime;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::WriteFileHeader(FairFileHeader* f)
-{
-  fOutFile->cd();
-  f->SetName(fOutFile->GetName());
-  f->Write("FileHeader", TObject::kSingleKey);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SetEventTimeInterval(Double_t min, Double_t max)
-{
-  fEventTimeMin=min;
-  fEventTimeMax=max;
-  fEventMeanTime=(fEventTimeMin+fEventTimeMax)/2;
-  fEventTimeInMCHeader=kFALSE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::SetEventMeanTime(Double_t mean)
-{
-  fEventMeanTime =mean;
-  TString form="(1/";
-  form+= mean;
-  form+=")*exp(-x/";
-  form+=mean;
-  form+=")";
-  fTimeProb= new TF1("TimeProb.", form.Data(), 0., mean*10);
-  fTimeProb->GetRandom();
-  fEventTimeInMCHeader=kFALSE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::SetEventTime()
-{
-  fLogger->Debug(MESSAGE_ORIGIN, "Set event time for Entry = %i , where the current entry is %i",
-                 fTimeforEntryNo, fCurrentEntryNo );
-  if(fTimeProb!=0) {
-    fLogger->Debug(MESSAGE_ORIGIN, "Time will be  set via sampling method : old time = %f ", fEventTime);
-    fEventTime += fTimeProb->GetRandom();
-    fLogger->Debug(MESSAGE_ORIGIN, "Time set via sampling method : %f ", fEventTime);
-  } else {
-    fEventTime += gRandom->Uniform( fEventTimeMin,  fEventTimeMax);
-    fLogger->Debug(MESSAGE_ORIGIN, "Time set via Uniform Random : %f ", fEventTime);
-
-  }
-  fTimeforEntryNo=fCurrentEntryNo;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::BGWindowWidthNo(UInt_t background, UInt_t Signalid)
-{
-  fLogger->Info(MESSAGE_ORIGIN, "SetSignal rate for signal %i  : %i ", Signalid , background );
-  fSBRatiobyN=kTRUE;
-  if(fSBRatiobyT) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Signal rate already set by TIME!!");
-  }
-  Double_t value=1.0/background;
-  if(background!=0) {
-    fSignalBGN[Signalid]=value;
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Background cannot be Zero when setting the signal rate!!");
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void  FairRootManager::BGWindowWidthTime(Double_t background, UInt_t Signalid)
-{
-  fSBRatiobyT=kTRUE;
-  if(fSBRatiobyN) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Signal rate already set by NUMBER!!");
-  }
-  if(fEventTimeInMCHeader) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "You have to Set the Event mean time before using SetSignalRateTime!");
-  }
-  if(fEventMeanTime==0) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Event mean time cannot be zero when using signal rate with time ");
-  }
-  /**convert to number of event by dividing by the mean time */
-  Double_t value=fEventMeanTime/background;
-  if(background!=0) {
-    fSignalBGN[Signalid]=value;
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Background cannot be Zero when setting the signal rate!!");
-  }
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-Int_t  FairRootManager::CheckMaxEventNo(Int_t EvtEnd)
-{
-
-  fLogger->Info(MESSAGE_ORIGIN, "Maximum No of Event was set manually to :  %i , we will check if there is enough entries for this!! ", EvtEnd);
-  Int_t MaxEventNo=0;
-  if(EvtEnd!=0) {
-    MaxEventNo=EvtEnd;
-  }
-  Int_t localMax=0;
-  if(!fMixedInput) {
-    MaxEventNo=fInChain->GetEntries();
-  } else {
-    Int_t MaxBG=fBackgroundChain->GetEntries();
-    Int_t MaxS=0;
-    Double_t ratio=0.;
-    std::map<UInt_t, Double_t>::const_iterator iterN;
-    for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
-      TChain* chain = fSignalTypeList[iterN->first];
-      MaxS=chain->GetEntries();
-      fLogger->Info(MESSAGE_ORIGIN, "Signal chain  No %i  has  :  %i  entries ", iterN->first, MaxS);
-      ratio=iterN->second;
-      cout<< " ratio = "<< ratio <<  "floor(MaxS/ratio) "<<floor(MaxS/ratio) << "  MaxBG = " << MaxBG  << endl;
-      if(floor(MaxS/ratio) > MaxBG) {
-        localMax=MaxBG+(Int_t)floor(MaxBG*ratio);
-        fLogger->Warning(MESSAGE_ORIGIN, "No of Event in Background chain is not enough for all signals in chain  %i ", iterN->first);
-      } else {
-        localMax=(Int_t)floor(MaxS/ratio);
-        fLogger->Warning(MESSAGE_ORIGIN, "No of Event in signal chain %i is not enough, the maximum event number will be reduced to : %i ", iterN->first,localMax );
-      }
-      if(MaxEventNo==0 || MaxEventNo > localMax) {
-        MaxEventNo=localMax;
-      }
-    }
-    fLogger->Info(MESSAGE_ORIGIN, "Maximum No of Event will be set to :  %i ", MaxEventNo);
-  }
-  return MaxEventNo;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairWriteoutBuffer* FairRootManager::RegisterWriteoutBuffer(TString branchName, FairWriteoutBuffer* buffer)
-{
-  if (fWriteoutBufferMap[branchName] == 0) {
-    fWriteoutBufferMap[branchName] = buffer;
-  } else {
-    fLogger->Warning(MESSAGE_ORIGIN, "Branch %s is already registered in WriteoutBufferMap", branchName.Data());
-    delete buffer;
-  }
-  return fWriteoutBufferMap[branchName];
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairWriteoutBuffer* FairRootManager::GetWriteoutBuffer(TString branchName)
-{
-  if (fWriteoutBufferMap.count(branchName) > 0) {
-    return fWriteoutBufferMap[branchName];
-  } else {
-    return 0;
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::StoreWriteoutBufferData(Double_t eventTime)
-{
-  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
-    iter->second->WriteOutData(eventTime);
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::StoreAllWriteoutBufferData()
-{
-  Bool_t dataInBuffer = kFALSE;
-  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
-    if (iter->second->GetNData() > 0) {
-      dataInBuffer = kTRUE;
-    }
-    iter->second->WriteOutAllData();
-  }
-  fFillLastData = dataInBuffer;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRootManager::DeleteOldWriteoutBufferData()
-{
-  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
-    iter->second->DeleteOldData();
-  }
-}
-//_____________________________________________________________________________
-
-ClassImp(FairRootManager)
-
-
-
-
-
-
-
-
diff --git a/base/FairRunAna.cxx b/base/FairRunAna.cxx
deleted file mode 100644
index c06b81f..0000000
--- a/base/FairRunAna.cxx
+++ /dev/null
@@ -1,922 +0,0 @@
-// -------------------------------------------------------------------------
-// -----                   FairRunAna source file                      -----
-// -----            Created 06/01/04  by M. Al-Turany                  -----
-// -------------------------------------------------------------------------
-
-#include "FairRunAna.h"
-
-#include "FairRootManager.h"
-#include "FairTask.h"
-#include "FairBaseParSet.h"
-#include "FairEventHeader.h"
-#include "FairFieldFactory.h"
-#include "FairRuntimeDb.h"
-#include "FairTrajFilter.h"
-#include "FairRunIdGenerator.h"
-#include "FairLogger.h"
-#include "FairFileHeader.h"
-#include "FairMCEventHeader.h"
-#include "FairParIo.h"
-#include "FairAnaSelector.h"
-
-#include "TROOT.h"
-#include "TTree.h"
-#include "TSeqCollection.h"
-#include "TGeoManager.h"
-#include "TKey.h"
-#include "TF1.h"
-#include "TSystem.h"
-#include "TProof.h"
-#include "TProofOutputFile.h"
-
-#include <iostream>
-#include <list>
-
-using std::cout;
-using std::endl;
-using std::list;
-
-
-//_____________________________________________________________________________
-FairRunAna* FairRunAna::fgRinstance= 0;
-//_____________________________________________________________________________
-FairRunAna* FairRunAna::Instance()
-{
-
-  return fgRinstance;
-}
-//_____________________________________________________________________________
-FairRunAna::FairRunAna()
-  :FairRun(),
-   fRunInfo(),
-   fIsInitialized(kFALSE),
-   fInputGeoFile(0),
-   fLoadGeo( kFALSE),
-   fEvtHeader(0),
-   fMCHeader(0),
-   fStatic(kFALSE),
-   fField(0),
-   fTimeStamps(kFALSE),
-   fInFileIsOpen(kFALSE),
-   fMixedInput(kFALSE),
-   fEventTimeMin(0),
-   fEventTimeMax(0),
-   fEventTime(0),
-   fEventMeanTime(0),
-   fTimeProb(0),
-   fProof(NULL),
-   fProofAnalysis(kFALSE),
-   fRunOnProofWorker(kFALSE),
-   fProofServerName(""),
-   fProofParName("$VMCWORKDIR/gconfig/libFairRoot.par"),
-   fOutputDirectory(""),
-   fProofOutputStatus("copy"),
-   fFinishProcessingLMDFile(kFALSE)
-{
-
-  fgRinstance=this;
-  fAna=kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairRunAna::FairRunAna(const char* type, const char* proofName)
-  :FairRun(),
-   fRunInfo(),
-   fIsInitialized(kFALSE),
-   //   fInputFile(0),
-   fInputGeoFile(0),
-   fLoadGeo( kFALSE),
-   fEvtHeader(0),
-   fMCHeader(0),
-   fStatic(kFALSE),
-   fField(0),
-   fTimeStamps(kFALSE),
-   fInFileIsOpen(kFALSE),
-   fMixedInput(kFALSE),
-   fEventTimeMin(0),
-   fEventTimeMax(0),
-   fEventTime(0),
-   fEventMeanTime(0),
-   fTimeProb(0),
-   fRunOnProofWorker(kFALSE),
-   fProofParName("$VMCWORKDIR/gconfig/libFairRoot.par"),
-   fOutputDirectory(""),
-   fProofOutputStatus("copy"),
-   fFinishProcessingLMDFile(kFALSE)
-{
-  TString anaType = type;
-  anaType.ToLower();
-
-  fProof = NULL;
-  fProofAnalysis = kFALSE;
-  fProofServerName = proofName;
-
-  if ( anaType.Contains("proof") ) {
-    fProofAnalysis = kTRUE;
-    fProofServerName = proofName;
-
-    cout << "+++++++ T P R O O F +++++++++++++++++++++++++++++++++" << endl;
-    cout << "creating TProof* proof = TProof::Open(\"" << fProofServerName.Data()
-         << "\");" << endl;
-    TProof::AddEnvVar("LOCALDATASERVER","file://");
-    //    TProof* proof = TProof::Open("lite:///?workers=1");
-    fProof = TProof::Open(fProofServerName.Data());
-    cout << "+++++++ C R E A T E D +++++++++++++++++++++++++++++++" << endl;
-    //    fStatic = kTRUE;
-  }
-
-  fgRinstance=this;
-  fAna=kTRUE;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-FairRunAna::~FairRunAna()
-{
-  //  delete fFriendFileList;
-  if (fField) {
-    delete fField;
-  }
-  if (gGeoManager) {
-    delete gGeoManager;
-  }
-}
-
-//_____________________________________________________________________________
-
-void  FairRunAna::SetGeomFile(const char* GeoFileName)
-{
-  if (fIsInitialized) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "Geometry file has to be set before Run::Init !") ;
-    exit(-1);
-  } else {
-
-    TFile* CurrentFile=gFile;
-    fInputGeoFile= new TFile(GeoFileName);
-    if (fInputGeoFile->IsZombie()) {
-      fLogger->Error(MESSAGE_ORIGIN, "Error opening Geometry Input file");
-      fInputGeoFile=0;
-    }
-    fLogger->Info(MESSAGE_ORIGIN, " Opening Geometry input file: %s ", GeoFileName);
-    fLoadGeo=kTRUE;
-    gFile=CurrentFile;
-  }
-}
-
-//_____________________________________________________________________________
-
-void FairRunAna::Init()
-{
-
-  if (fIsInitialized) {
-    fLogger->Fatal(MESSAGE_ORIGIN,"Error Init is already called before!");
-    exit(-1);
-  } else {
-    fIsInitialized=kTRUE;
-  }
-
-  if ( fRunOnProofWorker ) {
-    fInFileIsOpen = fRootManager->OpenInTree();
-  } else {
-    // Open the input file and add other input files added by AddFile to the
-    // input chain. Do a check if the added files are of the same type
-    // as the the input file. Same type means check if they contain the
-    // same branch.
-    if (!fMixedInput) {
-      fInFileIsOpen = fRootManager->OpenInChain();
-    } else {
-      Bool_t openBKChain = fRootManager->OpenBackgroundChain();
-      if (!openBKChain) {
-        fLogger->Fatal(MESSAGE_ORIGIN, "Could not open background Chain!");
-      }
-      fRootManager->OpenSignalChain();
-    }
-  }
-  //Load Geometry from user file
-
-  if (fLoadGeo) {
-    if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
-      TIter next(fInputGeoFile->GetListOfKeys());
-      TKey* key;
-      while ((key = (TKey*)next())) {
-        if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
-          continue;
-        }
-        gGeoManager = (TGeoManager*)key->ReadObj();
-        break;
-      }
-    }
-  }
-  if (fInFileIsOpen) {
-    if ( fRunOnProofWorker ) {
-      if (fLoadGeo && gGeoManager==0) {
-        fRootManager->GetInFile()->Get("FAIRGeom");
-      }
-      if (fLoadGeo && gGeoManager==0) {
-      }
-    } else {
-
-      // Add all friend files defined by AddFriend to the correct chain
-      fRootManager->AddFriendsToChain();
-      if (fLoadGeo && gGeoManager==0) {
-        // Check if the geometry in the first file of the Chain
-        fRootManager->GetInChain()->GetFile()->Get("FAIRGeom");
-      }
-      //check that the geometry was loaded if not try all connected files!
-      if (fLoadGeo && gGeoManager==0) {
-        fLogger->Info(MESSAGE_ORIGIN, "Geometry was not found in the input file we will look in the friends if any!" );
-        TFile* currentfile= gFile;
-        TFile* nextfile=0;
-        TSeqCollection* fileList=gROOT->GetListOfFiles();
-        for (Int_t k=0; k<fileList->GetEntries(); k++) {
-          nextfile=(TFile*)fileList->At(k);
-          if (nextfile) {
-            nextfile->Get("FAIRGeom");
-          }
-          if (gGeoManager) {
-            break;
-          }
-        }
-        gFile=currentfile;
-      }
-    }
-  } else if (fMixedInput) {
-
-
-
-  } else { //  if(fInputFile )
-    // NO input file but there is a geometry file
-    if (fLoadGeo) {
-      if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
-        TIter next(fInputGeoFile->GetListOfKeys());
-        TKey* key;
-        while ((key = (TKey*)next())) {
-          if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
-            continue;
-          }
-          gGeoManager = (TGeoManager*)key->ReadObj();
-          break;
-        }
-      }
-    }
-  }
-  //Init the Chain ptr
-  //  fcurrent = fChainList.begin();
-// fOutFile = fRootManager->OpenOutFile(fOutname);
-
-  if ( fProofAnalysis ) {
-    return;
-  }
-
-  gROOT->GetListOfBrowsables()->Add(fTask);
-
-  // Init the RTDB containers
-  fRtdb= GetRuntimeDb();
-  FairBaseParSet* par=(FairBaseParSet*)
-                      (fRtdb->getContainer("FairBaseParSet"));
-
-  /**Set the IO Manager to run with time stamps*/
-  if (fTimeStamps) {
-    fRootManager->RunWithTimeStamps();
-  }
-
-
-
-  // Assure that basic info is there for the run
-  //  if(par && fInputFile) {
-  if (par && fInFileIsOpen) {
-
-    fLogger->Info(MESSAGE_ORIGIN,"Parameter and input file are available, Assure that basic info is there for the run!");
-    fRootManager->ReadEvent(0);
-
-    fEvtHeader = (FairEventHeader*)fRootManager->GetObject("EventHeader.");
-    fMCHeader = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
-    if (fEvtHeader ==0) {
-      fEvtHeader=GetEventHeader();
-      fRunId = fMCHeader->GetRunID();
-      fEvtHeader->SetRunId(fRunId);
-      fRootManager->SetEvtHeaderNew(kTRUE);
-    } else {
-      fRunId = fEvtHeader->GetRunId();
-    }
-
-    //Copy the Event Header Info to Output
-    fEvtHeader->Register();
-
-    // Init the containers in Tasks
-
-    fRtdb->initContainers(fRunId);
-    fTask->SetParTask();
-
-    fRtdb->initContainers( fRunId );
-    if (gGeoManager==0) {
-      par->GetGeometry();
-    }
-    //  fRootManager->SetBranchNameList(par->GetBranchNameList());
-
-  } else if (fMixedInput) {
-    fLogger->Info(MESSAGE_ORIGIN,"Initializing for Mixed input");
-
-    //For mixed input we have to set containers to static becauser of the different run ids
-    //fRtdb->setContainersStatic(kTRUE);
-
-    fEvtHeader = (FairEventHeader*) fRootManager->GetObject("EventHeader.");
-
-
-    fMCHeader = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
-    if (fEvtHeader ==0) {
-      fEvtHeader=GetEventHeader();
-      fRunId = fMCHeader->GetRunID();
-      fEvtHeader->SetRunId(fRunId);
-      fRootManager->SetEvtHeaderNew(kTRUE);
-    }
-
-
-    fRootManager->ReadBKEvent(0);
-
-    //Copy the Event Header Info to Output
-    fEvtHeader->Register();
-
-    fRunId = fEvtHeader->GetRunId();
-    // Init the containers in Tasks
-    fRtdb->initContainers(fRunId);
-
-    if (gGeoManager==0) {
-      fLogger->Info(MESSAGE_ORIGIN,"Read the Geometry from Parameter file");
-      par->GetGeometry();
-
-    }
-    if (gGeoManager==0) {
-      fLogger->Fatal(MESSAGE_ORIGIN,"Could not Read the Geometry from Parameter file");
-    }
-    fTask->SetParTask();
-    fRtdb->initContainers( fRunId );
-
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN,"Initializing without input file or Mixed input");
-    FairEventHeader* evt = GetEventHeader();
-    evt->Register();
-    FairRunIdGenerator genid;
-    fRunId = genid.generateId();
-    fRtdb->addRun(fRunId);
-    evt->SetRunId( fRunId);
-    fTask->SetParTask();
-    fRtdb->initContainers( fRunId );
-
-  }
-  FairFieldFactory* fieldfact= FairFieldFactory::Instance();
-  if (fieldfact) {
-    fieldfact->SetParm();
-  }
-
-  fRtdb->initContainers(fRunId);
-  fFileHeader->SetRunId(fRunId);
-
-  // create a field
-  // <DB>
-  // Add test for external FairField settings
-  if (fieldfact && !fField) {
-    fField= fieldfact->createFairField();
-  }
-  // Now call the User initialize for Tasks
-  fTask->InitTask();
-  // if the vis manager is available then initialize it!
-  FairTrajFilter* fTrajFilter = FairTrajFilter::Instance();
-  if (fTrajFilter) {
-    fTrajFilter->Init();
-  }
-
-  // create the output tree after tasks initialisation
-  fOutFile->cd();
-  TTree* outTree =new TTree("cbmsim", "/cbmout", 99);
-  fRootManager->TruncateBranchNames(outTree, "cbmout");
-  fRootManager->SetOutTree(outTree);
-  fRootManager->WriteFolder();
-  fRootManager->WriteFileHeader(fFileHeader);
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::InitContainers()
-{
-  fRtdb= GetRuntimeDb();
-  FairBaseParSet* par=(FairBaseParSet*)
-                      (fRtdb->getContainer("FairBaseParSet"));
-
-  if (par && fInFileIsOpen) {
-    fRootManager->ReadEvent(0);
-
-    fEvtHeader = (FairEventHeader*)fRootManager->GetObjectFromInTree("EventHeader.");
-    fMCHeader  = (FairMCEventHeader*)fRootManager->GetObjectFromInTree("MCEventHeader.");
-
-    if ( fMCHeader != 0 ) {
-      fRunId = fMCHeader->GetRunID();
-      fEvtHeader->SetRunId(fRunId); // should i do it?
-      fRootManager->SetEvtHeaderNew(kTRUE);
-    } else {
-      fRunId = fEvtHeader->GetRunId();
-    }
-
-    //Copy the Event Header Info to Output
-    fEvtHeader->Register();
-
-    // Init the containers in Tasks
-    fRtdb->initContainers(fRunId);
-    fTask->ReInitTask();
-    //    fTask->SetParTask();
-    fRtdb->initContainers( fRunId );
-    if (gGeoManager==0) {
-      par->GetGeometry();
-    }
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::RunMixed(Int_t Ev_start, Int_t Ev_end)
-{
-
-  fLogger->Debug(MESSAGE_ORIGIN,"Running in mixed mode");
-  Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
-  if (Ev_end==0) {
-    if (Ev_start==0) {
-      Ev_end=MaxAllowed;
-    } else {
-      Ev_end =  Ev_start;
-      if ( Ev_end > MaxAllowed ) {
-        Ev_end = MaxAllowed;
-      }
-      Ev_start=0;
-    }
-  } else {
-    if (Ev_end > MaxAllowed) {
-      Ev_end=MaxAllowed;
-    }
-  }
-
-  for (int i=Ev_start; i< Ev_end; i++) {
-    fRootManager->ReadEvent(i);
-    fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
-    fLogger->Debug(MESSAGE_ORIGIN,"------Event is read , now execute the tasks--------");
-    fTask->ExecuteTask("");
-    fLogger->Debug(MESSAGE_ORIGIN,"------ Tasks executed, now fill the tree  --------");
-    fRootManager->Fill();
-    fRootManager->DeleteOldWriteoutBufferData();
-    fTask->FinishEvent();
-    if (NULL !=  FairTrajFilter::Instance()) {
-      FairTrajFilter::Instance()->Reset();
-    }
-  }
-  fTask->FinishTask();
-  fRootManager->StoreAllWriteoutBufferData();
-  fRootManager->LastFill();
-  fRootManager->Write();
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end)
-{
-  if ( fProofAnalysis ) {
-    RunOnProof(Ev_start,Ev_end);
-    return;
-  }
-
-  if (fTimeStamps) {
-    RunTSBuffers();
-  } else if (fMixedInput) {
-    RunMixed(Ev_start,Ev_end);
-  } else {
-    UInt_t tmpId =0;
-    //  if (fInputFile==0) {
-    if (!fInFileIsOpen) {
-      DummyRun(Ev_start,Ev_end);
-      return;
-    }
-    if (Ev_end==0) {
-      if (Ev_start==0) {
-        Ev_end=Int_t((fRootManager->GetInChain())->GetEntries());
-      } else {
-        Ev_end =  Ev_start;
-        if ( Ev_end > ((fRootManager->GetInChain())->GetEntries()) ) {
-          Ev_end = (Int_t) (fRootManager->GetInChain())->GetEntries();
-        }
-        Ev_start=0;
-      }
-    } else {
-      Int_t fileEnd=(fRootManager->GetInChain())->GetEntries();
-      if (Ev_end > fileEnd) {
-        cout << "-------------------Warning---------------------------" << endl;
-        cout << " -W FairRunAna : File has less events than requested!!" << endl;
-        cout << " File contains : " << fileEnd  << " Events" << endl;
-        cout << " Requested number of events = " <<  Ev_end <<  " Events"<< endl;
-        cout << " The number of events is set to " << fileEnd << " Events"<< endl;
-        cout << "-----------------------------------------------------" << endl;
-        Ev_end = fileEnd;
-      }
-
-    }
-
-    fRunInfo.Reset();
-
-
-    for (int i=Ev_start; i< Ev_end; i++) {
-      fRootManager->ReadEvent(i);
-      /**
-       * if we have simulation files then they have MC Event Header and the Run Id is in it, any way it
-       * would be better to make FairMCEventHeader a subclass of FairEvtHeader.
-       */
-      if (fRootManager->IsEvtHeaderNew()) {
-        tmpId = fMCHeader->GetRunID();
-      } else {
-        tmpId = fEvtHeader->GetRunId();
-      }
-      if ( tmpId != fRunId ) {
-        fRunId = tmpId;
-        if ( !fStatic ) {
-          Reinit( fRunId );
-          fTask->ReInitTask();
-        }
-      }
-      //FairMCEventHeader* header = (FairMCEventHeader*)fRootManager->GetObject("MCEventHeader.");
-      //std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime();
-      fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
-      fTask->ExecuteTask("");
-      fRootManager->Fill();
-      fRootManager->DeleteOldWriteoutBufferData();
-      fTask->FinishEvent();
-
-      fRunInfo.StoreInfo();
-      if (NULL !=  FairTrajFilter::Instance()) {
-        FairTrajFilter::Instance()->Reset();
-      }
-
-    }
-
-    fRootManager->StoreAllWriteoutBufferData();
-    fTask->FinishTask();
-    if (fWriteRunInfo) {
-      fRunInfo.WriteInfo();
-    }
-    fRootManager->LastFill();
-    fRootManager->Write();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::Run(Double_t delta_t)
-{
-  while (fRootManager->ReadNextEvent(delta_t)==kTRUE) {
-    fTask->ExecuteTask("");
-    fRootManager->Fill();
-    fRootManager->DeleteOldWriteoutBufferData();
-    fTask->FinishEvent();
-    if (NULL !=  FairTrajFilter::Instance()) {
-      FairTrajFilter::Instance()->Reset();
-    }
-  }
-
-  fRootManager->StoreAllWriteoutBufferData();
-  fTask->FinishTask();
-  fRootManager->LastFill();
-  fRootManager->Write();
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::Run(Long64_t entry)
-{
-//  if (fTimeStamps) {
-//    RunTSBuffers();
-//  } else {
-  UInt_t tmpId =0;
-  fRootManager->ReadEvent(entry);
-  tmpId = fEvtHeader->GetRunId();
-  if ( tmpId != fRunId ) {
-    fRunId = tmpId;
-    if ( !fStatic ) {
-      Reinit( fRunId );
-      fTask->ReInitTask();
-    }
-  }
-  fTask->ExecuteTask("");
-  fTask->FinishTask();
-  fRootManager->Fill();
-  fRootManager->DeleteOldWriteoutBufferData();
-  fRootManager->LastFill();
-  fRootManager->Write();
-//  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::RunOneEvent(Long64_t entry)
-{
-  if (fTimeStamps) {
-    RunTSBuffers();
-  } else {
-    UInt_t tmpId =0;
-    fRootManager->ReadEvent(entry);
-    tmpId = fEvtHeader->GetRunId();
-    if ( tmpId != fRunId ) {
-      fRunId = tmpId;
-      if ( !fStatic ) {
-        Reinit( fRunId );
-        fTask->ReInitTask();
-      }
-    }
-    fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
-
-    fTask->ExecuteTask("");
-    fRootManager->Fill();
-    fRootManager->DeleteOldWriteoutBufferData();
-    fTask->FinishEvent();
-  }
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::RunTSBuffers()
-{
-  Int_t globalEvent = 0;
-
-  bool firstRun = true;
-  while (firstRun || fRootManager->AllDataProcessed() == kFALSE) {
-    firstRun = false;
-    if (globalEvent < fRootManager->GetInTree()->GetEntriesFast()) { //this step is necessary to load in all data which is not read in via TSBuffers
-      fRootManager->ReadEvent(globalEvent++);
-    }
-    fTask->ExecuteTask("");
-    fRootManager->Fill();
-    fRootManager->DeleteOldWriteoutBufferData();
-    fTask->FinishEvent();
-    if (NULL !=  FairTrajFilter::Instance()) {
-      FairTrajFilter::Instance()->Reset();
-    }
-  }
-  fTask->FinishTask();
-  fRootManager->LastFill();
-  fRootManager->Write();
-}
-//_____________________________________________________________________________
-//_____________________________________________________________________________
-
-void FairRunAna::RunOnLmdFiles(UInt_t NStart, UInt_t NStop)
-{
-  if(NStart==0 && NStop==0) {
-    NStart=0;
-    NStop=1000000000;
-    fLogger->Info(MESSAGE_ORIGIN," Maximum number of event is set to 1E9");
-  }
-  for (UInt_t i=NStart; i< NStop; i++) {
-    if ( fFinishProcessingLMDFile ) {
-      i = NStop; ///Same result like break
-
-    }
-
-    fTask->ExecuteTask("");
-    fRootManager->Fill();
-  }
-
-  fTask->FinishTask();
-  fRootManager->Write();
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::DummyRun(Int_t Ev_start, Int_t Ev_end)
-{
-
-  /** This methode is just for testing, if you are not sure about what you do, don't use it */
-  for (int i=Ev_start; i< Ev_end; i++) {
-    fTask->ExecuteTask("");
-    fRootManager->Fill();
-  }
-  fTask->FinishTask();
-  fRootManager->Write();
-
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::RunOnProof(Int_t NStart,Int_t NStop)
-{
-  cout << "FairRunAna::RunOnProof(" << NStart << "," << NStop << "): "
-       << "running FairAnaSelector on proof server: \"" << fProofServerName.Data() << "\" "
-       << "with PAR file name = \"" << fProofParName.Data() << "\"." << endl;
-
-  FairAnaSelector* proofSelector = new FairAnaSelector();
-
-
-  TChain* inChain = (TChain*)fRootManager->GetInChain();
-  TString par1File = "";
-  TString par2File = "";
-  if ( fRtdb->getFirstInput () ) {
-    par1File = fRtdb->getFirstInput ()->getFilename();
-  }
-  if ( fRtdb->getSecondInput() ) {
-    par2File = fRtdb->getSecondInput()->getFilename();
-  }
-
-  TString outDir = (fOutputDirectory.Length()>1?fOutputDirectory.Data():gSystem->WorkingDirectory());
-
-//   cout << "+++++++ T P R O O F +++++++++++++++++++++++++++++++++" << endl;
-//   cout << "creating TProof* proof = TProof::Open(\"" << fProofServerName.Data()
-//        << "\");" << endl;
-//   TProof::AddEnvVar("LOCALDATASERVER","file://");
-//   //    TProof* proof = TProof::Open("lite:///?workers=1");
-//   TProof* proof = TProof::Open(fProofServerName.Data());
-//   cout << "+++++++ C R E A T E D +++++++++++++++++++++++++++++++" << endl;
-
-  TString outFile = fRootManager->GetOutFile()->GetName();
-  fRootManager->CloseOutFile();
-
-  fProof->AddInput(fTask);
-
-  fProof->AddInput(new TNamed("FAIRRUNANA_fContainerStatic",(fStatic?"kTRUE":"kFALSE")));
-  fProof->AddInput(new TNamed("FAIRRUNANA_fProofOutputStatus",fProofOutputStatus.Data()));
-  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputDirectory",outDir.Data()));
-  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputFileName",outFile.Data()));
-  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput1FName",par1File.Data()));
-  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput2FName",par2File.Data()));
-
-  cout << "0309: ClearPackages" << endl;
-  fProof->ClearPackages();
-  cout << "0309: UploadPackages" << endl;
-  fProof->UploadPackage(fProofParName.Data());
-  cout << "0309: EnablePackages" << endl;
-  fProof->EnablePackage(fProofParName.Data());
-  cout << "0309: ShowPackages" << endl;
-  fProof->ShowPackages();
-  cout << "0309: Done" << endl;
-
-  Int_t nofChainEntries = inChain->GetEntries();
-  cout << "FairRunAna::RunOnProof(): The chain seems to have " << nofChainEntries << " entries." << endl;
-
-  TObjArray* listOfFiles = inChain->GetListOfFiles();
-  cout << "FairRunAna::RunOnProof(): There are " << listOfFiles->GetEntries() << " files in the chain." << endl;
-
-  inChain->SetProof();
-
-  Int_t nofEventsToAnalyze = NStop-NStart;
-
-  if ( nofEventsToAnalyze <= 0 ) {
-    cout << "You requested to analyze events from " << NStart << " to " << NStop << " that is " << nofEventsToAnalyze << " events!!!" << endl;
-    nofEventsToAnalyze = nofChainEntries-NStart;
-    cout << "It will be changed to analyze all events from " << NStart << " to the end of chain (" << nofChainEntries << "), that is to analyze " << nofEventsToAnalyze << " events." << endl;
-  }
-
-  cout << "FairRunAna::RunOnProof(): Starting inChain->Process(\"FairAnaSelector\",\"\","
-       << nofEventsToAnalyze << "," << NStart << ")" << endl;
-  inChain->Process("FairAnaSelector","",nofEventsToAnalyze,NStart);
-  cout << "FairRunAna::RunOnProof(): inChain->Process DONE" << endl;
-
-  return;
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::TerminateRun()
-{
-  fRootManager->StoreAllWriteoutBufferData();
-  fTask->FinishTask();
-  gDirectory->SetName(fRootManager->GetOutFile()->GetName());
-  //  fRunInfo.WriteInfo(); // CRASHES due to file ownership i guess...
-  //   cout << ">>> SlaveTerminate fRootManager->GetInChain()->Print()" << endl;
-  //   fRootManager->GetInChain()->Print();
-  //   cout << ">>>------------------------------------------------<<<" << endl;
-  fRootManager->LastFill();
-  fRootManager->Write();
-  fRootManager->CloseOutFile();
-}
-//_____________________________________________________________________________
-
-//_____________________________________________________________________________
-void FairRunAna::SetInputFile(TString name)
-{
-  if (!fMixedInput) {
-    fRootManager->SetInputFile(name);
-  }
-}
-//_____________________________________________________________________________
-void FairRunAna::SetSignalFile(TString name, UInt_t identifier )
-{
-  fMixedInput=kTRUE;
-  if (identifier==0) {
-    fLogger->Fatal(MESSAGE_ORIGIN," ----- Identifier 0 is reserved for background files! please use other value ------ ");
-  }
-  fRootManager->AddSignalFile(name, identifier);
-  fLogger->Info(MESSAGE_ORIGIN," ----- Mixed input mode will be used ------ ");
-}
-//_____________________________________________________________________________
-void FairRunAna::SetBackgroundFile(TString name)
-{
-  fMixedInput=kTRUE;
-  fRootManager->SetBackgroundFile(name);
-  fLogger->Info(MESSAGE_ORIGIN," ----- Mixed input mode will be used ------ ");
-
-}//_____________________________________________________________________________
-void FairRunAna::AddBackgroundFile(TString name)
-{
-  if (fMixedInput) {
-    fRootManager->AddBackgroundFile(name);
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN," Background can be added only if mixed mode is used");
-  }
-}
-//_____________________________________________________________________________
-void FairRunAna::AddSignalFile(TString name, UInt_t identifier )
-{
-  if (fMixedInput) {
-    if (identifier==0) {
-      fLogger->Fatal(MESSAGE_ORIGIN," ----- Identifier 0 is reserved for background files! please use other value ------ ");
-    }
-    fRootManager->AddSignalFile(name, identifier);
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN," Signal can be added only if mixed mode is used");
-  }
-}
-//_____________________________________________________________________________
-void FairRunAna::AddFriend (TString Name)
-{
-  if (fIsInitialized) {
-    fLogger->Fatal(MESSAGE_ORIGIN, "AddFriend has to be set before Run::Init !");
-  } else {
-    fRootManager->AddFriend(Name);
-  }
-}
-//_____________________________________________________________________________
-
-void FairRunAna::Reinit(UInt_t runId)
-{
-  // reinit procedure
-  fRtdb->initContainers( runId );
-}
-//_____________________________________________________________________________
-
-void FairRunAna::AddFile(TString name)
-{
-  fRootManager->AddFile(name);
-}
-//_____________________________________________________________________________
-
-void  FairRunAna::RunWithTimeStamps()
-{
-  if (ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)) {
-    if (fIsInitialized) {
-      fLogger->Warning(MESSAGE_ORIGIN, "RunWithTimeStamps has to be set before Run::Init !");
-      exit(-1);
-    } else {
-      fTimeStamps=kTRUE;
-      fRootManager->RunWithTimeStamps();
-    }
-  } else {
-    fLogger->Fatal(MESSAGE_ORIGIN, "RunWithTimeStamps need at least ROOT version 5.29.1") ;
-  }
-}
-//_____________________________________________________________________________
-
-void FairRunAna::CompressData()
-{
-  fRootManager->SetCompressData(kTRUE);
-}
-//_____________________________________________________________________________
-void FairRunAna::SetEventTimeInterval(Double_t min, Double_t max)
-{
-  fRootManager->SetEventTimeInterval(min,max);
-}
-//_____________________________________________________________________________
-void  FairRunAna::SetEventMeanTime(Double_t mean)
-{
-  fRootManager->SetEventMeanTime(mean);
-}
-//_____________________________________________________________________________
-void  FairRunAna::SetContainerStatic(Bool_t tempBool)
-{
-  fStatic=tempBool;
-  if ( fStatic ) {
-    fLogger->Info(MESSAGE_ORIGIN, "Parameter Cont. initialisation is static");
-  } else {
-    fLogger->Info(MESSAGE_ORIGIN, "Parameter Cont. initialisation is NOT static");
-  }
-}
-//_____________________________________________________________________________
-void  FairRunAna::BGWindowWidthNo(UInt_t background, UInt_t Signalid)
-{
-  fRootManager->BGWindowWidthNo(background, Signalid);
-}
-//_____________________________________________________________________________
-void  FairRunAna::BGWindowWidthTime(Double_t background, UInt_t Signalid)
-{
-  fRootManager->BGWindowWidthTime(background, Signalid);
-}
-//_____________________________________________________________________________
-
-ClassImp(FairRunAna)
-
-
diff --git a/base/FairRunIdGenerator.h b/base/FairRunIdGenerator.h
deleted file mode 100644
index 1d660d2..0000000
--- a/base/FairRunIdGenerator.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef FAIRRUNIDGENERATOR_H
-#define FAIRRUNIDGENERATOR_H
-
-
-typedef unsigned char      uint8_t;
-typedef unsigned short int uint16_t;
-typedef unsigned int       uint32_t;
-typedef unsigned char      uuid_t[16];
-
-class FairRunIdGenerator
-{
-    struct uuid {
-      uint32_t time_low;
-      uint16_t time_mid;
-      uint16_t time_hi_and_version;
-      uint16_t clock_seq;
-      uint8_t node[6];
-    };
-    int get_random_fd(void);
-    void get_random_bytes(void*, int);
-    int get_node_id(unsigned char*);
-    int get_clock(uint32_t*, uint32_t*, uint16_t*);
-    void uuid_generate_time(uuid_t);
-    void uuid_generate_random(uuid_t);
-    void uuid_generate(uuid_t);
-    void uuid_pack(const struct uuid*, uuid_t);
-    void uuid_unpack(const uuid_t, struct uuid*);
-  public:
-    FairRunIdGenerator() {}
-    ~FairRunIdGenerator() {}
-    unsigned int generateId(void);
-};
-
-#endif
diff --git a/base/FairRunInfo.h b/base/FairRunInfo.h
deleted file mode 100644
index fa99ecb..0000000
--- a/base/FairRunInfo.h
+++ /dev/null
@@ -1,57 +0,0 @@
-#ifndef FAIRRUNINFO_H
-#define FAIRRUNINFO_H
-
-
-#include "TObject.h"
-#include "TSystem.h"
-#include "TTimeStamp.h"
-
-#include <vector>
-
-class FairLogger;
-class TList;
-
-class FairRunInfo : public TObject
-{
-
-  public:
-
-    FairRunInfo();
-
-    ~FairRunInfo();
-
-    void StoreInfo();
-
-    void WriteInfo();
-
-    void Reset();
-
-  private:
-
-    TTimeStamp  fTimeStamp;//!
-    CpuInfo_t   fCpuInfo;//!
-    MemInfo_t   fMemInfo;//!
-    ProcInfo_t  fProcInfo;//!
-    std::vector<Double_t> fTimeDiff;//!
-    std::vector<Double_t> fTime;//!
-    std::vector<Long_t> fResidentMemory;//!
-    std::vector<Long_t> fVirtualMemory;//!
-    FairLogger* fLogger;
-
-    void CalculateTimeDifference();
-
-    void PrintInfo();
-
-    void GetInfo();
-
-    void CreateAndFillHistograms(TList* histoList);
-
-    void WriteHistosToFile(TList* histoList);
-
-    FairRunInfo(const FairRunInfo&);
-    FairRunInfo& operator=(const FairRunInfo&);
-
-    ClassDef(FairRunInfo,1)
-
-};
-#endif
diff --git a/base/FairTimeStamp.cxx b/base/FairTimeStamp.cxx
deleted file mode 100644
index 19412fc..0000000
--- a/base/FairTimeStamp.cxx
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "FairTimeStamp.h"
-
-// -----   Default constructor   -------------------------------------------
-FairTimeStamp::FairTimeStamp()
-  : FairMultiLinkedData(),
-    fTimeStamp(-1),
-    fTimeStampError(-1),
-    fEntryNr()
-{
-}
-// -----   Standard constructor   ------------------------------------------
-FairTimeStamp::FairTimeStamp(Double_t time)
-  : FairMultiLinkedData(),
-    fTimeStamp(time),
-    fTimeStampError(-1),
-    fEntryNr()
-{
-}
-
-FairTimeStamp::FairTimeStamp(Double_t time, Double_t timeerror)
-  : FairMultiLinkedData(),
-    fTimeStamp(time),
-    fTimeStampError(timeerror),
-    fEntryNr()
-{
-}
-// -----   Destructor   ----------------------------------------------------
-FairTimeStamp::~FairTimeStamp()
-{
-}
-
-// -------------------------------------------------------------------------
-
-void FairTimeStamp::Print(std::ostream& out) const
-{
-  out << fEntryNr << "TimeStamp: " << GetTimeStamp() << " +/- " << GetTimeStampError() << std::endl;
-  FairMultiLinkedData::Print(out);
-}
-ClassImp(FairTimeStamp)
diff --git a/base/FairVTrack.cxx b/base/FairVTrack.cxx
deleted file mode 100644
index 6b6fb13..0000000
--- a/base/FairVTrack.cxx
+++ /dev/null
@@ -1,296 +0,0 @@
-#include "FairVTrack.h"
-
-#include "TPad.h"
-#include "TParticle.h"
-#include "TView.h"
-#include "TGeoTrack.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
-
-ClassImp(FairVTrack)
-
-//_______________________________________________________________________
-FairVTrack::FairVTrack():
-  fTrack(0),
-  fIndex(0),
-  fParticle(0)
-
-{
-  //
-  // Default constructor
-  //
-}
-
-//_______________________________________________________________________
-FairVTrack::FairVTrack(const FairVTrack& pts):
-  TPolyLine3D(pts),
-  fTrack(0),
-  fIndex(0),
-  fParticle(0)
-{
-  //
-  // Copy constructor
-  //
-  pts.Copy(*this);
-}
-
-//_______________________________________________________________________
-FairVTrack::FairVTrack(Int_t nhits):
-  TPolyLine3D(nhits),
-  fTrack(0),
-  fIndex(0),
-  fParticle(0)
-
-{
-  //
-  // Standard constructor
-  //
-  ResetBit(kCanDelete);
-}
-
-//_______________________________________________________________________
-FairVTrack::~FairVTrack()
-{
-  //
-  // Default destructor
-  //
-}
-
-//_______________________________________________________________________
-void FairVTrack::Copy(TObject& pts) const
-{
-  //
-  // Copy *this onto pts
-  //
-  if((TObject*)this != &pts) {
-    ((TPolyLine3D*)this)->Copy(dynamic_cast<TPolyLine3D&>(pts));
-    (dynamic_cast<FairVTrack&>(pts)).fGLList = fGLList;
-    (dynamic_cast<FairVTrack&>(pts)).fLastPoint = fLastPoint;
-    (dynamic_cast<FairVTrack&>(pts)).fIndex = fIndex;
-    (dynamic_cast<FairVTrack&>(pts)).fParticle = fParticle;
-  }
-}
-
-//_______________________________________________________________________
-Int_t FairVTrack::DistancetoPrimitive(Int_t px, Int_t py)
-{
-  //
-  //*-*-*-*-*-*-*Compute distance from point px,py to a 3-D polymarker*-*-*-*-*
-  //*-*          =====================================================
-  //*-*
-  //*-*  Compute the closest distance of approach from point
-  //*-*  px,py to each segment
-  //*-*  of the polyline.
-  //*-*  Returns when the distance found is below DistanceMaximum.
-  //*-*  The distance is computed in pixels units.
-  //*-*
-  //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
-  //const Int_t inaxis = 7;
-  //Int_t dist = 9999;
-  return TPolyLine3D::DistancetoPrimitive(px,py);
-}
-
-//_______________________________________________________________________
-void FairVTrack::DumpParticle() const
-{
-  //
-  //   Dump particle corresponding to this point
-
-  if (fParticle) { fParticle->Dump(); }
-
-}
-
-//_______________________________________________________________________
-void FairVTrack::ExecuteEvent(Int_t event, Int_t px, Int_t py)
-{
-  //
-  //*-*-*-*-*-*-*-*-*-*Execute action corresponding to one event*-*-*-*-*-*-*-*
-  //*-*                =========================================
-  //*-*
-  //*-*  This member function must be implemented to realize the action
-  //*-*  corresponding to the mouse click on the object in the window
-  //*-*
-  //*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-
-  gPad->SetCursor(kCross);
-  /*
-    if (gPad->GetView())
-      gPad->GetView()->ExecuteRotateView(event, px, py);
-    */
-  // cout << "FairVTrack::ExecuteEvent" << event <<" " <<px <<" " <<  py<< endl;
-  fParticle->ExecuteEvent(event, px, py);
-
-
-}
-
-//_______________________________________________________________________
-const Text_t* FairVTrack::GetName() const
-{
-  //
-  // Return name of the Geant3 particle corresponding to this point
-  //
-
-  if (!fParticle) { return "Particle"; }
-  return fParticle->GetName();
-}
-
-//_______________________________________________________________________
-Text_t* FairVTrack::GetObjectInfo(Int_t px, Int_t py) const
-{
-  //
-  //   Redefines TObject::GetObjectInfo.
-  //   Displays the info (particle,etc
-  //   corresponding to cursor position px,py
-  //
-// static char info[64];
-// sprintf(info,"%s %d",GetName(),fIndex);
-  return fParticle->GetObjectInfo(px,py);
-}
-
-//_______________________________________________________________________
-TParticle* FairVTrack::GetParticle() const
-{
-  //
-  //   Returns pointer to particle
-  return fParticle;
-}
-
-//_______________________________________________________________________
-void FairVTrack::InspectParticle() const
-{
-  //   Inspect particle corresponding to this track
-
-  if (fParticle) { fParticle->Inspect(); }
-
-}
-//_______________________________________________________________________
-
-void FairVTrack::SetParticle(TParticle* p)
-{
-  fParticle = p;
-  SetLineColor(Color(p->GetPdgCode()));
-}
-//_______________________________________________________________________
-
-void FairVTrack::SetTrack(TGeoTrack* Tr)
-{
-  fTrack=Tr;
-  SetLineColor(Color(Tr->GetPDG()));
-}
-//_______________________________________________________________________
-
-Int_t FairVTrack::Color(Int_t pdg)
-{
-  switch(pdg) {
-
-  case   22     :
-    return  1;    // photon
-  case   -2112  :
-    return  2 ;   // anti-neutron
-  case   -11    :
-    return  3;    // e+
-  case   -3122  :
-    return  4;   // anti-Lambda
-  case   11     :
-    return  5;    // e-
-  case   -3222  :
-    return  6;   // Sigma-
-  case   12     :
-    return  7;    // e-neutrino (NB: flavour undefined by Geant)
-  case   -3212  :
-    return  8;   // Sigma0
-  case   -13    :
-    return  9;    // mu+
-  case   -3112  :
-    return  10;   // Sigma+ (PB)*/
-  case   13     :
-    return  11;    // mu-
-  case   -3322  :
-    return  12;   // Xi0
-  case   111    :
-    return  13;    // pi0
-  case   -3312  :
-    return  14;   // Xi+
-  case   211    :
-    return  15;    // pi+
-  case   -3334  :
-    return  16;   // Omega+ (PB)
-  case   -211   :
-    return  17;    // pi-
-  case   -15    :
-    return  18;   // tau+
-  case   130    :
-    return  19;   // K long
-  case   15     :
-    return  20;   // tau-
-  case   321    :
-    return  21;   // K+
-  case   411    :
-    return  22;   // D+
-  case   -321   :
-    return  23;   // K-
-  case   -411   :
-    return  24;   // D-
-  case   2112   :
-    return  25;   // n
-  case   421    :
-    return  26;   // D0
-  case   2212   :
-    return  27;   // p
-  case   -421   :
-    return  28;   // D0
-  case   -2212  :
-    return  29;   // anti-proton
-  case   431    :
-    return  30;   // Ds+
-  case   310    :
-    return  31;   // K short
-  case   -431   :
-    return  32;   // anti Ds-
-  case   221    :
-    return  33;   // eta
-  case   4122   :
-    return  34;   // Lamba_c+
-  case   3122   :
-    return  35;   // Lambda
-  case   24     :
-    return  36;   // W+
-  case   3222   :
-    return  37;   // Sigma+
-  case   -24    :
-    return  38;   // W-
-  case   3212   :
-    return  39;   // Sigma0
-  case   23     :
-    return  40;   // Z
-  case   3112   :
-    return  41;   // Sigma-
-  case   3322   :
-    return  42;   // Xi0
-  case   3312   :
-    return  43;   // Xi-
-  case   3334   :
-    return  44;   // Omega- (PB)
-  case   50000050   :
-    return  801;   // Cerenkov
-  default  :
-    return 0;
-
-  }
-
-}
-
-
-
-
-
-
-
-
-
-
-
diff --git a/base/FairVTrack.h b/base/FairVTrack.h
deleted file mode 100644
index 0c6a449..0000000
--- a/base/FairVTrack.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
-* To draw the tracks in openGL
-* @author M. Al-Turany
-* @version 0.1
-* @since 22.11.07
-*/
-
-#ifndef FAIRVTRACK_H
-#define FAIRVTRACK_H
-#include "TPolyLine3D.h"
-#include "TGeoTrack.h"
-
-class TParticle;
-class TGeoTrack;
-class FairVTrack : public TPolyLine3D
-{
-  public:
-    FairVTrack();
-    FairVTrack(const FairVTrack& pts);
-    FairVTrack(Int_t nhits);
-    virtual ~FairVTrack();
-    void SetTrack(TGeoTrack* Tr);
-    virtual Int_t         DistancetoPrimitive(Int_t px, Int_t py);
-    virtual void          ExecuteEvent(Int_t event, Int_t px, Int_t py);
-    Int_t                   GetIndex() const {return fIndex;}
-    virtual const Text_t* GetName() const;
-    virtual void          InspectParticle() const; // *MENU*
-    virtual void          DumpParticle() const; // *MENU*
-    virtual Text_t*       GetObjectInfo(Int_t px, Int_t py) const;
-    virtual void          SetParticle(TParticle* p);
-    TParticle*              GetParticle() const;
-    FairVTrack&            operator=(const FairVTrack& pts)
-    {pts.Copy(*this); return (*this);}
-  protected:
-    void Copy(TObject& pts) const;
-    Int_t Color(Int_t pdg);
-    TGeoTrack*   fTrack;
-    Int_t          fIndex;
-    TParticle*     fParticle;
-    ClassDef(FairVTrack,1) //Class to  Tracks (Also in OpenGL viewer of ROOT)
-};
-#endif
-
-
-
-
-
diff --git a/base/FairVolumeList.h b/base/FairVolumeList.h
deleted file mode 100644
index 2d0fc65..0000000
--- a/base/FairVolumeList.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef FAIR_VOLUMELIST_H
-#define FAIR_VOLUMELIST_H
-
-//#include "FairVolume.h"
-
-#include "TObject.h"
-#include "TObjArray.h"
-#include "TString.h"
-
-#include <iostream>
-
-class FairVolume;
-//class TObjArray;
-
-/**
-* This Object is only used for internal book keeping!
-* @author M. Al-Turany, D. Bertini
-* @version 0.1
-* @since 12.01.04
-*/
-
-class FairVolumeList : public TObject
-{
-  private:
-    TObjArray* fData;
-    FairVolumeList(const FairVolumeList&);
-    FairVolumeList& operator=(const FairVolumeList&);
-
-  public:
-    FairVolumeList();
-    virtual ~FairVolumeList();
-
-    FairVolume* getVolume( TString* name );
-    Int_t getVolumeId( TString* name );
-
-    FairVolume* findObject( TString name );
-    void addVolume( FairVolume* elem);
-
-    Int_t getEntries () { return fData->GetEntries();}
-    FairVolume* At(Int_t pos ) { return ( (FairVolume*) fData->At(pos)); }
-
-    ClassDef(FairVolumeList,1) // Volume List
-};
-
-#endif //FAIR_VOLUMELIST_H
-
-
diff --git a/base/FairWriteoutBufferAbsBasis.h b/base/FairWriteoutBufferAbsBasis.h
deleted file mode 100644
index c1bc7f7..0000000
--- a/base/FairWriteoutBufferAbsBasis.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * FairWriteoutBufferAbsBasis.h
- *
- *  Created on: Jul 18, 2011
- *      Author: stockman
- */
-
-#ifndef FAIRWRITEOUTBUFFERABSBASIS_H_
-#define FAIRWRITEOUTBUFFERABSBASIS_H_
-
-#include "TObject.h"
-
-class FairWriteoutBufferAbsBasis : public TObject
-{
-  public:
-    virtual ~FairWriteoutBufferAbsBasis() {};
-
-    virtual void WriteOutData(double time) = 0;
-    virtual void WriteOutAllData() = 0;
-
-    ClassDef(FairWriteoutBufferAbsBasis,1)
-};
-
-
-#endif /* FAIRWRITEOUTBUFFERABSBASIS_H_ */
diff --git a/base/README.md b/base/README.md
new file mode 100644
index 0000000..6948486
--- /dev/null
+++ b/base/README.md
@@ -0,0 +1,12 @@
+base
+======
+
+The collection of base classes for the FairRoot.
+They are groupped in the following few directories:
+
+- MQ - message queue abstract classes
+- event - data storage classes
+- field - magnetic field classes
+- sim - Monte Carlo simulation classes
+- source - input classes
+- steer - steering classes
\ No newline at end of file
diff --git a/base/event/FairEventBuilder.cxx b/base/event/FairEventBuilder.cxx
new file mode 100644
index 0000000..7495174
--- /dev/null
+++ b/base/event/FairEventBuilder.cxx
@@ -0,0 +1,134 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/* $Id: */
+
+// -------------------------------------------------------------------------
+// -----                    FairEventBuilder source file                -----
+// -----                  Created 23/09/2013 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+/** FairEventBuilder
+ *@author Radoslaw Karabowicz <r.karabowicz@gsi.de>
+ *@since 23.09.2013
+ *@version 1.0
+ **
+ ** FairRoot base task for the event buffers.
+ ** The tasks may:
+ ** 1. analyze data to reconstruct event times or other characteristics
+ **    in the function TClonesArray* FindEvents(), that returns
+ **    TClonesArray of FairRecoEvents
+ ** 2. identify the data that could belong to event in the
+ **    function and insert this identified data to the output TClonesArrays
+ **    in the function StoreEventData(event)
+ ** The implementations may be using any or both of the above functions.
+ **/
+
+#include "FairEventBuilder.h"
+
+#include "FairRootManager.h"
+#include "FairRunAna.h"
+#include "FairRuntimeDb.h"
+
+#include "TClonesArray.h"
+
+#include <iomanip>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::flush;
+using std::fixed;
+using std::right;
+using std::left;
+using std::setw;
+using std::setprecision;
+using std::set;
+using std::map;
+
+// -----   Default constructor   ------------------------------------------
+FairEventBuilder::FairEventBuilder()
+  : FairWriteoutBuffer(),
+    fBuilderName                (""),
+    fTimer                      (),
+    fExecTime                   (0.),
+    fIdentifier                 (0),
+    fMaxAllowedEventCreationTime(0.)
+{
+}
+// -------------------------------------------------------------------------
+
+
+// -----   Constructor with name   -----------------------------------------
+FairEventBuilder::FairEventBuilder(TString branchName, TString className, TString folderName, Bool_t persistance)
+  : FairWriteoutBuffer(branchName,className,folderName,persistance),
+    fBuilderName                (""),
+    fTimer                      (),
+    fExecTime                   (0.),
+    fIdentifier                 (0),
+    fMaxAllowedEventCreationTime(0.)
+{
+}
+// -------------------------------------------------------------------------
+
+
+
+// -----   Destructor   ----------------------------------------------------
+FairEventBuilder::~FairEventBuilder()
+{
+}
+// -------------------------------------------------------------------------
+
+void FairEventBuilder::WriteOutAllDeadTimeData()
+{
+  if ( fBranchName.Length() < 1 ) {
+    return;
+  }
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  std::vector<FairTimeStamp*> data;
+  if (fActivateBuffering) {
+    if (fVerbose > 0) {
+      std::cout << "-I- FairEventBuilder::WriteOutAllDeadTimeData" << std::endl;
+    }
+    data = GetAllData();
+    if (fTreeSave && data.size() > 0) {
+      TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
+      if (!myArray) {
+        std::cout << "-E- FairEventBuilder::WriteOutData " << fBranchName << " array is not available!" << std::endl;
+      }
+      if (fVerbose > 0) {
+        std::cout << "-I- FairEventBuilder::WriteOutData size: " << data.size() << std::endl;
+      }
+      for (unsigned int i = 0; i < data.size(); i++) {
+        AddNewDataToTClonesArray(data[i]);
+        if (fVerbose > 1) {
+          std::cout << i << " : ";
+          data[i]->Print();
+          std::cout << std::endl;
+        }
+        delete data[i];
+      }
+    }
+  } else {
+    ioman->GetTClonesArray(fBranchName);
+  }
+}
+//_____________________________________________________________________________
+
+// -----   Public method Finish   ------------------------------------------
+void FairEventBuilder::Finish()
+{
+
+  cout << "-------------------- " << GetBuilderName() << " : Summary -----------------------" << endl;
+  cout << " Should be implemented by the user" << endl;
+  cout << "---------------------------------------------------------------------" << endl;
+}
+// -------------------------------------------------------------------------
+
+ClassImp(FairEventBuilder)
+
diff --git a/base/event/FairEventBuilder.h b/base/event/FairEventBuilder.h
new file mode 100644
index 0000000..585b652
--- /dev/null
+++ b/base/event/FairEventBuilder.h
@@ -0,0 +1,113 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//* $Id: */
+
+// -------------------------------------------------------------------------
+// -----                     FairEventBuilder header file                -----
+// -----                  Created 23/09/2013 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+
+/** FairEventBuilder
+ *@author Radoslaw Karabowicz <r.karabowicz@gsi.de>
+ *@since 23/09/2013
+ *@version 1.0
+ **
+ ** FairRoot base task for the event buffers.
+ ** The tasks may:
+ ** 1. analyze data to reconstruct event times or other characteristics
+ **    in the function TClonesArray* FindEvents(), that returns
+ **    TClonesArray of FairRecoEvents
+ ** 2. identify the data that could belong to event in the
+ **    function and insert this identified data to the output TClonesArrays
+ **    in the function StoreEventData(event)
+ ** The implementations may be using any or both of the above functions.
+ **/
+
+
+#ifndef FAIREVENTBUILDER_H
+#define FAIREVENTBUILDER_H 1
+
+#include "FairWriteoutBuffer.h"
+#include "FairRecoEventHeader.h"
+
+#include "TStopwatch.h"
+#include "TString.h"
+
+#include <map>
+#include <set>
+#include <vector>
+
+class TClonesArray;
+//class FairRecoEventHeader;
+
+class FairEventBuilder : public FairWriteoutBuffer
+{
+
+
+  public :
+
+    /** Default constructor **/
+    FairEventBuilder();
+
+
+    /** Constructor with task name **/
+    FairEventBuilder(TString branchName, TString className, TString folderName, Bool_t persistance);
+
+
+    /** Destructor **/
+    virtual ~FairEventBuilder();
+
+    virtual void WriteOutAllDeadTimeData();
+
+    virtual std::vector<std::pair<double, FairRecoEventHeader*> > FindEvents() = 0;
+    virtual void          StoreEventData(FairRecoEventHeader* /*recoEvent*/) = 0;
+
+    void  SetIdentifier(Int_t ident) {
+      fIdentifier=ident;
+    }
+    Int_t GetIdentifier() {
+      return fIdentifier;
+    }
+
+    virtual Bool_t Init() = 0;
+
+    virtual void Print(Option_t *option="") const = 0;
+
+    /** Finish at the end of each event **/
+    virtual void Finish();
+
+    Double_t AllowedTime() {
+      return fMaxAllowedEventCreationTime;
+    };
+    void SetMaxAllowedTime(Double_t td) {
+      fMaxAllowedEventCreationTime = td;
+    };
+
+    void    SetBuilderName(const char* name) {
+      fBuilderName=name;
+    }
+    TString GetBuilderName() {
+      return fBuilderName;
+    }
+
+  private:
+
+    TString    fBuilderName;
+
+    TStopwatch fTimer;
+    Double_t   fExecTime;
+
+    Int_t      fIdentifier;
+    Double_t   fMaxAllowedEventCreationTime;
+
+    ClassDef(FairEventBuilder,1);
+
+};
+
+#endif
diff --git a/base/event/FairEventBuilderManager.cxx b/base/event/FairEventBuilderManager.cxx
new file mode 100644
index 0000000..1f8d327
--- /dev/null
+++ b/base/event/FairEventBuilderManager.cxx
@@ -0,0 +1,231 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/* $Id: */
+
+// -------------------------------------------------------------------------
+// -----                    FairEventBuilderManager source file               -----
+// -----                  Created 23/09/2013 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+/** FairEventBuilderManager
+ *@author Radoslaw Karabowicz <r.karabowicz@gsi.de>
+ *@since 23.09.2013
+ *@version 1.0
+ **
+ ** FairRoot general task for recreating events in Time-Based reconstruction mode.
+ ** Various experiments should implement their own version of the Event Builder Manager.
+ ** The main member of the task is vector of reconstructed events fRecoEvents.
+ ** It also contains a vector of implementations of FairEventBuilders, that are
+ ** responsible for feeding fRecoEvents vector via FindEvents() function.
+ **
+ ** The heart of the experiment-specific implemenations is
+ ** the AnalyzeAndExtractEvents() function, which should interpret
+ ** the experimental data to reconstruct events.
+ **/
+
+#include "FairEventBuilderManager.h"
+
+#include "FairRecoEventHeader.h"
+#include "FairRootManager.h"
+#include "FairRunAna.h"
+#include "FairRuntimeDb.h"
+
+#include "TClonesArray.h"
+#include "TMath.h"
+#include "TRandom2.h"
+
+#include <iomanip>
+
+using std::cout;
+using std::cerr;
+using std::endl;
+using std::flush;
+using std::fixed;
+using std::right;
+using std::left;
+using std::setw;
+using std::setprecision;
+using std::set;
+using std::map;
+
+using std::sort;
+using std::iterator;
+using std::vector;
+
+// -----   Default constructor   ------------------------------------------
+FairEventBuilderManager::FairEventBuilderManager()
+  : FairTask("FairEventBuilderManager", 0),
+    fEventBuilders  (),
+    fPossibleEvents()
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Constructor with name   -----------------------------------------
+FairEventBuilderManager::FairEventBuilderManager(const char* name, Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fEventBuilders  (),
+    fPossibleEvents()
+{
+}
+// -------------------------------------------------------------------------
+
+
+
+// -----   Destructor   ----------------------------------------------------
+FairEventBuilderManager::~FairEventBuilderManager()
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method Exec   --------------------------------------------
+void FairEventBuilderManager::Exec(Option_t*)
+{
+  if ( fVerbose ) {
+    cout << "FairEventBuilderManager::Exec() begin" << endl;
+  }
+
+  Double_t maxEventTimeAllowed = FillEventVectors();
+
+  if ( fVerbose ) {
+    cout << "++ CAN CREATE EVENTS THAT ARE SMALLER THAN " << maxEventTimeAllowed << " ns" << endl;
+  }
+
+  // AnalyzeAndExtractEvents function:
+  // - works on fEventBuilders[ieb]
+  // - should extract possible events
+  // - is implemented by different experiments
+  AnalyzeAndExtractEvents(maxEventTimeAllowed);
+
+  return;
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method FillEventVectors   -------------------------------
+Double_t FairEventBuilderManager::FillEventVectors()
+{
+  // for ( std::vector<FairEventBuilder*>::iterator it = fEventBuilders.begin() ; it != fEventBuilders.end() ; ++it ) {
+  //   *it.FindEvents();
+  // }
+  Double_t maxEventTimeAllowed = 10.e6;
+  for ( UInt_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
+    if ( fVerbose ) { cout << "***** " << fEventBuilders[ieb]->GetName() << " *****" << endl; }
+    if ( fVerbose ) { cout << "  there are " << fPossibleEvents[ieb].size() << " possible events" << endl; }
+    std::vector<std::pair<double,FairRecoEventHeader*> > tempBuilder = fEventBuilders[ieb]->FindEvents();
+    if ( fVerbose ) {
+      cout << "  event buffer " << fEventBuilders[ieb]->GetName() << " found " << tempBuilder.size() << " events" << endl;
+    }
+    std::pair<double,FairRecoEventHeader*> tempPair;
+    for ( UInt_t ipair = 0 ; ipair < tempBuilder.size() ; ipair++ ) {
+      fPossibleEvents[ieb].push_back(tempBuilder[ipair]);
+      if ( fVerbose )
+        cout << "    added event " << fPossibleEvents[ieb][fPossibleEvents[ieb].size()-1].second
+             << " at " << fPossibleEvents[ieb][fPossibleEvents[ieb].size()-1].second->GetEventTime() << " ns." << endl;
+    }
+    if ( fVerbose ) {
+      cout << "  and now " << fPossibleEvents[ieb].size() << " possible events" << endl;
+    }
+
+    if ( fEventBuilders[ieb]->AllowedTime() < maxEventTimeAllowed ) {
+      maxEventTimeAllowed = fEventBuilders[ieb]->AllowedTime();
+    }
+  }
+  return maxEventTimeAllowed;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method CreateAndFillEvents   -----------------------------
+void FairEventBuilderManager::CreateAndFillEvent(FairRecoEventHeader* recoEvent)
+{
+
+  for ( UInt_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
+    fEventBuilders[ieb]->StoreEventData(recoEvent);
+    fEventBuilders[ieb]->WriteOutAllDeadTimeData();
+  }
+
+  FairRootManager::Instance()->Fill();
+
+  for ( UInt_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
+    fEventBuilders[ieb]->DeleteOldData();
+  }
+}
+// -------------------------------------------------------------------------
+
+
+// -----   Public method AddEventBuilder   ----------------------------------
+void FairEventBuilderManager::AddEventBuilder(FairEventBuilder* eventBuilder)
+{
+  fEventBuilders  .push_back(eventBuilder);
+  std::vector<std::pair<double,FairRecoEventHeader*> > tcArray;
+  fPossibleEvents.push_back(tcArray);
+  //  if ( fVerbose )
+  cout << "*** FairEventBuilderManager. Registered " << eventBuilder->GetName() << endl;
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method SetParContainers   -------------------------------
+void FairEventBuilderManager::SetParContainers()
+{
+
+  // Get run and runtime database
+  FairRunAna* run = FairRunAna::Instance();
+  if ( ! run ) { 
+    Fatal("SetParContainers", "No analysis run"); 
+  } else {
+    FairRuntimeDb* db = run->GetRuntimeDb();
+    if ( ! db ) { Fatal("SetParContainers", "No runtime database"); }
+  }
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method Init   -------------------------------------------
+InitStatus FairEventBuilderManager::Init()
+{
+  // Get input array
+  FairRootManager* ioman = FairRootManager::Instance();
+  if ( ! ioman ) { Fatal("Init", "No FairRootManager"); }
+
+  cout << "*** FairEventBuilderManager. " << fEventBuilders.size() << " event builders registered." << endl;
+
+  for ( UInt_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
+    fEventBuilders[ieb]->SetIdentifier(TMath::Power(2,static_cast<Int_t>(ieb)));
+    fEventBuilders[ieb]->Init();
+  }
+
+  return kSUCCESS;
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method ReInit   -------------------------------------------
+InitStatus FairEventBuilderManager::ReInit()
+{
+
+  return kSUCCESS;
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method ReInit   -------------------------------------------
+void FairEventBuilderManager::Finish()
+{
+  AnalyzeAndExtractEvents(-1.);
+
+  cout << "==================== " << fName.Data() << " : Summary ========================" << endl;
+  for ( UInt_t ieb = 0 ; ieb < fEventBuilders.size() ; ieb++ ) {
+    fEventBuilders[ieb]->Finish();
+  }
+  cout << "=====================================================================" << endl;
+}
+// -------------------------------------------------------------------------
+
+
+
+
+
+
+ClassImp(FairEventBuilderManager)
+
diff --git a/base/event/FairEventBuilderManager.h b/base/event/FairEventBuilderManager.h
new file mode 100644
index 0000000..b16ebd5
--- /dev/null
+++ b/base/event/FairEventBuilderManager.h
@@ -0,0 +1,111 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//* $Id: */
+
+// -------------------------------------------------------------------------
+// -----                     FairEventBuilderManager header file              -----
+// -----                  Created 20/09/2013 by R. Karabowicz          -----
+// -------------------------------------------------------------------------
+
+
+/** FairEventBuilderManager
+ *@author Radoslaw Karabowicz <r.karabowicz@gsi.de>
+ *@since 20/09/2013
+ *@version 1.0
+ **
+ ** FairRoot general task for recreating events in Time-Based reconstruction mode.
+ ** Various experiments should implement their own version of Event Builder.
+ ** The main member of the task is vector of reconstructed events fRecoEvents.
+ ** It also contains a vector of implementations of FairEventBuilders, that are
+ ** responsible for feeding fRecoEvents vector via FindEvents() function.
+ **
+ ** The heart of the experiment-specific implemenations is
+ ** the AnalyzeAndExtractEvents() function, which should interpret
+ ** the experimental data to reconstruct events.
+ **/
+
+
+#ifndef FAIREVENTBUILDERMANAGER_H
+#define FAIREVENTBUILDERMANAGER_H 1
+
+#include "FairTask.h"
+#include "FairEventBuilder.h"
+
+#include "TStopwatch.h"
+
+#include <map>
+#include <set>
+#include <vector>
+
+class TClonesArray;
+
+class FairEventBuilderManager : public FairTask
+{
+
+
+  public :
+
+    /** Default constructor **/
+    FairEventBuilderManager();
+
+
+    /** Constructor with task name **/
+    FairEventBuilderManager(const char* name, Int_t iVerbose=1);
+
+
+    /** Destructor **/
+    virtual ~FairEventBuilderManager();
+
+
+    /** Execution **/
+    virtual void Exec(Option_t* opt);
+
+
+    /** Adding FairEventBuilder **/
+    virtual void AddEventBuilder(FairEventBuilder* eventBuilder);
+
+  protected:
+
+    std::vector<FairEventBuilder*> fEventBuilders;
+    std::vector<std::vector<std::pair<double,FairRecoEventHeader*> > >  fPossibleEvents;
+
+
+    /** Fill events from various builders **/
+    virtual Double_t FillEventVectors();
+
+
+    /** Analyze and extract events - experiment specific **/
+    virtual void AnalyzeAndExtractEvents(Double_t maxEventTimeAllowed) = 0;
+
+
+    /** Create output tree structure **/
+    virtual void CreateAndFillEvent(FairRecoEventHeader* recoEvent);
+
+  private:
+
+    /** Get parameter containers **/
+    virtual void SetParContainers();
+
+
+    /** Intialisation **/
+    virtual InitStatus Init();
+
+
+    /** Reinitialisation **/
+    virtual InitStatus ReInit();
+
+
+    /** Finish at the end of each event **/
+    virtual void Finish();
+
+
+    ClassDef(FairEventBuilderManager,1);
+
+};
+
+#endif
diff --git a/base/FairEventHeader.cxx b/base/event/FairEventHeader.cxx
similarity index 60%
rename from base/FairEventHeader.cxx
rename to base/event/FairEventHeader.cxx
index 84f583f..1b7789b 100644
--- a/base/FairEventHeader.cxx
+++ b/base/event/FairEventHeader.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                         FairEventHeader source file           -----
 // -----            Created 08/09/04                 D. Bertini        -----
diff --git a/base/FairEventHeader.h b/base/event/FairEventHeader.h
similarity index 72%
rename from base/FairEventHeader.h
rename to base/event/FairEventHeader.h
index ceb96ca..295641e 100644
--- a/base/FairEventHeader.h
+++ b/base/event/FairEventHeader.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairEventHeader header file                      -----
 // -----          Created 08/09/04                 D.Bertini           -----
@@ -6,8 +13,9 @@
 #ifndef FAIREVENTHEADER_H
 #define FAIREVENTHEADER_H
 
+#include "TNamed.h"                     // for TNamed
 
-#include "TNamed.h"
+#include "Rtypes.h"                     // for Int_t, Double_t, UInt_t, etc
 
 /**
  *  Event Header Class
diff --git a/base/FairFileHeader.cxx b/base/event/FairFileHeader.cxx
similarity index 59%
rename from base/FairFileHeader.cxx
rename to base/event/FairFileHeader.cxx
index 16e00ec..d3e4ba0 100644
--- a/base/FairFileHeader.cxx
+++ b/base/event/FairFileHeader.cxx
@@ -1,13 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                         FairFileHeader source file           -----
 // -----            Created 20/04/11                 M.Al-Turany        -----
 // -------------------------------------------------------------------------
 
-
 #include "FairFileHeader.h"
-#include "FairRootManager.h"
-#include "FairFileInfo.h"
 
+#include "FairFileInfo.h"               // for FairFileInfo
+
+#include "TIterator.h"                  // for TIterator
+#include "TList.h"                      // for TList
+#include "TObjString.h"                 // for TObjString
+#include "TObject.h"                    // for TObject
+class TFile;
 
 // -----   Default constructor   -------------------------------------------
 FairFileHeader::FairFileHeader()
@@ -37,8 +48,11 @@ FairFileInfo* FairFileHeader::GetFileInfo(UInt_t id, UInt_t ChId)
   FairFileInfo* info=0;
   while((obj=Iter->Next())) {
     info=dynamic_cast <FairFileInfo*> (obj);
-    if(info->GetIdentifier() == id && info->GetOrderInChain()==ChId) {return info;}
+    if(info && info->GetIdentifier() == id && info->GetOrderInChain()==ChId) {
+      return info;
+    }
   }
+  delete Iter;
   return 0;
 
 }
diff --git a/base/FairFileHeader.h b/base/event/FairFileHeader.h
similarity index 66%
rename from base/FairFileHeader.h
rename to base/event/FairFileHeader.h
index a5a6494..c3cb51f 100644
--- a/base/FairFileHeader.h
+++ b/base/event/FairFileHeader.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                         FairFileHeader source file           -----
 // -----            Created 20/04/11                 M.Al-Turany        -----
@@ -6,14 +13,14 @@
 #ifndef FAIRFILEHEADER_H
 #define FAIRFILEHEADER_H
 
+#include "TNamed.h"                     // for TNamed
 
-#include "TNamed.h"
-#include "TList.h"
-#include "TObjString.h"
-#include "TFile.h"
-
+#include "Rtypes.h"                     // for UInt_t, etc
+#include "TString.h"                    // for TString
 
 class FairFileInfo;
+class TFile;
+class TList;
 
 /**
  *  File Header Class
diff --git a/base/FairFileInfo.cxx b/base/event/FairFileInfo.cxx
similarity index 60%
rename from base/FairFileInfo.cxx
rename to base/event/FairFileInfo.cxx
index 562dcf9..d21af30 100644
--- a/base/FairFileInfo.cxx
+++ b/base/event/FairFileInfo.cxx
@@ -1,9 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //  FairFileInfo.cxx
 //  Created by Mohammad Al-Turany on 6/21/11.
 //
-
 #include "FairFileInfo.h"
-#include "TSystem.h"
+
+#include "TFile.h"                      // for TFile
+#include "TSystem.h"                    // for TSystem, gSystem
+
+#include <stdio.h>                      // for printf
 
 //__________________________________________________________________________
 FairFileInfo::FairFileInfo()
@@ -32,7 +42,7 @@ FairFileInfo::~FairFileInfo()
 
 }
 //__________________________________________________________________________
-void FairFileInfo::Print(Option_t* option) const
+void FairFileInfo::Print(Option_t*) const
 {
   printf("Printing FairFileInfo for    :  %s \n", fName.Data());
   printf("File full path               :  %s \n", fPath.Data());
diff --git a/base/FairFileInfo.h b/base/event/FairFileInfo.h
similarity index 59%
rename from base/FairFileInfo.h
rename to base/event/FairFileInfo.h
index 546d5b7..78d30be 100644
--- a/base/FairFileInfo.h
+++ b/base/event/FairFileInfo.h
@@ -1,13 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //  FairFileInfo.h
 //  Created by Mohammad Al-Turany on 6/21/11.
 //
 #ifndef FAIRFILEINFO_H
 #define FAIRFILEINFO_H
 
-#include "TNamed.h"
-#include "TString.h"
-#include "TFile.h"
+#include "TNamed.h"                     // for TNamed
 
+#include "Rtypes.h"                     // for UInt_t, FairFileInfo::Class, etc
+#include "TString.h"                    // for TString
+
+class TFile;
 
 class FairFileInfo : public TNamed
 {
diff --git a/base/FairHit.cxx b/base/event/FairHit.cxx
similarity index 63%
rename from base/FairHit.cxx
rename to base/event/FairHit.cxx
index 11802cc..57394c6 100644
--- a/base/FairHit.cxx
+++ b/base/event/FairHit.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairHit.h"
 
 
@@ -33,9 +40,10 @@ FairHit::FairHit(Int_t detID, TVector3& pos, TVector3& dpos, Int_t index)
    fZ           (pos.Z())
 {
 }
-// -------------------------------------------------------------------------
 
 
+// -------------------------------------------------------------------------
+
 
 // -----   Destructor   ----------------------------------------------------
 FairHit::~FairHit() { }
diff --git a/base/FairHit.h b/base/event/FairHit.h
similarity index 63%
rename from base/FairHit.h
rename to base/event/FairHit.h
index 818fcd6..4a6b8ca 100644
--- a/base/FairHit.h
+++ b/base/event/FairHit.h
@@ -1,8 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRHIT_H
 #define FAIRHIT_H
 
-#include "FairTimeStamp.h"
-#include "TVector3.h"
+#include "FairTimeStamp.h"              // for FairTimeStamp
+
+#include "Rtypes.h"                     // for Double_t, Int_t, Double32_t, etc
+#include "TVector3.h"                   // for TVector3
+
+#ifndef __CINT__
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/base_object.hpp>
+#endif //__CINT__
 
 /**
  * Abstract base class for reconstructed hits in the FAIR detectors.
@@ -22,7 +36,6 @@ class FairHit : public FairTimeStamp
     /** Constructor with hit parameters **/
     FairHit(Int_t detID, TVector3& pos, TVector3& dpos, Int_t index);
 
-
     /** Destructor **/
     virtual ~FairHit();
 
@@ -33,7 +46,7 @@ class FairHit : public FairTimeStamp
     Double_t GetDz()            const { return fDz;                     };
     Int_t    GetRefIndex()      const { return fRefIndex;               };
     void PositionError(TVector3& dpos) const;
-    Int_t    GetDetectorID()   const { return fDetectorID;             };
+    Int_t    GetDetectorID()    const { return fDetectorID;             };
     Double_t GetX()             const { return fX;                      };
     Double_t GetY()             const { return fY;                      };
     Double_t GetZ()             const { return fZ;                      };
@@ -57,21 +70,35 @@ class FairHit : public FairTimeStamp
 
 
     /*** Output to screen */
-    virtual void Print(const Option_t* opt ="") const {;}
-
-
+    //KG
+    //virtual void Print(const Option_t*) const {;}
+    virtual void Print(const Option_t* = "") const {;}
+
+    template<class Archive>
+    void serialize(Archive& ar, const unsigned int)
+    {
+        ar& boost::serialization::base_object<FairTimeStamp>(*this);
+        ar& fDetectorID;
+        ar& fRefIndex;
+        ar& fX;
+        ar& fY;
+        ar& fZ;
+        ar& fDx;
+        ar& fDy;
+        ar& fDz;
+    }
 
   protected:
+#ifndef __CINT__ // for BOOST serialization
+    friend class boost::serialization::access;
+#endif // for BOOST serialization
 
     Double32_t fDx, fDy, fDz;   ///< Errors of position [cm]
     Int_t      fRefIndex;       ///< Index of FairMCPoint for this hit
     Int_t      fDetectorID;     ///< Detector unique identifier
     Double32_t fX, fY, fZ;      ///< Position of hit [cm]
 
-
-    ClassDef(FairHit,2);
-
-
+    ClassDef(FairHit,3);
 };
 
 
diff --git a/base/FairLink.cxx b/base/event/FairLink.cxx
similarity index 66%
rename from base/FairLink.cxx
rename to base/event/FairLink.cxx
index 944212b..7633d53 100644
--- a/base/FairLink.cxx
+++ b/base/event/FairLink.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * FairLink.cpp
  *
@@ -62,7 +69,7 @@ FairLink::FairLink(Int_t file, Int_t entry, TString branchName, Int_t index, Flo
 {
 }
 
-void FairLink::Print(std::ostream& out) const
+void FairLink::PrintLinkInfo(std::ostream& out) const
 {
   out << "(" << GetFile() << "/" << GetEntry() << "/";
   out << GetType() << "/" << GetIndex() << "/" << GetWeight() << ")";
diff --git a/base/event/FairLink.h b/base/event/FairLink.h
new file mode 100644
index 0000000..e98416c
--- /dev/null
+++ b/base/event/FairLink.h
@@ -0,0 +1,114 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairLink.h
+ *
+ *  Created on: Dec 23, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRLINK_H_
+#define FAIRLINK_H_
+
+#include "TObject.h"                    // for TObject
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, Float_t, etc
+#include "TString.h"                    // for TString
+
+#include <iostream>                     // for ostream, cout
+
+class FairLink : public TObject
+{
+  public:
+    FairLink();
+    FairLink(Int_t type, Int_t index, Float_t weight = 1.);
+    FairLink(TString branchName, Int_t index, Float_t weight = 1.);
+    FairLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.);
+    FairLink(Int_t file, Int_t entry, TString branchName, Int_t index, Float_t weight = 1.);
+    virtual ~FairLink();
+
+    void SetLink(Int_t file, Int_t entry, Int_t type, Int_t index, Float_t weight = 1.) {
+      fFile = file;
+      fEntry = entry;
+      fType = type;
+      fIndex = index;
+      fWeight = weight;
+    };
+    void SetLink(Int_t type, Int_t index, Float_t weight = 1.) {
+      fFile = -1;
+      fEntry = -1;
+      fType = type;
+      fIndex = index;
+      fWeight = weight;
+    };
+    Int_t GetFile() const {return fFile;}
+    Int_t GetEntry() const {return fEntry;}
+    Int_t GetType() const {return fType;}
+    Int_t GetIndex() const {return fIndex;}
+    Float_t GetWeight() const {return fWeight;}
+
+    void SetWeight(Float_t weight) {fWeight = weight;}
+    void AddWeight(Float_t weight) {fWeight += weight;}
+
+    virtual void PrintLinkInfo(std::ostream& out = std::cout) const;
+
+    virtual bool operator==(const FairLink& link) const {
+      if ((fFile == link.GetFile() || link.GetFile() == -1) && (fEntry == link.GetEntry() || link.GetEntry() == -1) && fType == link.GetType() && fIndex == link.GetIndex()) {
+        return true;
+      } else {
+        return false;
+      }
+    }
+
+    virtual bool operator<(const FairLink& link) const {
+	if (fFile != -1 && link.GetFile() != -1){
+		if (fFile < link.GetFile()) 		return true;
+		else if (link.GetFile() < fFile) 	return false;
+	}
+	if (fEntry != -1 && link.GetEntry() != -1){
+		if(fEntry < link.GetEntry())		return true;
+		else if (link.GetEntry() < fEntry)	return false;
+	}
+	if (fType < link.GetType())				return true;
+	else if (link.GetType() < fType)		return false;
+	if (fIndex < link.GetIndex())			return true;
+	else if (link.GetIndex() < fIndex)		return false;
+
+	return false;
+//      if (fFile != -1 && fFile < link.GetFile()) {
+//        return true;
+//      } else if ((fFile == link.GetFile() || link.GetFile() == -1) && fEntry < link.GetEntry()) {
+//        return true;
+//      } else if ((fFile == link.GetFile() || link.GetFile() == -1)  && (fEntry == link.GetEntry() || link.GetEntry() == -1) && fType < link.GetType()) {
+//        return true;
+//      } else if ((fFile == link.GetFile() || link.GetFile() == -1)  && (fEntry == link.GetEntry() || link.GetEntry() == -1) && fType == link.GetType() && fIndex < link.GetIndex()) {
+//        return true;
+//      } else {
+//        return false;
+//      }
+    }
+
+    friend std::ostream& operator<< (std::ostream& out, const FairLink& link) {
+      link.PrintLinkInfo(out);
+      return out;
+    }
+
+    ClassDef(FairLink, 3);
+
+
+  private:
+    Int_t fFile;
+    Int_t fEntry;
+    Int_t fType;
+    Int_t fIndex;
+    Float_t fWeight;
+
+};
+
+#endif /* FAIRLINK_H_ */
diff --git a/base/FairMCEventHeader.cxx b/base/event/FairMCEventHeader.cxx
similarity index 97%
rename from base/FairMCEventHeader.cxx
rename to base/event/FairMCEventHeader.cxx
index aaa5899..c5ea906 100644
--- a/base/FairMCEventHeader.cxx
+++ b/base/event/FairMCEventHeader.cxx
@@ -1,4 +1,4 @@
- /********************************************************************************
+/********************************************************************************
  *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
  *                                                                              *
  *              This software is distributed under the terms of the             * 
@@ -110,4 +110,3 @@ void FairMCEventHeader::Register()
 }
 
 ClassImp(FairMCEventHeader)
-
diff --git a/base/event/FairMCEventHeader.h b/base/event/FairMCEventHeader.h
new file mode 100644
index 0000000..6d61f12
--- /dev/null
+++ b/base/event/FairMCEventHeader.h
@@ -0,0 +1,127 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/** FairMCEventHeader.h
+ *@author V.Friese <v.friese@gsi.de>
+ ** Data class (level MC) containing information about the input event.
+ ** 15.05.2008 change the event time to ns (M. Al-Turany)
+ **/
+
+
+#ifndef FAIRMCEVENTHEADER_H
+#define FAIRMCEVENTHEADER_H 1
+
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Double_t, UInt_t, etc
+#include "TVector3.h"                   // for TVector3
+
+class FairMCEventHeader : public TNamed
+{
+
+  public:
+
+    /** Default constructor **/
+    FairMCEventHeader();
+
+
+    /** Constructor with all members
+     **
+     *@param iEvent   event identifier
+     *@param x,y,z    vertex oordinates [cm]
+     *@param t        event time [ns]
+     *@param b        impact parameter [fm] (if relevant)
+     *@param nPrim    number of input tracks
+     **/
+    FairMCEventHeader(Int_t iEvent, Double_t x, Double_t y, Double_t z,
+                      Double_t t, Double_t b, Int_t nPrim);
+
+
+    /** Standard constructor with run identifier **/
+    FairMCEventHeader(UInt_t runId);
+
+
+    /** Destructor **/
+    virtual ~FairMCEventHeader();
+
+
+    /** Accessors **/
+    UInt_t GetRunID()   const { return fRunId; }     /// run identifier
+    UInt_t GetEventID() const { return fEventId; }   /// event identifier
+    Double_t GetX()     const { return fX; }         /// vertex x [cm]
+    Double_t GetY()     const { return fY; }         /// vertex y [cm]
+    Double_t GetZ()     const { return fZ; }         /// vertex z [cm]
+    Double_t GetT()     const { return fT; }         /// event time [ns]
+    Double_t GetB()     const { return fB; }         /// impact parameter [fm]
+    Int_t GetNPrim()    const { return fNPrim; }     /// number of input tracks
+    Bool_t IsSet()      const { return fIsSet; }     /// Flag
+    Double_t GetRotX()     const { return fRotX; } /// rot. around x-axis [rad]
+    Double_t GetRotY()     const { return fRotY; } /// rot. around y-axis [rad]
+    Double_t GetRotZ()     const { return fRotZ; } /// rot. around z-axis [rad]
+
+    void GetVertex(TVector3& vertex) { vertex.SetXYZ(fX, fY, fZ); }
+
+
+    /** Modifiers **/
+    void SetEventID(UInt_t eventId) { fEventId = eventId; }
+    void SetRunID(UInt_t runId) { fRunId = runId; }
+    void SetTime(Double_t t)       { fT = t; }
+    void SetB(Double_t b)          { fB = b; }
+    void SetNPrim(Int_t nPrim)     { fNPrim = nPrim; }
+    void MarkSet(Bool_t isSet)     { fIsSet = isSet; }
+    void SetVertex(Double_t x, Double_t y, Double_t z);
+    void SetVertex(const TVector3& vertex);
+    void SetRotX(Double_t rotx) { fRotX = rotx; }
+    void SetRotY(Double_t roty) { fRotY = roty; }
+    void SetRotZ(Double_t rotz) { fRotZ = rotz; }
+
+    /** Reset all members **/
+    void Reset();
+
+    /** Register the class as data branch to the output */
+    virtual void Register();
+
+  protected:
+
+
+    UInt_t     fRunId;       ///  Run identifier
+    UInt_t     fEventId;     ///  Event identifier
+    Double32_t fX;           ///  Primary vertex x [cm]
+    Double32_t fY;           ///  Primary vertex y [cm]
+    Double32_t fZ;           ///  Primary vertex z [cm]
+    Double32_t fT;           ///  Event time [s]
+    Double32_t fB;           ///  Impact parameter [fm] (if relevant)
+    Int_t      fNPrim;       ///  Number of input tracks
+    Bool_t     fIsSet;       ///  Flag whether variables are filled
+    Double32_t fRotX;        ///  Rotation around x-axis (beam tilt) [rad]
+    Double32_t fRotY;        ///  Rotation around y-axis (beam tilt) [rad]
+    Double32_t fRotZ;        ///  Rotation around z-axis (event plane) [rad]
+
+
+    ClassDef(FairMCEventHeader,2);
+
+};
+
+
+inline void FairMCEventHeader::SetVertex(Double_t x, Double_t y,
+    Double_t z)
+{
+  fX = x;
+  fY = y;
+  fZ = z;
+}
+
+
+inline void FairMCEventHeader::SetVertex(const TVector3& vertex)
+{
+  fX = vertex.X();
+  fY = vertex.Y();
+  fZ = vertex.Z();
+}
+
+
+#endif
diff --git a/base/FairMCPoint.cxx b/base/event/FairMCPoint.cxx
similarity index 50%
rename from base/FairMCPoint.cxx
rename to base/event/FairMCPoint.cxx
index 0a3f569..d95733d 100644
--- a/base/FairMCPoint.cxx
+++ b/base/event/FairMCPoint.cxx
@@ -1,8 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairMCPoint.h"
+#include "FairLogger.h"
 
 // -----   Default constructor   -------------------------------------------
 FairMCPoint::FairMCPoint()
-  : FairMultiLinkedData(),
+  : FairMultiLinkedData_Interface(),
     fTrackID(-1),
     fEventId(0),
     fPx(0.),
@@ -28,7 +36,7 @@ FairMCPoint::FairMCPoint()
 FairMCPoint::FairMCPoint(Int_t trackID, Int_t detID, TVector3 pos,
                          TVector3 mom, Double_t tof, Double_t length,
                          Double_t eLoss, UInt_t EventId)
-  :FairMultiLinkedData(),
+  :FairMultiLinkedData_Interface(),
    fTrackID    ( trackID),
    fEventId    (EventId),
    fPx         ( mom.Px()),
@@ -45,11 +53,20 @@ FairMCPoint::FairMCPoint(Int_t trackID, Int_t detID, TVector3 pos,
 }
 // -------------------------------------------------------------------------
 
-
-
 // -----   Destructor   ----------------------------------------------------
 FairMCPoint::~FairMCPoint() { }
 // -------------------------------------------------------------------------
+void FairMCPoint::Print(const Option_t*) const
+{
+  LOG(DEBUG) << "FairMC point for track " << fTrackID
+             << " in detector " << fDetectorID << FairLogger::endl;
+  LOG(DEBUG) << "Position (" << fX << ", " << fY << ", " << fZ
+             << ") cm" << FairLogger::endl;
+  LOG(DEBUG) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz
+             << ") GeV" << FairLogger::endl;
+  LOG(DEBUG) << "    Time " << fTime << " ns,  Length " << fLength
+             << " cm,  Energy loss " << fELoss*1.0e06 << " keV" << FairLogger::endl;
+}
 
 
 
diff --git a/base/FairMCPoint.h b/base/event/FairMCPoint.h
similarity index 64%
rename from base/FairMCPoint.h
rename to base/event/FairMCPoint.h
index ee8d34c..a08bda1 100644
--- a/base/FairMCPoint.h
+++ b/base/event/FairMCPoint.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /**  FairMCPoint.h
  * This is the base class for all MC Points generated by the transport of
  * tracks through active detectors.
@@ -8,10 +15,18 @@
 #ifndef FAIRMCPOINT_H
 #define FAIRMCPOINT_H
 
-#include "FairMultiLinkedData.h"
-#include "TVector3.h"
+#include "FairMultiLinkedData_Interface.h"        // for FairMultiLinkedData
 
-class FairMCPoint : public FairMultiLinkedData
+#include "Rtypes.h"                     // for Double_t, Double32_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
+
+
+#ifndef __CINT__
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/base_object.hpp>
+#endif //__CINT__
+
+class FairMCPoint : public FairMultiLinkedData_Interface
 {
 
   public:
@@ -32,8 +47,7 @@ class FairMCPoint : public FairMultiLinkedData
      **/
     FairMCPoint(Int_t trackID, Int_t detID, TVector3 pos, TVector3 mom,
                 Double_t tof, Double_t length, Double_t eLoss, UInt_t EventId=0);
-
-
+    
     /** Destructor **/
     virtual ~FairMCPoint();
 
@@ -47,12 +61,12 @@ class FairMCPoint : public FairMultiLinkedData
     Double_t GetTime()       const { return fTime; }
     Double_t GetLength()     const { return fLength; }
     Double_t GetEnergyLoss() const { return fELoss; }
-    void Momentum(TVector3& mom) { mom.SetXYZ(fPx, fPy, fPz); }
+    void Momentum(TVector3& mom) const { mom.SetXYZ(fPx, fPy, fPz); }
     Int_t    GetDetectorID()   const { return fDetectorID;             };
     Double_t GetX()             const { return fX;                      };
     Double_t GetY()             const { return fY;                      };
     Double_t GetZ()             const { return fZ;                      };
-    void Position(TVector3& pos)       const;
+    void Position(TVector3& pos) const { pos.SetXYZ(fX, fY, fZ); }
 
 
 
@@ -73,12 +87,35 @@ class FairMCPoint : public FairMultiLinkedData
 
 
     /** Output to screen **/
-    virtual void Print(const Option_t* opt = 0) const = 0;
-
-
+    virtual void Print(const Option_t* opt = 0) const;
+
+
+    
+    template<class Archive>
+    void serialize(Archive & ar, const unsigned int) 
+    {
+        //ar & boost::serialization::base_object<FairMultiLinkedData>(*this);
+        ar & fTrackID;
+        ar & fEventId;
+        ar & fDetectorID; 
+        ar & fX;
+        ar & fY;
+        ar & fZ;
+        ar & fPx;
+        ar & fPy;
+        ar & fPz; 
+        ar & fTime; 
+        ar & fLength; 
+        ar & fELoss; 
+    }
 
   protected:
 
+    #ifndef __CINT__ // for BOOST serialization
+    friend class boost::serialization::access;
+
+    #endif // for BOOST serialization
+    
     Int_t fTrackID;               ///< Track index
     UInt_t fEventId;              ///< MC Event id
     Double32_t fPx, fPy, fPz;     ///< Momentum components [GeV]
@@ -89,7 +126,7 @@ class FairMCPoint : public FairMultiLinkedData
     Double32_t fX, fY, fZ;        ///< Position of hit [cm]
 
 
-    ClassDef(FairMCPoint,4)
+    ClassDef(FairMCPoint,5)
 
 };
 
@@ -100,10 +137,6 @@ inline void FairMCPoint::SetMomentum(const TVector3& mom)
   fPy = mom.Py();
   fPz = mom.Pz();
 }
-inline void FairMCPoint::Position(TVector3& pos) const
-{
-  pos.SetXYZ(fX, fY, fZ);
-}
 
 
 inline void FairMCPoint::SetXYZ(Double_t x, Double_t y, Double_t z)
diff --git a/base/FairMesh.cxx b/base/event/FairMesh.cxx
similarity index 73%
rename from base/FairMesh.cxx
rename to base/event/FairMesh.cxx
index 4967cdb..2b31859 100644
--- a/base/FairMesh.cxx
+++ b/base/event/FairMesh.cxx
@@ -1,14 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                         FairMesh source file                  -----
 // -----          original author                  D.Bertini           -----
 // -----          adapted april 2010               O.Hartmann          -----
 // -------------------------------------------------------------------------
 
-
 #include "FairMesh.h"
-#include "TString.h"
-#include "TMath.h"
-#include <iostream>
+
+#include "Riosfwd.h"                    // for ostream
+#include "TMath.h"                      // for Sqrt
+#include "TString.h"                    // for TString, operator+
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using namespace std;
 
diff --git a/base/FairMesh.h b/base/event/FairMesh.h
similarity index 76%
rename from base/FairMesh.h
rename to base/event/FairMesh.h
index 17a400c..fdf8d98 100644
--- a/base/FairMesh.h
+++ b/base/event/FairMesh.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairMesh header file                    -----
 // -----          original author                  D.Bertini           -----
@@ -7,11 +14,12 @@
 #ifndef FAIRMESH_H
 #define FAIRMESH_H
 
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TH2.h"                        // for TH2D
+#include "TString.h"                    // for TString
 
-#include "TObject.h"
-#include "TVector3.h"
-#include "TH2D.h"
-#include "TString.h"
 /**
  * Abstract base class for Mesh Objects.
   **@author D.Bertini <d.bertini@gsi.de>
diff --git a/base/FairMultiLinkedData.cxx b/base/event/FairMultiLinkedData.cxx
similarity index 59%
rename from base/FairMultiLinkedData.cxx
rename to base/event/FairMultiLinkedData.cxx
index d3c688e..0c1872e 100644
--- a/base/FairMultiLinkedData.cxx
+++ b/base/event/FairMultiLinkedData.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * FairMultiLinkedData.cxx
  *
@@ -6,16 +13,24 @@
  */
 
 #include "FairMultiLinkedData.h"
-#include "TClonesArray.h"
+#include "FairMultiLinkedData_Interface.h"
 
-#include<algorithm>
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairLinkManager.h"            // for FairLinkManager
+
+#include "TClonesArray.h"               // for TClonesArray
+
+#include <algorithm>                    // for find
+#include <iterator>                     // for distance
 
 ClassImp(FairMultiLinkedData);
 
 FairMultiLinkedData::FairMultiLinkedData()
   :TObject(),
    fLinks(),
+   fEntryNr(),
    fPersistanceCheck(kTRUE),
+   fInsertHistory(kTRUE),
    fVerbose(0),
    fDefaultType(0)
 
@@ -25,7 +40,9 @@ FairMultiLinkedData::FairMultiLinkedData()
 FairMultiLinkedData::FairMultiLinkedData(std::set<FairLink> links, Bool_t persistanceCheck)
   :TObject(),
    fLinks(links),
+   fEntryNr(),
    fPersistanceCheck(persistanceCheck),
+   fInsertHistory(kTRUE),
    fVerbose(0),
    fDefaultType(0)
 {
@@ -34,7 +51,9 @@ FairMultiLinkedData::FairMultiLinkedData(std::set<FairLink> links, Bool_t persis
 FairMultiLinkedData::FairMultiLinkedData(TString dataType, std::vector<Int_t> links, Int_t fileId, Int_t evtId, Bool_t persistanceCheck, Bool_t bypass, Float_t mult)
   :TObject(),
    fLinks(),
+   fEntryNr(),
    fPersistanceCheck(persistanceCheck),
+   fInsertHistory(kTRUE),
    fVerbose(0),
    fDefaultType(0)
 
@@ -46,7 +65,9 @@ FairMultiLinkedData::FairMultiLinkedData(TString dataType, std::vector<Int_t> li
 FairMultiLinkedData::FairMultiLinkedData(Int_t dataType, std::vector<Int_t> links, Int_t fileId, Int_t evtId, Bool_t persistanceCheck, Bool_t bypass, Float_t mult)
   :TObject(),
    fLinks(),
+   fEntryNr(),
    fPersistanceCheck(persistanceCheck),
+   fInsertHistory(kTRUE),
    fVerbose(0),
    fDefaultType(0)
 
@@ -56,7 +77,7 @@ FairMultiLinkedData::FairMultiLinkedData(Int_t dataType, std::vector<Int_t> link
 
 FairLink FairMultiLinkedData::GetLink(Int_t pos) const
 {
-  if (pos < (Int_t)fLinks.size()) {
+  if (pos < static_cast<Int_t>(fLinks.size())) {
     std::set<FairLink>::iterator it = fLinks.begin();
     for (int i = 0; i < pos; i++) { it++; }
     return *it;
@@ -68,12 +89,12 @@ FairLink FairMultiLinkedData::GetLink(Int_t pos) const
 
 void FairMultiLinkedData::SetLinks(FairMultiLinkedData links, Float_t mult)
 {
-  fLinks = links.GetLinks();
-  MultiplyAllWeights(mult);
+  fLinks.clear();
+  AddLinks(links, mult);
 }
 
 
-inline void FairMultiLinkedData::SetLink(FairLink link, Bool_t bypass, Float_t mult)
+void FairMultiLinkedData::SetLink(FairLink link, Bool_t bypass, Float_t mult)
 {
   fLinks.clear();
   Float_t weight = link.GetWeight() * mult;
@@ -92,7 +113,7 @@ void FairMultiLinkedData::AddLinks(FairMultiLinkedData links, Float_t mult)
   }
 }
 
-inline void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t mult)
+void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t mult)
 {
 
   Float_t weight = link.GetWeight() * mult;
@@ -113,6 +134,8 @@ inline void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t m
       link.GetIndex() < 0 ||
       ioman->CheckBranch(ioman->GetBranchName(link.GetType())) == 0) {
     InsertLink(link);
+    if (fInsertHistory == kTRUE)
+    	InsertHistory(link);
     return;
   }
 
@@ -124,18 +147,18 @@ inline void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t m
       if (fVerbose > 1) {
         std::cout << "BYPASS!" << std::endl;
       }
-      bypass = kTRUE;
+//      bypass = kTRUE;
     }
   }
 
   if (bypass == kTRUE) {
     //FairRootManager* ioman = FairRootManager::Instance();
     if (link.GetType() > ioman->GetBranchId("MCTrack")) {
-      TClonesArray* array = (TClonesArray*)ioman->GetObject(ioman->GetBranchName(link.GetType()));
+      TClonesArray* array = static_cast<TClonesArray*>(ioman->GetObject(ioman->GetBranchName(link.GetType())));
       if (fVerbose > 1) {
         std::cout << "Entries in " << ioman->GetBranchName(link.GetType()) << " Array: " << array->GetEntries() << std::endl;
       }
-      FairMultiLinkedData* links = (FairMultiLinkedData*)array->At(link.GetIndex());
+      FairMultiLinkedData* links = static_cast<FairMultiLinkedData*>(array->At(link.GetIndex()));
       if (fVerbose > 1) {
         std::cout << "FairMultiLinkedData has " << links->GetNLinks() << " Entries: " << std::endl;
         std::cout << *links << std::endl;
@@ -144,15 +167,23 @@ inline void FairMultiLinkedData::AddLink(FairLink link, Bool_t bypass, Float_t m
       return;
     } else {
       InsertLink(link);
+      if (fInsertHistory == kTRUE)
+    	  InsertHistory(link);
     }
   } else {
     InsertLink(link);
+    if (fInsertHistory == kTRUE)
+    	InsertHistory(link);
   }
 
 }
 
 void FairMultiLinkedData::InsertLink(FairLink link)
 {
+  if (FairLinkManager::Instance()->IsIgnoreType(link.GetType())){
+	return;
+  }
+
   std::set<FairLink>::iterator it = fLinks.find(link);
   if (it != fLinks.end()) {
     FairLink myTempLink = *it;
@@ -165,6 +196,44 @@ void FairMultiLinkedData::InsertLink(FairLink link)
   return;
 }
 
+void FairMultiLinkedData::InsertHistory(FairLink link)
+{
+        FairRootManager* ioman = FairRootManager::Instance();
+        FairMultiLinkedData* pointerToLinks = 0;
+
+        if (fVerbose > 1)
+        	std::cout << "FairMultiLinkedData::InsertHistory for Link " << link << " Type: " << ioman->GetBranchName(link.GetType()) << std::endl;
+
+        if (link.GetType() < 0)
+                return;
+        if (link.GetType() == ioman->GetBranchId("MCTrack"))
+                return;
+        if(ioman->GetBranchName(link.GetType()).Contains("."))
+        	return;
+        if(link.GetEntry() != -1 && link.GetEntry() != ioman->GetEntryNr())
+        	return;
+
+        if (link.GetIndex() < 0) { //if index is -1 then this is not a TClonesArray so only the Object is returned
+                FairMultiLinkedData_Interface* interface = static_cast<FairMultiLinkedData_Interface*>(ioman->GetObject(ioman->GetBranchName(link.GetType())));
+                pointerToLinks = interface->GetPointerToLinks();
+        } else {
+                TClonesArray* dataArray = static_cast<TClonesArray*>( ioman->GetObject(ioman->GetBranchName(link.GetType())));
+                if (dataArray != 0 && link.GetIndex() < dataArray->GetEntriesFast()) {
+                        FairMultiLinkedData_Interface* interface = static_cast<FairMultiLinkedData_Interface*>(dataArray->At(link.GetIndex()));
+                        pointerToLinks = interface->GetPointerToLinks();
+
+                }
+        }
+        if (pointerToLinks != 0){
+                std::set<FairLink> linkSet = pointerToLinks->GetLinks();
+                for (std::set<FairLink>::const_iterator iter = linkSet.begin(); iter!= linkSet.end(); iter++){
+                	if (fVerbose > 1)
+                		std::cout << "FairMultiLinkedData::InsertHistory inserting " << *iter << std::endl;
+                    InsertLink(*iter);
+                }
+        }
+
+}
 
 Bool_t FairMultiLinkedData::IsLinkInList(Int_t type, Int_t index)
 {
@@ -183,7 +252,7 @@ Int_t FairMultiLinkedData::LinkPosInList(Int_t type, Int_t index)
   return -1;
 }
 
-void FairMultiLinkedData::DeleteLink(Int_t type, Int_t index)
+void FairMultiLinkedData::DeleteLink(Int_t /*type*/, Int_t /*index*/)
 {
   /*  Int_t pos = LinkPosInList(type, index);
     if (pos < 0) return;
@@ -204,12 +273,27 @@ FairMultiLinkedData FairMultiLinkedData::GetLinksWithType(Int_t type) const
   return result;
 }
 
+bool LargerWeight(FairLink val1, FairLink val2){
+	return val1.GetWeight() > val2.GetWeight();
+}
+
+std::vector<FairLink> FairMultiLinkedData::GetSortedMCTracks(){
+	FairMultiLinkedData mcLinks = GetLinksWithType(FairRootManager::Instance()->GetBranchId("MCTrack"));
+	std::set<FairLink> mcSet = mcLinks.GetLinks();
+	std::vector<FairLink> mcVector(mcSet.begin(), mcSet.end());
+	//std::sort(begin(mcVector), end(mcVector), [](FairLink& val1, FairLink& val2){ return val1.GetWeight() > val2.GetWeight();});
+	//KG
+	//std::sort(begin(mcVector), end(mcVector), LargerWeight);
+	std::sort(mcVector.begin(), mcVector.end(), LargerWeight);
+	return mcVector;
+}
+
 TObject* FairMultiLinkedData::GetData(FairLink& myLink)
 {
   FairRootManager* ioman = FairRootManager::Instance();
   TString branchName = ioman->GetBranchName(myLink.GetType());
   if (ioman->CheckBranch(branchName) > 0) {
-    TClonesArray* myArray = (TClonesArray*)ioman->GetObject(branchName);
+    TClonesArray* myArray = static_cast<TClonesArray*>(ioman->GetObject(branchName));
     if (myArray != 0) {
       if (myArray->GetEntries() > myLink.GetIndex()) {
         return myArray->At(myLink.GetIndex());
diff --git a/base/FairMultiLinkedData.h b/base/event/FairMultiLinkedData.h
similarity index 69%
rename from base/FairMultiLinkedData.h
rename to base/event/FairMultiLinkedData.h
index 4cb8be3..e0febba 100644
--- a/base/FairMultiLinkedData.h
+++ b/base/event/FairMultiLinkedData.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /**
  * FairMultiLinkedData.h
  *
@@ -8,13 +15,17 @@
 #ifndef FAIRMULTILINKEDDATA_H_
 #define FAIRMULTILINKEDDATA_H_
 
-//#include "FairLinkedData.h"
-#include "FairLink.h"
-#include "FairRootManager.h"
-#include "TClonesArray.h"
-#include "TObject.h"
-#include <set>
-#include <utility>
+#include "TObject.h"                    // for TObject
+
+#include "FairLink.h"                   // for FairLink
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, Bool_t, kFALSE, etc
+#include "TString.h"                    // for TString
+
+#include <iostream>                     // for operator<<, ostream, cout
+#include <set>                          // for set
+#include <vector>                       // for vector
 
 class FairMultiLinkedData : public  TObject
 {
@@ -27,9 +38,11 @@ class FairMultiLinkedData : public  TObject
     virtual ~FairMultiLinkedData() {};
 
     virtual std::set<FairLink>    GetLinks() const {    return fLinks;}           ///< returns stored links as FairLinks
+    virtual FairLink		GetEntryNr() const { return fEntryNr;}				///< gives back the entryNr
     virtual Int_t           GetNLinks() const { return fLinks.size(); }       ///< returns the number of stored links
     virtual FairLink        GetLink(Int_t pos) const;                 ///< returns the FairLink at the given position
     virtual FairMultiLinkedData   GetLinksWithType(Int_t type) const;             ///< Gives you a list of links which contain the given type
+    virtual std::vector<FairLink> GetSortedMCTracks();				///< Gives you a list of all FairLinks pointing to a "MCTrack" sorted by their weight
     TObject*         GetData(FairLink& myLink);                  ///< Get the TObject the Link is pointing to
     virtual Int_t GetDefaultType() { return fDefaultType;}
     Bool_t              GetPersistanceCheck() {return fPersistanceCheck;}     ///< Returns the value of PersistanceCheck
@@ -37,7 +50,9 @@ class FairMultiLinkedData : public  TObject
     virtual void SetDefaultType(Int_t type) {  fDefaultType = type;}
     virtual void SetPersistanceCheck(Bool_t check) {fPersistanceCheck = check;}       ///< Controls if a persistance check of a link is done or not
     virtual void SetVerbose(Int_t level) {fVerbose = level;}                ///< Sets the verbosity level
+    virtual void SetInsertHistory(Bool_t val){ fInsertHistory = val;}		///< Toggles if history of a link is inserted or not
 
+    virtual void SetEntryNr(FairLink entry){ fEntryNr = entry;}
     virtual void SetLinks(FairMultiLinkedData links, Float_t mult = 1.0);           ///< Sets the links as vector of FairLink
     virtual void SetLink(FairLink link, Bool_t bypass = kFALSE, Float_t mult = 1.0);      ///< Sets the Links with a single FairLink
 
@@ -45,7 +60,7 @@ class FairMultiLinkedData : public  TObject
     virtual void AddLink(FairLink link, Bool_t bypass = kFALSE, Float_t mult = 1.0);      ///< Adds a FairLink link at the end of fLinks. If multi is kTRUE a link is allowed more than once otherwise it is stored only once
 
     virtual void InsertLink(FairLink link);                         ///< Inserts a link into the list of links without persistance checking
-
+    virtual void InsertHistory(FairLink link);                      ///< Adds the FairLinks of the inserted link to the set of links of this object
 
 
     virtual void AddAllWeights(Double_t weight);                        ///< Adds weight to all Links
@@ -61,36 +76,42 @@ class FairMultiLinkedData : public  TObject
     virtual void DeleteLink(FairLink link)    {DeleteLink(link.GetType(), link.GetIndex());}          ///< Deletes a link ouf of fLinks
     virtual void DeleteLink(Int_t type, Int_t index);                               ///< Deletes a link ouf of fLinks
 
-    virtual void Reset() {fLinks.clear();}                                    ///< Clears fLinks
+    virtual void Reset() {ResetLinks();}
+    virtual void ResetLinks() {fLinks.clear();}                                    ///< Clears fLinks
 
 
-    virtual void Print(std::ostream& out = std::cout) const {
+    std::ostream& PrintLinkInfo(std::ostream& out = std::cout) const
+    {
+      out << GetEntryNr() << " -> [";
       for (Int_t i = 0; i < GetNLinks(); i++) {
-        GetLink(i).Print(out);
+        GetLink(i).PrintLinkInfo(out);
         out << " ";
       }
-      out << std::endl;
+      out << "]";
+      return out;
     }                                                     ///< Output
 
     friend std::ostream& operator<< (std::ostream& out, const FairMultiLinkedData& data) {
-      data.Print(out);
+      data.PrintLinkInfo(out);
       return out;
     }                                                     ///< Output
 
   protected:
-    std::set<FairLink> fLinks; //!
-    Bool_t fPersistanceCheck;
-    Int_t fVerbose;
+    std::set<FairLink> fLinks;
+    FairLink fEntryNr;
+    Bool_t fPersistanceCheck; //!
+    Bool_t fInsertHistory; //!
+    Int_t fVerbose; //!
 
-    virtual void SimpleAddLinks(Int_t fileId, Int_t evtId, Int_t dataType, std::vector<Int_t> links, Bool_t bypass, Float_t mult) {
+    virtual void SimpleAddLinks(Int_t fileId, Int_t evtId, Int_t dataType, std::vector<Int_t> links, Bool_t, Float_t) {
       for (UInt_t i = 0; i < links.size(); i++) {
-        AddLink(FairLink(fileId, evtId, dataType, links[i]), bypass, mult);
+        fLinks.insert(FairLink(fileId, evtId, dataType, links[i]));
       }
     }
     Int_t fDefaultType;
 
 
-    ClassDef(FairMultiLinkedData, 3);
+    ClassDef(FairMultiLinkedData, 4);
 };
 
 /**\fn virtual void FairMultiLinkedData::SetLinks(Int_t type, std::vector<Int_t> links)
diff --git a/base/event/FairMultiLinkedData_Interface.cxx b/base/event/FairMultiLinkedData_Interface.cxx
new file mode 100644
index 0000000..587276b
--- /dev/null
+++ b/base/event/FairMultiLinkedData_Interface.cxx
@@ -0,0 +1,208 @@
+/*
+ * FairMultiLinkedData_Interface.cxx
+ *
+ *  Created on: Dec 7, 2009
+ *      Author: stockman
+ */
+
+#include "FairMultiLinkedData_Interface.h"
+
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "TClonesArray.h"               // for TClonesArray
+
+#include <algorithm>                    // for find
+#include <iterator>                     // for distance
+
+ClassImp(FairMultiLinkedData_Interface);
+
+FairMultiLinkedData_Interface::FairMultiLinkedData_Interface()
+  :TObject(), fVerbose(0), fInsertHistory(kTRUE), fLink(NULL)
+{
+}
+
+FairMultiLinkedData_Interface::FairMultiLinkedData_Interface(FairMultiLinkedData& links, Bool_t)
+  :TObject(), fVerbose(0), fInsertHistory(kTRUE), fLink(NULL)
+{
+	SetLinks(links);
+}
+
+FairMultiLinkedData_Interface::FairMultiLinkedData_Interface(TString dataType, std::vector<Int_t> links, Int_t fileId, Int_t evtId, Bool_t persistanceCheck, Bool_t bypass, Float_t mult)
+  :TObject(), fVerbose(0), fInsertHistory(kTRUE), fLink(NULL)
+{
+	FairMultiLinkedData data(dataType, links, fileId, evtId, persistanceCheck, bypass, mult);
+	SetLinks(data);
+}
+
+FairMultiLinkedData_Interface::FairMultiLinkedData_Interface( Int_t dataType, std::vector<Int_t> links, Int_t fileId, Int_t evtId, Bool_t persistanceCheck, Bool_t bypass, Float_t mult)
+  :TObject(), fVerbose(0), fInsertHistory(kTRUE), fLink(NULL)
+{
+	FairMultiLinkedData data(dataType, links, fileId, evtId, persistanceCheck, bypass, mult);
+	SetLinks(data);
+}
+
+FairMultiLinkedData_Interface::FairMultiLinkedData_Interface(const FairMultiLinkedData_Interface& toCopy)
+  :TObject(), fVerbose(0), fInsertHistory(kTRUE), fLink(NULL)
+{
+	if (toCopy.GetPointerToLinks() != 0){
+		SetInsertHistory(kFALSE);
+		SetLinks(*(toCopy.GetPointerToLinks()));
+        SetEntryNr(toCopy.GetEntryNr());
+        fInsertHistory = toCopy.fInsertHistory;
+        SetInsertHistory(fInsertHistory);
+    }
+}
+
+FairMultiLinkedData_Interface& FairMultiLinkedData_Interface::operator=(const FairMultiLinkedData_Interface& rhs)
+{
+	if (rhs.GetPointerToLinks() != 0){
+		SetInsertHistory(kFALSE);
+		SetLinks(*(rhs.GetPointerToLinks()));
+        SetEntryNr(rhs.GetEntryNr());
+        SetInsertHistory(kTRUE);
+    }
+    return *this;
+}
+
+FairMultiLinkedData* FairMultiLinkedData_Interface::CreateFairMultiLinkedData()
+{
+	if (FairRootManager::Instance() != 0){
+		if (FairRootManager::Instance()->GetUseFairLinks()){
+			if (fLink == 0){
+				fLink = new FairMultiLinkedData();
+			}
+			fLink->SetInsertHistory(fInsertHistory);
+			return fLink;
+		}
+	}
+	return 0;
+}
+
+std::set<FairLink>    FairMultiLinkedData_Interface::GetLinks() const
+{
+	if (GetPointerToLinks() != 0){
+		return GetPointerToLinks()->GetLinks();
+	} else {
+		std::set<FairLink> emptySet;
+		return emptySet;
+	}
+}
+
+Int_t           FairMultiLinkedData_Interface::GetNLinks() const
+{
+	if (GetPointerToLinks() != 0){
+		return GetPointerToLinks()->GetNLinks();
+	} else {
+		return 0;
+	}
+}
+
+FairLink        FairMultiLinkedData_Interface::GetLink(Int_t pos) const
+{
+	if (GetPointerToLinks() != 0){
+		return GetPointerToLinks()->GetLink(pos);
+	} else {
+		FairLink emptyLink;
+		return emptyLink;
+	}
+}
+
+FairLink        FairMultiLinkedData_Interface::GetEntryNr() const
+{
+	if (GetPointerToLinks() != 0) {
+		return GetPointerToLinks()->GetEntryNr();
+	} else {
+		FairLink emptyLink;
+		return emptyLink;
+	}
+}
+
+FairMultiLinkedData   FairMultiLinkedData_Interface::GetLinksWithType(Int_t type) const
+{
+	if (GetPointerToLinks() != 0){
+		return GetPointerToLinks()->GetLinksWithType(type);
+	} else {
+		FairMultiLinkedData emptyLinks;
+		return emptyLinks;
+	}
+}
+
+std::vector<FairLink> FairMultiLinkedData_Interface::GetSortedMCTracks()
+{
+	if (GetPointerToLinks() != 0){
+		return GetPointerToLinks()->GetSortedMCTracks();
+	} else {
+		std::vector<FairLink> empty;
+		return empty;
+	}
+}
+
+void FairMultiLinkedData_Interface::SetLinks(FairMultiLinkedData links)
+{
+	CreateFairMultiLinkedData();
+	if (GetPointerToLinks() != 0){
+		GetPointerToLinks()->SetLinks(links);
+	}
+}
+
+void FairMultiLinkedData_Interface::SetLink(FairLink link)
+{
+	CreateFairMultiLinkedData();
+	if (GetPointerToLinks() != 0){
+		GetPointerToLinks()->SetLink(link);
+	}
+}
+
+void FairMultiLinkedData_Interface::SetEntryNr(FairLink val)
+{
+	CreateFairMultiLinkedData();
+	if (GetPointerToLinks() != 0) {
+		GetPointerToLinks()->SetEntryNr(val);
+	}
+}
+
+void FairMultiLinkedData_Interface::AddLinks(FairMultiLinkedData links, Float_t mult)
+{
+	CreateFairMultiLinkedData();
+	if (GetPointerToLinks() != 0){
+		GetPointerToLinks()->AddLinks(links, mult);
+	}
+}
+
+void FairMultiLinkedData_Interface::AddLink(FairLink link)
+{
+	CreateFairMultiLinkedData();
+	if (GetPointerToLinks() != 0){
+		GetPointerToLinks()->AddLink(link);
+	}
+
+}
+
+void FairMultiLinkedData_Interface::AddInterfaceData(FairMultiLinkedData_Interface* data)
+{
+	SetInsertHistory(kFALSE); //todo add previous history value
+	if (data->GetEntryNr().GetType() != -1)
+		AddLink(data->GetEntryNr());
+	else
+		std::cout << "-E- FairMultiLinkedData_Interface::AddInterfaceData EntryNr == " << data->GetEntryNr() << std::endl;
+
+	if (data->GetPointerToLinks() != 0) {
+		AddLinks(*data->GetPointerToLinks());
+	}
+	SetInsertHistory(fInsertHistory);
+}
+
+void FairMultiLinkedData_Interface::SetInsertHistory(Bool_t val)
+{
+	fInsertHistory = val;
+	if (GetPointerToLinks() != 0) {
+		GetPointerToLinks()->SetInsertHistory(val);
+	}
+}
+
+void FairMultiLinkedData_Interface::ResetLinks()
+{
+	if (GetPointerToLinks() != 0){
+		GetPointerToLinks()->ResetLinks();
+	}
+}
diff --git a/base/event/FairMultiLinkedData_Interface.h b/base/event/FairMultiLinkedData_Interface.h
new file mode 100644
index 0000000..c35d141
--- /dev/null
+++ b/base/event/FairMultiLinkedData_Interface.h
@@ -0,0 +1,100 @@
+/**
+ * FairMultiLinkedData_Interface.h
+ *
+ * \date Dec 7, 2009
+ * \author T.Stockmanns <t.stockmanns@fz-juelich.de>
+ */
+
+#ifndef FairMultiLinkedData_Interface_H_
+#define FairMultiLinkedData_Interface_H_
+
+#include "TObject.h"                    // for TObject
+
+#include "FairLink.h"                   // for FairLink
+#include "FairMultiLinkedData.h"
+#include "FairRootManager.h"
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, Bool_t, kFALSE, etc
+#include "TString.h"                    // for TString
+#include "TRef.h"
+
+#include <iostream>                     // for operator<<, ostream, cout
+#include <set>                          // for set
+#include <vector>                       // for vector
+
+
+class FairMultiLinkedData_Interface : public  TObject
+{
+  public:
+    FairMultiLinkedData_Interface();///< Default constructor
+    FairMultiLinkedData_Interface(FairMultiLinkedData& links, Bool_t persistanceCheck = kTRUE);///< Constructor
+    FairMultiLinkedData_Interface(TString dataType, std::vector<Int_t> links, Int_t fileId = -1, Int_t evtId = -1,Bool_t persistanceCheck = kTRUE, Bool_t bypass = kFALSE, Float_t mult = 1.0);///< Constructor
+    FairMultiLinkedData_Interface(Int_t dataType, std::vector<Int_t> links, Int_t fileId = -1, Int_t evtId = -1, Bool_t persistanceCheck = kTRUE, Bool_t bypass = kFALSE, Float_t mult = 1.0);///< Constructor
+    FairMultiLinkedData_Interface(const FairMultiLinkedData_Interface& toCopy);
+
+    virtual ~FairMultiLinkedData_Interface() {
+    	delete(fLink);
+    };
+
+    FairMultiLinkedData_Interface& operator=(const FairMultiLinkedData_Interface& rhs);
+
+    virtual std::set<FairLink>  GetLinks() const;           		///< returns stored links as FairLinks
+    virtual Int_t           	GetNLinks() const;                	///< returns the number of stored links
+    virtual FairLink        	GetLink(Int_t pos) const;         	///< returns the FairLink at the given position
+    virtual FairMultiLinkedData GetLinksWithType(Int_t type) const; ///< returns all FairLinks with the corresponding type
+    virtual FairLink            GetEntryNr() const;
+    virtual FairMultiLinkedData* 		GetPointerToLinks() const {	return fLink;}
+
+    virtual std::vector<FairLink> GetSortedMCTracks();
+
+    virtual void SetLinks(FairMultiLinkedData links);           ///< Sets the links as vector of FairLink
+    virtual void SetLink(FairLink link);      					///< Sets the Links with a single FairLink
+    virtual void SetInsertHistory(Bool_t val);
+    virtual void SetEntryNr(FairLink val);
+    virtual void SetPointerToLinks(FairMultiLinkedData* links) {fLink = links;}
+
+    virtual void AddLinks(FairMultiLinkedData links, Float_t mult = 1.0);		///< Adds a List of FairLinks (FairMultiLinkedData_Interface) to fLinks
+    virtual void AddLink(FairLink link);      									///< Adds a FairLink link at the end of fLinks. If multi is kTRUE a link is allowed more than once otherwise
+    virtual void AddInterfaceData(FairMultiLinkedData_Interface* data);
+
+
+
+    virtual void ResetLinks();
+
+
+    std::ostream& PrintLinkInfo(std::ostream& out = std::cout) const {
+
+		if (GetPointerToLinks() != 0)
+			GetPointerToLinks()->PrintLinkInfo(out);
+		return out;
+    }                                                     ///< Output
+
+    friend std::ostream& operator<< (std::ostream& out, FairMultiLinkedData_Interface& data) {
+      data.PrintLinkInfo(out);
+      return out;
+    }                                                     ///< Output
+
+  protected:
+
+    Int_t fVerbose; //!
+    Bool_t fInsertHistory; //!
+    FairMultiLinkedData* fLink;
+
+    FairMultiLinkedData* CreateFairMultiLinkedData();
+
+    ClassDef(FairMultiLinkedData_Interface, 5);
+};
+
+/**\fn virtual void FairMultiLinkedData_Interface::SetLinks(Int_t type, std::vector<Int_t> links)
+ * \param type as Int_t gives one type of source data for all indices
+ * \param links as vector<Int_t> gives the vector of indices at which position in the TClonesArray the source data is stored
+ */
+
+/**\fn virtual void FairMultiLinkedData_Interface::SetLinks(std::vector<Int_t> type, std::vector<Int_t> links)
+ * \param type as vector<Int_t> gives the type of source data (TClonesArray)
+ * \param links as vector<Int_t> gives the vector of indices at which position in the TClonesArray the source data is stored
+ */
+
+
+#endif /* FairMultiLinkedData_Interface_H_ */
diff --git a/base/FairRadLenPoint.cxx b/base/event/FairRadLenPoint.cxx
similarity index 75%
rename from base/FairRadLenPoint.cxx
rename to base/event/FairRadLenPoint.cxx
index 078a2fa..baef81b 100644
--- a/base/FairRadLenPoint.cxx
+++ b/base/event/FairRadLenPoint.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadLenPoint source file                   -----
 // -----                  Created 14/01/08  by M. Al-Turany            -----
diff --git a/base/FairRadLenPoint.h b/base/event/FairRadLenPoint.h
similarity index 75%
rename from base/FairRadLenPoint.h
rename to base/event/FairRadLenPoint.h
index 37233a3..4c675d2 100644
--- a/base/FairRadLenPoint.h
+++ b/base/event/FairRadLenPoint.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadLenPoint header file               -----
 // -----                  Created 14/01/08  by M. Al-Turany            -----
@@ -12,9 +19,10 @@
 #ifndef FAIRRADLENPOINT_H
 #define FAIRRADLENPOINT_H
 
-#include "TObject.h"
-#include "TVector3.h"
-#include "FairMCPoint.h"
+#include "FairMCPoint.h"                // for FairMCPoint
+
+#include "Rtypes.h"                     // for Double_t, Float_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairRadLenPoint : public FairMCPoint
 {
diff --git a/base/FairRadMapPoint.cxx b/base/event/FairRadMapPoint.cxx
similarity index 77%
rename from base/FairRadMapPoint.cxx
rename to base/event/FairRadMapPoint.cxx
index db835f2..8487004 100644
--- a/base/FairRadMapPoint.cxx
+++ b/base/event/FairRadMapPoint.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadMapPoint source file              -----
 // -------------------------------------------------------------------------
diff --git a/base/FairRadMapPoint.h b/base/event/FairRadMapPoint.h
similarity index 77%
rename from base/FairRadMapPoint.h
rename to base/event/FairRadMapPoint.h
index d8ba60c..bb20a1b 100644
--- a/base/FairRadMapPoint.h
+++ b/base/event/FairRadMapPoint.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                     FairRadMapPoint header file               -----
 // -------------------------------------------------------------------------
@@ -11,9 +18,10 @@
 #ifndef FAIRRADMAPPOINT_H
 #define FAIRRADMAPPOINT_H
 
-#include "TObject.h"
-#include "TVector3.h"
-#include "FairMCPoint.h"
+#include "FairMCPoint.h"                // for FairMCPoint
+
+#include "Rtypes.h"                     // for Double_t, Float_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairRadMapPoint : public FairMCPoint
 {
diff --git a/base/event/FairRecoEventHeader.cxx b/base/event/FairRecoEventHeader.cxx
new file mode 100644
index 0000000..dd25a1a
--- /dev/null
+++ b/base/event/FairRecoEventHeader.cxx
@@ -0,0 +1,29 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----            FairRecoEventHeader source file                    -----
+// -----            Created 20/09/13                 R.Karabowicz      -----
+// -------------------------------------------------------------------------
+
+
+#include "FairRecoEventHeader.h"
+
+// -----   Default constructor   -------------------------------------------
+FairRecoEventHeader::FairRecoEventHeader()
+  :fRunId(0),
+   fIdentifier(0),
+   fEventTime(-1.),
+   fEventTimeError(-1.)
+{
+
+}
+// -----   Destructor   ----------------------------------------------------
+FairRecoEventHeader::~FairRecoEventHeader() { }
+// -------------------------------------------------------------------------
+
+ClassImp(FairRecoEventHeader)
diff --git a/base/event/FairRecoEventHeader.h b/base/event/FairRecoEventHeader.h
new file mode 100644
index 0000000..20099c9
--- /dev/null
+++ b/base/event/FairRecoEventHeader.h
@@ -0,0 +1,114 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----          FairRecoEventHeader header file                      -----
+// -----          Created 20/09/13                 R.Karabowicz        -----
+// -------------------------------------------------------------------------
+
+#ifndef FAIRRECOEVENTHEADER_H
+#define FAIRRECOEVENTHEADER_H
+
+
+#include "TNamed.h"
+
+/**
+ *  Event Header Class
+  **@author D.Bertini <d.bertini@gsi.de>
+  **@author M.Al-Turany <m.al-turany@gsi.de>
+  **@author R.Karabowicz <r.karabowicz@gsi.de>
+ */
+class FairRecoEventHeader : public TNamed
+{
+
+  public:
+
+    /** Default constructor */
+    FairRecoEventHeader();
+
+    /** Get the run ID for this run*/
+    UInt_t GetRunId() const {
+      return fRunId;
+    }
+
+    /** Get the MC time for this event*/
+    Double_t GetEventTime() const {
+      return fEventTime;
+    }
+
+    /** Get the error of MC time for this event*/
+    Double_t GetEventTimeError() const {
+      return fEventTimeError;
+    }
+
+    /** Get identifier*/
+    Int_t GetIdentifier() const {
+      return fIdentifier;
+    }
+
+    /** Set the run ID for this run
+    * @param runid : unique run id
+    */
+    void SetRunId(UInt_t runid) {
+      fRunId=runid;
+    }
+
+    /** Set the MC time for this event
+     * @param time : time in ns
+     * @param terr : time error in ns
+     */
+    void SetEventTime(Double_t time, Double_t terr) {
+      fEventTime=time;
+      fEventTimeError=terr;
+    }
+
+    /** Set the run ID for this run
+    * @param ident : identifier
+    */
+    void SetIdentifier(Int_t ident) {
+      fIdentifier=ident;
+    }
+
+    virtual bool operator<(const FairRecoEventHeader& tempObj) const {
+      if (fEventTime < tempObj.GetEventTime()) { return true; }
+      else if (fEventTime > tempObj.GetEventTime()) { return false; }
+      return false;
+    }
+
+    virtual bool operator>(const FairRecoEventHeader& tempObj) const {
+      if (fEventTime > tempObj.GetEventTime()) { return true; }
+      else if (fEventTime < tempObj.GetEventTime()) { return false; }
+      return false;
+    }
+
+    virtual bool operator==(const FairRecoEventHeader& tempObj) const {
+      if   (fEventTime == tempObj.GetEventTime() ) {
+        return true;
+      }
+      return false;
+    }
+
+    /**
+     * Destructor
+     */
+    virtual ~FairRecoEventHeader();
+
+  protected:
+
+    /** Run Id */
+    UInt_t fRunId;
+    /** Identifier */
+    Int_t     fIdentifier;
+    /** Event Time **/
+    Double_t  fEventTime;
+    /** Event Time Error **/
+    Double_t  fEventTimeError;
+
+    ClassDef(FairRecoEventHeader,1)
+
+};
+#endif
diff --git a/base/FairRunInfo.cxx b/base/event/FairRunInfo.cxx
similarity index 71%
rename from base/FairRunInfo.cxx
rename to base/event/FairRunInfo.cxx
index 82dcd5d..30273df 100644
--- a/base/FairRunInfo.cxx
+++ b/base/event/FairRunInfo.cxx
@@ -1,14 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairRunInfo.h"
-#include "FairLogger.h"
 
-#include "TSystem.h"
-#include "TFile.h"
-#include "TList.h"
-#include "TH1.h"
-#include "TDirectory.h"
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
 
-#include <iostream>
-#include <algorithm>
+#include "TFile.h"                      // for TFile, gFile
+#include "TH1.h"                        // for TH1F
+#include "TIterator.h"                  // for TIterator
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
+#include "TSystem.h"                    // for ProcInfo_t, TSystem, etc
+
+#include <stddef.h>                     // for NULL
+#include <algorithm>                    // for sort
 
 ClassImp(FairRunInfo)
 
@@ -26,11 +35,11 @@ FairRunInfo::FairRunInfo()
    fLogger(FairLogger::GetLogger())
 {
 }
-
+//_____________________________________________________________________________
 FairRunInfo::~FairRunInfo()
 {
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::StoreInfo()
 {
   // Extract the Information about the used memory from the system.
@@ -45,7 +54,7 @@ void FairRunInfo::StoreInfo()
 
   PrintInfo();
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::GetInfo()
 {
   // Set the TimeStamp to the actual time and store it
@@ -57,7 +66,7 @@ void FairRunInfo::GetInfo()
   fResidentMemory.push_back(fProcInfo.fMemResident/1024);
   fVirtualMemory.push_back(fProcInfo.fMemVirtual/1024);
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::CalculateTimeDifference()
 {
   // Calculates the time difference between now and the last call
@@ -66,7 +75,7 @@ void FairRunInfo::CalculateTimeDifference()
   fTimeDiff.push_back( fTime.at(lastElement) -
                        fTime.at(lastElement-1) );
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::PrintInfo()
 {
 
@@ -77,7 +86,7 @@ void FairRunInfo::PrintInfo()
   fLogger->Debug(MESSAGE_ORIGIN,"Used virtual memory: %i MB",
                  fVirtualMemory.back());
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::WriteInfo()
 {
   TList* histoList = new TList();
@@ -85,7 +94,7 @@ void FairRunInfo::WriteInfo()
   //  CreateAndFillHistograms(histoList);
   WriteHistosToFile(histoList);
 }
-
+//_____________________________________________________________________________
 void FairRunInfo::CreateAndFillHistograms(TList* histoList)
 {
   Int_t entries = fTime.size();
@@ -93,8 +102,8 @@ void FairRunInfo::CreateAndFillHistograms(TList* histoList)
 
   TH1F* ResidentMemoryVsEvent = new TH1F("ResidentMemoryVsEvent","Resident Memory as function of Eventnumber;Event;Memory [MB]",entries, 0, entries);
   TH1F* VirtualMemoryVsEvent = new TH1F("VirtualMemoryVsEvent","Virtual Memory as function of Eventnumber;Event;Memory [MB]",entries, 0, entries);
-  TH1F* ResidentMemoryVsTime = new TH1F("ResidentMemoryVsTime","Resident memory as function of Runtime;Time [s];Memory [MB]",(Int_t)(timePeriod*10), 0, (Int_t)timePeriod);
-  TH1F* VirtualMemoryVsTime = new TH1F("VirtualMemoryVsTime","Virtual memory as function of Runtime;Time [s];Memory [MB]",(Int_t)(timePeriod*10), 0, (Int_t)timePeriod);
+  TH1F* ResidentMemoryVsTime = new TH1F("ResidentMemoryVsTime","Resident memory as function of Runtime;Time [s];Memory [MB]",static_cast<Int_t>(timePeriod*10), 0, static_cast<Int_t>(timePeriod));
+  TH1F* VirtualMemoryVsTime = new TH1F("VirtualMemoryVsTime","Virtual memory as function of Runtime;Time [s];Memory [MB]",static_cast<Int_t>(timePeriod*10), 0, static_cast<Int_t>(timePeriod));
   TH1F* EventtimeVsEvent = new TH1F("EventtimeVsEvent","Runtime per Event as function of Event number;Event;Time [s]",entries-1, 1, entries);
 
   std::vector<Double_t> timeDiffSorted(fTimeDiff);
@@ -105,7 +114,7 @@ void FairRunInfo::CreateAndFillHistograms(TList* histoList)
   Double_t maxTime = timeDiffSorted.back();
   timePeriod = maxTime - minTime;
 
-  TH1F* TimePerEvent = new TH1F("TimePerEvent","Runtime;Time [s];Events",(Int_t)((timePeriod+20)*10), (Int_t)minTime-10, (Int_t)maxTime+10);
+  TH1F* TimePerEvent = new TH1F("TimePerEvent","Runtime;Time [s];Events",static_cast<Int_t>((timePeriod+20)*10), static_cast<Int_t>(minTime-10), static_cast<Int_t>(maxTime+10));
 
   Int_t counter = 0;
   std::vector<Long_t>::iterator lit;
@@ -136,6 +145,7 @@ void FairRunInfo::CreateAndFillHistograms(TList* histoList)
   histoList->AddLast(TimePerEvent);
   histoList->AddLast(EventtimeVsEvent);
 }
+//_____________________________________________________________________________
 
 void FairRunInfo::WriteHistosToFile(TList* histoList)
 {
@@ -168,7 +178,7 @@ void FairRunInfo::WriteHistosToFile(TList* histoList)
 
 
 
-  Int_t pid = gSystem->GetPid();
+//  Int_t pid = gSystem->GetPid();
   filename += "FairRunInfo_";
   filename += directory;
   filename += ".root";
@@ -213,6 +223,7 @@ void FairRunInfo::WriteHistosToFile(TList* histoList)
   gDirectory=currentDir;
   */
 }
+//_____________________________________________________________________________
 
 void FairRunInfo::Reset()
 {
diff --git a/base/event/FairRunInfo.h b/base/event/FairRunInfo.h
new file mode 100644
index 0000000..8b432a4
--- /dev/null
+++ b/base/event/FairRunInfo.h
@@ -0,0 +1,65 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRRUNINFO_H
+#define FAIRRUNINFO_H
+
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Double_t, Long_t, etc
+#include "TSystem.h"                    // for CpuInfo_t, MemInfo_t, etc
+#include "TTimeStamp.h"                 // for TTimeStamp
+
+#include <vector>                       // for vector
+
+class FairLogger;
+class TList;
+
+class FairRunInfo : public TObject
+{
+
+  public:
+
+    FairRunInfo();
+
+    ~FairRunInfo();
+
+    void StoreInfo();
+
+    void WriteInfo();
+
+    void Reset();
+
+  private:
+
+    TTimeStamp  fTimeStamp;//!
+    CpuInfo_t   fCpuInfo;//!
+    MemInfo_t   fMemInfo;//!
+    ProcInfo_t  fProcInfo;//!
+    std::vector<Double_t> fTimeDiff;//!
+    std::vector<Double_t> fTime;//!
+    std::vector<Long_t> fResidentMemory;//!
+    std::vector<Long_t> fVirtualMemory;//!
+    FairLogger* fLogger;
+
+    void CalculateTimeDifference();
+
+    void PrintInfo();
+
+    void GetInfo();
+
+    void CreateAndFillHistograms(TList* histoList);
+
+    void WriteHistosToFile(TList* histoList);
+
+    FairRunInfo(const FairRunInfo&);
+    FairRunInfo& operator=(const FairRunInfo&);
+
+    ClassDef(FairRunInfo,1)
+
+};
+#endif
diff --git a/base/event/FairTimeStamp.cxx b/base/event/FairTimeStamp.cxx
new file mode 100644
index 0000000..ddfa626
--- /dev/null
+++ b/base/event/FairTimeStamp.cxx
@@ -0,0 +1,49 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#include "FairTimeStamp.h"
+
+// -----   Default constructor   -------------------------------------------
+FairTimeStamp::FairTimeStamp()
+  : FairMultiLinkedData_Interface(),
+    fTimeStamp(-1),
+    fTimeStampError(-1),
+    fEntryNr()
+{
+}
+// -----   Standard constructor   ------------------------------------------
+FairTimeStamp::FairTimeStamp(Double_t time)
+  : FairMultiLinkedData_Interface(),
+    fTimeStamp(time),
+    fTimeStampError(-1),
+    fEntryNr()
+{
+}
+
+FairTimeStamp::FairTimeStamp(Double_t time, Double_t timeerror)
+  : FairMultiLinkedData_Interface(),
+    fTimeStamp(time),
+    fTimeStampError(timeerror),
+    fEntryNr()
+{
+}
+
+// -----   Destructor   ----------------------------------------------------
+FairTimeStamp::~FairTimeStamp()
+{
+}
+
+// -------------------------------------------------------------------------
+
+std::ostream& FairTimeStamp::PrintTimeInfo(std::ostream& out) const
+{
+  out << "EntryNr of Data: " << fEntryNr << " TimeStamp: " << GetTimeStamp() << " +/- " << GetTimeStampError() << std::endl;
+  FairMultiLinkedData_Interface::PrintLinkInfo(out);
+
+  return out;
+}
+ClassImp(FairTimeStamp)
diff --git a/base/FairTimeStamp.h b/base/event/FairTimeStamp.h
similarity index 50%
rename from base/FairTimeStamp.h
rename to base/event/FairTimeStamp.h
index 5ced222..8d4fc3e 100644
--- a/base/FairTimeStamp.h
+++ b/base/event/FairTimeStamp.h
@@ -1,12 +1,35 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRTIMESTAMP_H
 #define FAIRTIMESTAMP_H
-#include "FairMultiLinkedData.h"
+
+#include "FairMultiLinkedData_Interface.h"        // for FairMultiLinkedData
+
+#include "FairLink.h"                   // for FairLink
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Double_t, etc
+
+#include <iostream>                     // for ostream, cout
+
+#ifndef __CINT__ // for BOOST serialization
+#include <boost/serialization/access.hpp>
+#include <boost/serialization/base_object.hpp>
+#endif //__CINT__
+
+class TObject;
+
 /**
  * Base class for Time stamp information
  ** Aug. 2010
  **@author M.Al-Turany <m.al-turany@gsi.de>
  */
-class FairTimeStamp : public FairMultiLinkedData
+class FairTimeStamp : public FairMultiLinkedData_Interface
 {
   public:
     /** Default constructor **/
@@ -28,7 +51,7 @@ class FairTimeStamp : public FairMultiLinkedData
     virtual void SetEntryNr(FairLink entry) {fEntryNr = entry;}
     virtual Int_t Compare(const TObject* obj) const {
       if (this == obj) { return 0; }
-      FairTimeStamp* tsobj = (FairTimeStamp*)obj;
+      FairTimeStamp* tsobj = static_cast<FairTimeStamp*>(const_cast<TObject*>(obj));
       Double_t ts = tsobj->GetTimeStamp();
       Double_t tserror = tsobj->GetTimeStampError();
       if (fTimeStamp < ts) { return -1; }
@@ -38,7 +61,7 @@ class FairTimeStamp : public FairMultiLinkedData
     }
 
 
-    virtual void Print(std::ostream& out = std::cout) const;
+    virtual std::ostream& PrintTimeInfo(std::ostream& out = std::cout) const;
     virtual Bool_t IsSortable() const { return kTRUE;};
 
 
@@ -47,17 +70,35 @@ class FairTimeStamp : public FairMultiLinkedData
     }
 
     friend std::ostream& operator<< (std::ostream& out, const FairTimeStamp& link) {
-      link.Print(out);
+      link.PrintTimeInfo(out);
       return out;
     }
 
+    virtual bool operator< (const FairTimeStamp* rValue) const {
+    	if (GetTimeStamp() < rValue->GetTimeStamp())
+    		return true;
+    	else
+    		return false;
+    }
+
+    template<class Archive>
+    void serialize(Archive& ar, const unsigned int)
+    {
+        // ar & boost::serialization::base_object<FairMultiLinkedData>(*this);
+        ar& fTimeStamp;
+        ar& fTimeStampError;
+    }
 
   protected:
+#ifndef __CINT__ // for BOOST serialization
+    friend class boost::serialization::access;
+#endif // for BOOST serialization
+
     Double_t fTimeStamp;        /** Time of digit or Hit  [ns] */
     Double_t fTimeStampError;     /** Error on time stamp */
     FairLink fEntryNr; //!  indicates where the data is stored in the branch
 
-    ClassDef(FairTimeStamp,2);
+    ClassDef(FairTimeStamp,3);
 };
 
 #endif
diff --git a/base/FairTrackParam.cxx b/base/event/FairTrackParam.cxx
similarity index 77%
rename from base/FairTrackParam.cxx
rename to base/event/FairTrackParam.cxx
index 09fb061..7b5763b 100644
--- a/base/FairTrackParam.cxx
+++ b/base/event/FairTrackParam.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                     FairTrackParam source file                 -----
 // -----                  Created 27/01/05  by V. Friese               -----
@@ -5,11 +12,15 @@
 
 #include "FairTrackParam.h"
 
-#include "TMath.h"
+#include "FairLogger.h"
 
-#include <iostream>
-using std::cout;
-using std::endl;
+#include "Riosfwd.h"                    // for ostream
+#include "TMath.h"                      // for Sqrt
+#include "TMathBase.h"                  // for Abs
+#include "TMatrixTSym.h"                // for TMatrixTSym
+#include "TMatrixTUtils.h"              // for TMatrixTRow, etc
+
+#include <iomanip>
 
 // -----   Default constructor   -------------------------------------------
 FairTrackParam::FairTrackParam()
@@ -66,13 +77,13 @@ FairTrackParam::~FairTrackParam() {}
 
 
 // -----   Public method Print   -------------------------------------------
-void FairTrackParam::Print(Option_t* option) const
+void FairTrackParam::Print(Option_t*) const
 {
-  cout << "Position : (";
-  cout.precision(2);
-  cout << fX << ", " << fY << ", " << fZ << ")" << endl;
-  cout << "Slopes : dx/dz = " << fTx << ", dy/dz = " << fTy << endl;
-  cout << "q/p = " << fQp << endl;
+  LOG(INFO) << "Position : (" << std::setprecision(2)
+	    << fX << ", " << fY << ", " << fZ << ")" << FairLogger::endl;
+  LOG(INFO) << "Slopes : dx/dz = " << fTx << ", dy/dz = " << fTy 
+	    << FairLogger::endl;
+  LOG(INFO) << "q/p = " << fQp << FairLogger::endl;
 }
 // -------------------------------------------------------------------------
 
@@ -122,8 +133,8 @@ void FairTrackParam::CovMatrix(TMatrixFSym& covMat) const
 Double_t FairTrackParam::GetCovariance(Int_t i, Int_t j) const
 {
   if ( i<0 || j<0 || i>4 || j>4 ) {
-    cout << "-E- FairTrackParam::GetCovariance: Invalid index pair ("
-         << i << "," << j << ") !" << endl;
+    LOG(ERROR) << "FairTrackParam::GetCovariance: Invalid index pair ("
+	       << i << "," << j << ") !" << FairLogger::endl;
     return 0;
   }
   if (i>j) {
@@ -179,13 +190,13 @@ void FairTrackParam::SetCovMatrix(const TMatrixFSym& covMat)
 void FairTrackParam::SetCovariance(Int_t i, Int_t j, Double_t val)
 {
   if (i < 0 || i > 4) {
-    cout << "-W- FairTrackParam::SetCovariance: "
-         << "First index out of range!  " << i << endl;
+    LOG(WARNING) << "FairTrackParam::SetCovariance: "
+		 << "First index out of range!  " << i << FairLogger::endl;
     return;
   }
   if (j < 0 || j > 4) {
-    cout << "-W- FairTrackParam::SetCovariance: "
-         << "Second index out of range!  " << j << endl;
+    LOG(WARNING) << "FairTrackParam::SetCovariance: "
+         << "Second index out of range!  " << j << FairLogger::endl;
     return;
   }
   if (i>j) {
diff --git a/base/FairTrackParam.h b/base/event/FairTrackParam.h
similarity index 78%
rename from base/FairTrackParam.h
rename to base/event/FairTrackParam.h
index e63e9f7..3d2761a 100644
--- a/base/FairTrackParam.h
+++ b/base/event/FairTrackParam.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                     FairTrackParam header file                 -----
 // -----                  Created 27/01/05  by V. Friese               -----
@@ -20,13 +27,11 @@
 #ifndef FAIRSTSTRACKPARAM
 #define FAIRSTSTRACKPARAM 1
 
+#include "TObject.h"                    // for TObject
 
-# include "TObject.h"
-
-#include "TMatrixFSym.h"
-#include "TVector3.h"
-
-
+#include "Rtypes.h"                     // for Double_t, Double32_t, Int_t, etc
+#include "TMatrixFSymfwd.h"             // for TMatrixFSym
+#include "TVector3.h"                   // for TVector3
 
 class FairTrackParam : public TObject
 {
diff --git a/base/event/README.md b/base/event/README.md
new file mode 100644
index 0000000..7705ffe
--- /dev/null
+++ b/base/event/README.md
@@ -0,0 +1,4 @@
+event
+========
+
+Base data classes of FairRoot, for event headers, Monte Carlo points, hits, radiation length measurements.
diff --git a/base/FairField.cxx b/base/field/FairField.cxx
similarity index 73%
rename from base/FairField.cxx
rename to base/field/FairField.cxx
index 8d16f7a..9625429 100644
--- a/base/FairField.cxx
+++ b/base/field/FairField.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairField source file                    -----
 // -----                Created 06/01/04  by M. Al/Turany              -----
@@ -17,7 +24,7 @@ FairField::FairField()
 
 
 // -----   Constructor with name and title   -------------------------------
-FairField::FairField(const char* name, const char* title)
+FairField::FairField(const char* name, const char*)
   : TVirtualMagField(name),
     fType(0)
 {
diff --git a/base/FairField.h b/base/field/FairField.h
similarity index 74%
rename from base/FairField.h
rename to base/field/FairField.h
index a6b2277..d153714 100644
--- a/base/FairField.h
+++ b/base/field/FairField.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairField header file                     -----
 // -----                Created 06/01/04  by M. Al-Turany              -----
@@ -96,18 +103,18 @@ class FairField : public TVirtualMagField
     /** Get x component of magnetic field [kG]
      ** @param x,y,z    Position [cm]
      **/
-    virtual Double_t GetBx(Double_t x, Double_t y, Double_t z) {LOG(WARNING)<<"FairField::GetBx Should be implemented in User class"<<FairLogger::endl; return 0;}
+    virtual Double_t GetBx(Double_t, Double_t, Double_t) {LOG(WARNING)<<"FairField::GetBx Should be implemented in User class"<<FairLogger::endl; return 0;}
 
 
     /** Get y component of magnetic field [kG]
      ** @param x,y,z    Position [cm]
      **/
-    virtual Double_t GetBy(Double_t x, Double_t y, Double_t z) {LOG(WARNING)<<"FairField::GetBy Should be implemented in User class"<<FairLogger::endl; return 0;}
+    virtual Double_t GetBy(Double_t, Double_t, Double_t) {LOG(WARNING)<<"FairField::GetBy Should be implemented in User class"<<FairLogger::endl; return 0;}
 
     /** Get z component of magnetic field [kG]
      ** @param x,y,z    Position [cm]
      **/
-    virtual Double_t GetBz(Double_t x, Double_t y, Double_t z) {LOG(WARNING)<<"FairField::GetBz Should be implemented in User class"<<FairLogger::endl; return 0;}
+    virtual Double_t GetBz(Double_t, Double_t, Double_t) {LOG(WARNING)<<"FairField::GetBz Should be implemented in User class"<<FairLogger::endl; return 0;}
 
 
     /** Get magnetic field. For use of GEANT3
@@ -121,8 +128,8 @@ class FairField : public TVirtualMagField
 
 
     /** Screen output. To be implemented in the concrete class. **/
-    virtual void  Print(Option_t* option = "") const {;}
-    virtual void GetBxyz(const Double_t point[3], Double_t* bField) {LOG(WARNING)<<"FairField::GetBxyz Should be implemented in User class"<<FairLogger::endl;}
+    virtual void  Print(Option_t*) const {;}
+    virtual void GetBxyz(const Double_t[3], Double_t*) {LOG(WARNING)<<"FairField::GetBxyz Should be implemented in User class"<<FairLogger::endl;}
 
 
 
diff --git a/base/FairFieldFactory.cxx b/base/field/FairFieldFactory.cxx
similarity index 51%
rename from base/FairFieldFactory.cxx
rename to base/field/FairFieldFactory.cxx
index caaa0c2..c4e9fa2 100644
--- a/base/FairFieldFactory.cxx
+++ b/base/field/FairFieldFactory.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----              FairFieldFactory source file                     -----
 // -----          Created 12/01/04  by   M. Al-Turany                  -----
diff --git a/base/FairFieldFactory.h b/base/field/FairFieldFactory.h
similarity index 60%
rename from base/FairFieldFactory.h
rename to base/field/FairFieldFactory.h
index e0c2078..478706a 100644
--- a/base/FairFieldFactory.h
+++ b/base/field/FairFieldFactory.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                    FairFieldFactory header file                  -----
 // -----                Created 15/01/07  by M. Al-Turany              -----
@@ -7,7 +14,9 @@
 #ifndef FAIRFIELDFACTORY_H
 #define FAIRFIELDFACTORY_H
 
-#include "FairField.h"
+#include "Rtypes.h"                     // for FairFieldFactory::Class, etc
+
+class FairField;
 
 class FairFieldFactory
 {
diff --git a/base/FairRKPropagator.cxx b/base/field/FairRKPropagator.cxx
similarity index 93%
rename from base/FairRKPropagator.cxx
rename to base/field/FairRKPropagator.cxx
index 80bc157..8b2e4cc 100644
--- a/base/FairRKPropagator.cxx
+++ b/base/field/FairRKPropagator.cxx
@@ -1,8 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairRKPropagator.h"
 
+#include "FairField.h"                  // for FairField
 
-#include "TMath.h"
-#include "TVector3.h"
+#include "TMath.h"                      // for Sqrt
+#include "TMathBase.h"                  // for Abs
+
+#include <stdio.h>                      // for printf
 
 ClassImp(FairRKPropagator);
 
@@ -32,6 +42,8 @@ void FairRKPropagator::PropagatToPlane(Double_t Charge, Double_t* vecRKIn, Doubl
   Double_t distance[3];
   Double_t vecRKoutT[7];
 
+  for (Int_t i=0; i< 7; i++) {vecRKoutT[i]=0;}
+    
   Norm[0]=vec1[1]*vec2[2] - vec2[2] * vec2[1]; // a2b3 − a3b2,
   Norm[1]=vec1[2]*vec2[0] - vec1[0] * vec2[2]; // a3b1 − a1b3;
   Norm[2]=vec1[0]*vec2[1] - vec1[1] * vec2[0];
diff --git a/base/FairRKPropagator.h b/base/field/FairRKPropagator.h
similarity index 66%
rename from base/FairRKPropagator.h
rename to base/field/FairRKPropagator.h
index c0913f3..37dece4 100644
--- a/base/FairRKPropagator.h
+++ b/base/field/FairRKPropagator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /**
 * Runge-Kutte Track propagator
 * @author M. Al-Turany
@@ -8,7 +15,11 @@
 #ifndef RKPropagator
 #define RKPropagator
 
-#include "FairField.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Double_t, etc
+
+class FairField;
 
 class FairRKPropagator : public TObject
 {
diff --git a/base/field/README.md b/base/field/README.md
new file mode 100644
index 0000000..2876df9
--- /dev/null
+++ b/base/field/README.md
@@ -0,0 +1,7 @@
+field
+========
+
+The `FairField` base class allows implementation of the experiment
+specific magnetic field.
+
+The propagation through the magnetic field may be performed by the `FairRKPropagator`.
\ No newline at end of file
diff --git a/base/FairBaseContFact.cxx b/base/sim/FairBaseContFact.cxx
similarity index 61%
rename from base/FairBaseContFact.cxx
rename to base/sim/FairBaseContFact.cxx
index b63ab15..c2061cf 100644
--- a/base/FairBaseContFact.cxx
+++ b/base/sim/FairBaseContFact.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                     FairBaseContFact source file              -----
 // -----                Created 25/10/04  by  Ilse Koenig              -----
@@ -6,9 +13,16 @@
 
 //  Factory for the parameter containers in Base
 
+#include <string.h>
+
 #include "FairBaseContFact.h"
 #include "FairBaseParSet.h"
+#include "FairGeoParSet.h"
 #include "FairRuntimeDb.h"
+#include "TList.h"
+#include "TString.h"
+
+class FairParSet;
 
 
 ClassImp(FairBaseContFact)
@@ -34,6 +48,15 @@ void FairBaseContFact::setAllContainers()
                                           "DefaultContext");
   pTest->addContext("TestNonDefaultContext");
   containers->Add(pTest);
+
+  FairContainer* pGeo= new FairContainer("FairGeoParSet",
+                                         "class for Geo parameter",
+                                         "DefaultContext");
+  pTest->addContext("TestNonDefaultContext");
+  containers->Add(pGeo);
+
+
+
 }
 
 FairParSet* FairBaseContFact::createContainer(FairContainer* c)
@@ -45,7 +68,10 @@ FairParSet* FairBaseContFact::createContainer(FairContainer* c)
   FairParSet* p=0;
   if (strcmp(name,"FairBaseParSet")==0) {
     p=new FairBaseParSet(c->getConcatName().Data(),c->GetTitle(),c->getContext());
+  } else if (strcmp(name,"FairGeoParSet")==0) {
+    p=new FairGeoParSet(c->getConcatName().Data(),c->GetTitle(),c->getContext());
   }
+
   return p;
 }
 
diff --git a/base/sim/FairBaseContFact.h b/base/sim/FairBaseContFact.h
new file mode 100644
index 0000000..3c8816e
--- /dev/null
+++ b/base/sim/FairBaseContFact.h
@@ -0,0 +1,34 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRBASECONTFACT_H
+#define FAIRBASECONTFACT_H
+
+#include "FairContFact.h"               // for FairContFact, etc
+
+#include "Rtypes.h"                     // for FairBaseContFact::Class, etc
+
+class FairParSet;
+
+class FairBaseContFact : public FairContFact
+{
+    /** Factory for all Base parameter containers */
+  private:
+    void setAllContainers();
+  public:
+    /**default ctor*/
+    FairBaseContFact();
+    /**default dtor*/
+    ~FairBaseContFact() {}
+    /** Calls the constructor of the corresponding parameter container.
+     * For an actual context, which is not an empty string and not the default context
+     * of this container, the name is concatinated with the context. */
+    FairParSet* createContainer(FairContainer*);
+    ClassDef( FairBaseContFact,0)
+};
+
+#endif  /* !FAIRBASECONTFACT_H */
diff --git a/base/FairBaseParSet.cxx b/base/sim/FairBaseParSet.cxx
similarity index 61%
rename from base/FairBaseParSet.cxx
rename to base/sim/FairBaseParSet.cxx
index 060d7e2..a3ad4f9 100644
--- a/base/FairBaseParSet.cxx
+++ b/base/sim/FairBaseParSet.cxx
@@ -1,12 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairBaseParSet source file              -----
 // -----                Created 06/01/04  by M. Al/Turany              -----
 // -------------------------------------------------------------------------
 
 #include "FairBaseParSet.h"
-#include "FairPrimaryGenerator.h"
-#include "FairParamList.h"
-#include "TObjArray.h"
+
+#include "FairParamList.h"              // for FairParamList
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
 
 
 ClassImp(FairBaseParSet)
@@ -14,11 +21,10 @@ ClassImp(FairBaseParSet)
 FairBaseParSet::FairBaseParSet(const char* name,const char* title,const char* context)
   : FairParGenericSet(name,title,context),
     fDetList(0),
-    fGeoNodes(new TObjArray()),
     fPriGen(0),
     fBeamMom(15),
-    fGeom(0),
-    fContNameList(new TObjArray())
+    fContNameList(new TObjArray()),
+    fRandomSeed(99999999)
 {
 
 
@@ -33,9 +39,7 @@ void FairBaseParSet::clear(void)
 {
   if(fPriGen) { delete fPriGen; }
   if(fDetList) { delete fDetList; }
-  if(fGeoNodes) { delete fGeoNodes; }
   if(fContNameList) { delete fContNameList; }
-// if(fGeom ) delete fGeom;
 
 }
 
@@ -44,10 +48,9 @@ void FairBaseParSet::putParams(FairParamList* l)
   if (!l) { return; }
   l->addObject("Detector List", fDetList);
   l->addObject("Event Generator", fPriGen);
-  l->addObject("FairGeoNodes List", fGeoNodes);
   l->add("Beam Momentum Gev/c", fBeamMom);
-  l->addObject("Detector Geometry", fGeom);
   l->addObject("Parameter containers list", fContNameList);
+  l->add("Random Seed", fRandomSeed);
 }
 
 Bool_t FairBaseParSet::getParams(FairParamList* l)
@@ -55,10 +58,9 @@ Bool_t FairBaseParSet::getParams(FairParamList* l)
   if (!l) { return kFALSE; }
   if (!l->fillObject("Detector List", fDetList)) { return kFALSE; }
   if (!l->fillObject("Event Generator", fPriGen)) { return kFALSE; }
-  if (!l->fillObject("FairGeoNodes List", fGeoNodes)) { return kFALSE; }
   if (!l->fill("Beam Momentum Gev/c", &fBeamMom)) { return kFALSE; }
-  if (!l->fillObject("Detector Geometry", fGeom)) { return kFALSE; }
   if (!l->fillObject("Parameter containers list", fContNameList)) { return kFALSE; }
+  if (!l->fill("Random Seed", &fRandomSeed)) { return kFALSE; }
   return kTRUE;
 }
 
diff --git a/base/FairBaseParSet.h b/base/sim/FairBaseParSet.h
similarity index 71%
rename from base/FairBaseParSet.h
rename to base/sim/FairBaseParSet.h
index 7faa866..a3fc389 100644
--- a/base/FairBaseParSet.h
+++ b/base/sim/FairBaseParSet.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRBASEPARSET_H
 #define FAIRBASEPARSET_H
 
@@ -7,11 +14,12 @@
  * @version 1
  * @since 12.10.04
  */
+#include "FairParGenericSet.h"          // for FairParGenericSet
 
+#include "Rtypes.h"                     // for Double_t, etc
+#include "TGeoManager.h"                // IWYU pragma: keep needed by cint
 
-#include "FairParGenericSet.h"
-#include "TGeoManager.h"
-#include "TObjString.h"
+class FairParamList;
 class FairPrimaryGenerator;
 class TObjArray;
 
@@ -50,11 +58,6 @@ class FairBaseParSet : public FairParGenericSet
      * @param array: TObjArray of detector
      */
     void SetDetList(TObjArray* array) {fDetList=array;}
-    /**
-     * Set the Geometry node list used in the simulation
-     * @param array: TObjArray of Geometry nodes
-     */
-    void SetGeoNodes(TObjArray* array) {fGeoNodes=array;}
     /**
      * Set the Generator used in the simulation
      * @param gen: Primary generator used in simulation
@@ -65,24 +68,20 @@ class FairBaseParSet : public FairParGenericSet
      * @param BMom: Beam Momentum in GeV/c
      */
     void SetBeamMom(Double_t  BMom) {fBeamMom = BMom;}
-    /**
-     * Set the Geometry (TGeoManager) used in the simulation
-     * @param Geom: TGeoManager of the full geometry
-     */
-    void SetGeometry(TGeoManager* Geom) {fGeom=Geom;}
     /**
      * Set the list of parameter containers used in a run
      * @param array: TObjArray of containers
      */
     void SetContListStr(TObjArray* list) {fContNameList= list;}
+   /**
+    * Set the random seed used in a run
+    * @param RndSeed: Random Seed
+    */
+    void SetRndSeed(UInt_t RndSeed) {fRandomSeed= RndSeed;}
     /**
      *  Get the detector list used in the simulation
      */
     TObjArray*             GetDetList() {return fDetList;}
-    /**
-    *  Get the Geometry Nodes list used in the simulation
-    */
-    TObjArray*             GetGeoNodes() {return fGeoNodes;}
     /**
      *  Get the Primery generator used in the simulation
      */
@@ -91,31 +90,30 @@ class FairBaseParSet : public FairParGenericSet
      *  Get the Beam Momentum used in the simulation (GeV/c)
      */
     Double_t          GetBeamMom() {return fBeamMom; }
-    /**
-     *  Get the geometry (TGeoManager) used in the simulation
-     */
-    TGeoManager*           GetGeometry() {return fGeom;}
     /**
      *  Get the parameter container list used in this run
      */
     TObjArray*             GetContList() {return fContNameList;}
+   /**
+    *  Get the Random Seed used in this run
+    */
+    UInt_t  GetRndSeed() {return fRandomSeed;}
+   
 
   protected:
 
     /// Detectors used in the simulation
     TObjArray*              fDetList;
-    /// List of FairGeoNodes for sensitive volumes
-    TObjArray*              fGeoNodes; //!
     ///Generator used for simulation
     FairPrimaryGenerator*   fPriGen;
     ///Beam momentum (GeV/c)
     Double_t              fBeamMom;
-    /// Full Geometry
-    TGeoManager*            fGeom;
     /// List of parameter container names in the RUN
     TObjArray*              fContNameList;
+    /// Random Seed from gRandom
+    UInt_t                 fRandomSeed;
 
-    ClassDef(FairBaseParSet,4)
+    ClassDef(FairBaseParSet,6)
 
   private:
     FairBaseParSet(const FairBaseParSet& L);
diff --git a/base/sim/FairDetector.cxx b/base/sim/FairDetector.cxx
new file mode 100644
index 0000000..885de09
--- /dev/null
+++ b/base/sim/FairDetector.cxx
@@ -0,0 +1,135 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                    FairDetector source file                   -----
+// -----            Created 06/01/04  by M. Al-Turany/ D. Bertini      -----
+// -------------------------------------------------------------------------
+
+#include "FairDetector.h"
+
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairModule.h"                 // for FairModule::svList, etc
+#include "FairVolume.h"                 // for FairVolume
+
+#include "TFolder.h"                    // for TFolder
+#include "TList.h"                      // for TList
+#include "TObject.h"                    // for TObject
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TRefArray.h"                  // for TRefArray
+#include "TString.h"                    // for TString
+#include "TVirtualMC.h"                 // for TVirtualMC
+
+#include <stddef.h>                     // for NULL
+// -------------------------------------------------------------------------
+
+FairDetector::FairDetector(const char* Name, Bool_t Active, Int_t DetId )
+  :FairModule(Name, "FAIR Detector", Active),
+   fDetId(DetId),
+   fLogger(FairLogger::GetLogger())
+{
+  flGeoPar = new TList();
+  TString lname( GetName());
+  lname += "GeoPar";
+  flGeoPar->SetName(lname.Data());
+  kGeoSaved = kFALSE;
+
+
+}
+// -------------------------------------------------------------------------
+
+FairDetector::FairDetector(const FairDetector& rhs)
+  :FairModule(rhs),
+   fDetId(rhs.fDetId),
+   fLogger(rhs.fLogger)
+{
+}
+// -------------------------------------------------------------------------
+
+FairDetector::~FairDetector()
+{
+
+  if ( flGeoPar ) { delete flGeoPar; }
+
+}
+// -------------------------------------------------------------------------
+
+FairDetector& FairDetector::operator= (const FairDetector& rhs)
+{
+  // check assignment to self
+  if (this == &rhs) return *this;
+
+  // base class assignment
+  FairModule::operator=(rhs);
+
+  // assignment operator
+  fDetId = rhs.fDetId;
+  fLogger = rhs.fLogger;
+
+  return *this;
+}
+
+// -------------------------------------------------------------------------
+
+FairDetector::FairDetector()
+  :fDetId(0),
+   fLogger(FairLogger::GetLogger())
+{
+
+}
+// -------------------------------------------------------------------------
+
+void   FairDetector::Initialize()
+{
+// Registers hits collection in Root manager;
+// sets sensitive volumes.
+// ---
+  Int_t NoOfEntries=svList->GetEntries();
+  Int_t fMCid;
+  FairGeoNode* fN;
+  TString cutName;
+  TString copysign="#";
+  for (Int_t i = 0 ; i < NoOfEntries ; i++ )  {
+    FairVolume* aVol = static_cast<FairVolume*>(svList->At(i));
+    cutName = aVol->GetName();
+    Ssiz_t pos = cutName.Index (copysign, 1);
+    if(pos>1) { cutName.Resize(pos); }
+    if ( aVol->getModId() == GetModId()  ) {
+      fMCid=TVirtualMC::GetMC()->VolId(cutName.Data());
+      aVol->setMCid(fMCid);
+      fN=aVol->getGeoNode();
+      if (fN) { fN->setMCid(fMCid); }
+    }
+  }
+
+}
+// -------------------------------------------------------------------------
+
+void FairDetector::SaveGeoParams()
+{
+
+  if ( ! kGeoSaved  ) {
+    fLogger->Info(MESSAGE_ORIGIN,"Detector: %s Geometry parameters saved ... ", GetName());
+    TFolder* mf = dynamic_cast<TFolder*>(gROOT->FindObjectAny("cbmroot")) ;
+    TFolder* stsf = NULL;
+    if (mf ) { stsf = dynamic_cast<TFolder*> (mf->FindObjectAny(GetName())); }
+    if (stsf) {
+      TFolder* newf = stsf->AddFolder("Parameters","Detector parameters",NULL);
+      newf->Add( flGeoPar ) ;
+    }
+    kGeoSaved = kTRUE;
+  }
+}
+// -------------------------------------------------------------------------
+
+
+ClassImp(FairDetector)
+
+
+
+
diff --git a/base/FairDetector.h b/base/sim/FairDetector.h
similarity index 66%
rename from base/FairDetector.h
rename to base/sim/FairDetector.h
index ca0b62f..ca22c27 100644
--- a/base/FairDetector.h
+++ b/base/sim/FairDetector.h
@@ -1,9 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRDETECTOR_H
 #define FAIRDETECTOR_H
 
-#include "FairModule.h"
+#include "FairModule.h"                 // for FairModule
 
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
 
+class FairLogger;
 class FairVolume;
 class TClonesArray;
 
@@ -16,7 +25,6 @@ class TClonesArray;
 class FairDetector : public FairModule
 {
 
-
   public:
 
     /**
@@ -61,7 +69,7 @@ class FairDetector : public FairModule
     */
     virtual void   Reset()=0;
 
-    virtual void   CopyClones( TClonesArray* cl1,  TClonesArray* cl2 , Int_t offset) {
+    virtual void   CopyClones( TClonesArray*,  TClonesArray*, Int_t) {
       ;
     }
 
@@ -94,16 +102,14 @@ class FairDetector : public FairModule
       return fDetId;
     }
 
-  private:
-    FairDetector(const FairDetector& M);
-    FairDetector& operator= (const FairDetector&) {
-      return *this;
-    }
-
-
   protected:
+    /** Copy constructor */
+    FairDetector(const FairDetector&);
+    /** Assignment operator */
+    FairDetector& operator= (const FairDetector&);
 
     Int_t fDetId; // Detector Id has to be set from ctr.
+    FairLogger* fLogger;  //! /// FairLogger
 
     ClassDef(FairDetector,1)
 
diff --git a/base/sim/FairDoubleHit.cxx b/base/sim/FairDoubleHit.cxx
new file mode 100644
index 0000000..1b8b841
--- /dev/null
+++ b/base/sim/FairDoubleHit.cxx
@@ -0,0 +1,30 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/* Generated by Together */
+
+#include "FairDoubleHit.h"
+
+FairDoubleHit::FairDoubleHit():
+  fRefIndex(-1),
+  fDetectorID(-1),
+  fPosition_in(),
+  fPositionError_in(),
+  fPosition_out(),
+  fPositionError_out()
+{
+
+}
+
+FairDoubleHit::~FairDoubleHit()
+{
+
+}
+
+ClassImp(FairDoubleHit)
+
+
diff --git a/base/FairDoubleHit.h b/base/sim/FairDoubleHit.h
similarity index 72%
rename from base/FairDoubleHit.h
rename to base/sim/FairDoubleHit.h
index 78d30b4..e6cbf3c 100644
--- a/base/FairDoubleHit.h
+++ b/base/sim/FairDoubleHit.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /* Generated by Together */
 
 #ifndef FAIRDOUBLEHIT_H
diff --git a/base/FairGeaneApplication.cxx b/base/sim/FairGeaneApplication.cxx
similarity index 61%
rename from base/FairGeaneApplication.cxx
rename to base/sim/FairGeaneApplication.cxx
index 7b987ee..c475d2d 100644
--- a/base/FairGeaneApplication.cxx
+++ b/base/sim/FairGeaneApplication.cxx
@@ -1,16 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                    FairGeaneApplication source file           -----
 // -----                   Created 10/11/10  by M. Al-Turany           -----
 // -------------------------------------------------------------------------
 
-
 #include "FairGeaneApplication.h"
-#include "FairField.h"
 
-#include "TVirtualMC.h"
-#include "TGeoManager.h"
+#include "FairField.h"                  // for FairField
+
+#include "TVirtualMC.h"                 // for  TVirtualMC
 
-#include <iostream>
+#include <stdio.h>                      // for printf
+#include <iostream>                     // for cout, endl
 
 using std::cout;
 using std::endl;
@@ -40,28 +47,24 @@ FairGeaneApplication::FairGeaneApplication(Bool_t Debug)
 FairGeaneApplication::~FairGeaneApplication()
 {
 // Destructor
-  delete gMC;
-  gMC=0;
 }
 //_____________________________________________________________________________
 
 //_____________________________________________________________________________
 void FairGeaneApplication::ConstructGeometry()
 {
-  gMC->SetRootGeometry();  // notify VMC about Root geometry
+  TVirtualMC::GetMC()->SetRootGeometry();  // notify VMC about Root geometry
 }
 
-void FairGeaneApplication::InitMC(const char* setup, const char* cuts)
+void FairGeaneApplication::InitMC(const char*, const char*)
 {
 // Initialize MC.
 
-  gMC->Init();
-  gMC->BuildPhysics();
+  TVirtualMC::GetMC()->Init();
+  TVirtualMC::GetMC()->BuildPhysics();
   fMcVersion = 3;  //Geane
 
-#if ROOT_VERSION_CODE >= 333824
-  gMC->SetMagField(fxField);
-#endif
+  TVirtualMC::GetMC()->SetMagField(fxField);
 }
 //_____________________________________________________________________________
 void FairGeaneApplication::GeaneStepping()
@@ -70,31 +73,14 @@ void FairGeaneApplication::GeaneStepping()
 // ---
   if (fDebug) {
     printf(" FairGeaneApplication::GeaneStepping() \n");
-    gMC->TrackPosition(fTrkPos);
+    TVirtualMC::GetMC()->TrackPosition(fTrkPos);
     printf(" Track Position: x = %f   y= %f    z= %f \n  ", fTrkPos.X(), fTrkPos.Y(), fTrkPos.Z());
-    printf(" Current Volume name: %s \n", gMC->CurrentVolName());
+    printf(" Current Volume name: %s \n", TVirtualMC::GetMC()->CurrentVolName());
     Int_t copyNo;
-    Int_t id = gMC->CurrentVolID(copyNo);
+    Int_t id = TVirtualMC::GetMC()->CurrentVolID(copyNo);
     printf(" Current Volume id = %i  , CopyNo = %i \n", id, copyNo);
   }
 }
-
-#if ROOT_VERSION_CODE < 333824
-//_____________________________________________________________________________
-void FairGeaneApplication::Field(const Double_t* x, Double_t* b) const
-{
-// put here a const magnetic field as 0th approx
-// ---
-// cout<< "FairGeaneApplication::Field" <<endl;
-  b[0]=0;
-  b[1]=0;
-  b[2]=0;
-  if(fxField) {
-    fxField->GetFieldValue(x,b);
-//     cout << " FairGeaneApplication::Field the old way of getting field " << endl;
-  }
-}
-#endif
 //_____________________________________________________________________________
 void FairGeaneApplication::SetField(FairField* field)
 {
diff --git a/base/FairGeaneApplication.h b/base/sim/FairGeaneApplication.h
similarity index 74%
rename from base/FairGeaneApplication.h
rename to base/sim/FairGeaneApplication.h
index 8e7e70c..e17cfff 100644
--- a/base/FairGeaneApplication.h
+++ b/base/sim/FairGeaneApplication.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----               FairGeaneApplication header file                   -----
 // -----            Created 10/11/10  by M. Al-Turany                  -----
@@ -6,15 +13,13 @@
 #ifndef FAIR_GEANE_APPLICATION_H
 #define FAIR_GEANE_APPLICATION_H
 
+#include "TVirtualMCApplication.h"      // for TVirtualMCApplication
 
-#include "TVirtualMCApplication.h"
-#include "TLorentzVector.h"
-#include "FairTask.h"
+#include "RVersion.h"                   // for ROOT_VERSION_CODE
+#include "Rtypes.h"                     // for Bool_t, etc
+#include "TLorentzVector.h"             // for TLorentzVector
 
 class FairField;
-class FairPrimaryGenerator;
-class TTask;
-
 
 /**
  * The Main Application for GEANE
@@ -86,6 +91,6 @@ class FairGeaneApplication : public TVirtualMCApplication
 // inline functions
 
 inline FairGeaneApplication* FairGeaneApplication::Instance()
-{ return (FairGeaneApplication*)(TVirtualMCApplication::Instance());}
+{ return static_cast<FairGeaneApplication*>(TVirtualMCApplication::Instance());}
 
 #endif
diff --git a/base/sim/FairGenerator.cxx b/base/sim/FairGenerator.cxx
new file mode 100644
index 0000000..809f7a9
--- /dev/null
+++ b/base/sim/FairGenerator.cxx
@@ -0,0 +1,58 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                     FairGenerator source file                 -----
+// -------------------------------------------------------------------------
+
+
+#include "FairGenerator.h"
+
+
+// -----   Default constructor   -------------------------------------------
+FairGenerator::FairGenerator()
+  : TNamed() {}
+// -------------------------------------------------------------------------
+
+
+
+// -----   Constructor with name and title   -------------------------------
+FairGenerator::FairGenerator(const char* name, const char* title)
+  : TNamed(name, title) {}
+// -------------------------------------------------------------------------
+
+
+// -----   Copy constructor ------------------------------------------------
+FairGenerator::FairGenerator(const FairGenerator& rhs)
+  : TNamed(rhs) {}
+// -------------------------------------------------------------------------
+
+
+// -----   Destructor   ----------------------------------------------------
+FairGenerator::~FairGenerator() { }
+// -------------------------------------------------------------------------
+
+// -----   Assignment   ----------------------------------------------------
+FairGenerator& FairGenerator::operator= (const FairGenerator& rhs)
+{
+  // check assignment to self
+  if (this == &rhs) return *this;
+
+  // base class assignment
+  TNamed::operator=(rhs);
+
+  return *this;
+}
+
+// -----   Clone this object   ---------------------------------------------
+FairGenerator* FairGenerator::CloneGenerator() const
+{
+  Fatal("CloneGenerator","Has to be overriden in multi-threading applications.");
+  return 0;
+}
+
+ClassImp(FairGenerator)
diff --git a/base/FairGenerator.h b/base/sim/FairGenerator.h
similarity index 62%
rename from base/FairGenerator.h
rename to base/sim/FairGenerator.h
index f42fb0f..7a49ef8 100644
--- a/base/FairGenerator.h
+++ b/base/sim/FairGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                    FairGenerator header file                   -----
 // -----          Created 09/06/04  by D. Bertini / V. Friese          -----
@@ -18,10 +25,11 @@ which has to use the method FairPrimaryGenerator::AddTrack.
 #ifndef FAIRGENERATOR_H
 #define FAIRGENERATOR_H
 
-#include "TNamed.h"
+#include "TNamed.h"                     // for TNamed
 
-class FairPrimaryGenerator;
+#include "Rtypes.h"                     // for Bool_t, etc
 
+class FairPrimaryGenerator;
 
 class FairGenerator : public TNamed
 {
@@ -53,13 +61,16 @@ class FairGenerator : public TNamed
     /**Initialize the generator if needed */
     virtual Bool_t Init() { return kTRUE;}
 
-    ClassDef(FairGenerator,1);
-
-  private:
-    FairGenerator(const FairGenerator& G);
-    FairGenerator& operator= (const FairGenerator&) {return *this;}
+    /** Clone this object (used in MT mode only) */
+    virtual FairGenerator* CloneGenerator() const;
 
+  protected:
+    /** Copy constructor */
+    FairGenerator(const FairGenerator&);
+    /** Assignment operator */
+    FairGenerator& operator= (const FairGenerator&);
 
+    ClassDef(FairGenerator,1);
 };
 
 #endif
diff --git a/base/FairGenericStack.cxx b/base/sim/FairGenericStack.cxx
similarity index 55%
rename from base/FairGenericStack.cxx
rename to base/sim/FairGenericStack.cxx
index 0124f35..141d0c4 100644
--- a/base/FairGenericStack.cxx
+++ b/base/sim/FairGenericStack.cxx
@@ -1,36 +1,34 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairGenericStack source file                    -----
 // -----             Created 10/08/04  by D. Bertini                   -----
 // -------------------------------------------------------------------------
 #include "FairGenericStack.h"
-
-#include "FairDetector.h"
-#include "FairRootManager.h"
-#include "FairMCPoint.h"
-
-#include "TError.h"
-#include "TLorentzVector.h"
-#include "TParticle.h"
+#include "FairLogger.h"                 // for FairLogger
 #include "TRefArray.h"
-//#include "TClonesArray.h"
-
-//#include <map>
-//#include <stack>
-//#include <iostream>
-
 
 // -----   Default constructor   -------------------------------------------
 FairGenericStack::FairGenericStack()
   : TVirtualMCStack(),
     fLogger(FairLogger::GetLogger()),
+    fDetList(0),
+    fDetIter(0),
     fVerbose(1)
 {
 }
 // -------------------------------------------------------------------------
 // -----   Constructor with estimated array dimension   --------------------
-FairGenericStack::FairGenericStack(Int_t size)
+FairGenericStack::FairGenericStack(Int_t)
   : TVirtualMCStack(),
     fLogger(FairLogger::GetLogger()),
+    fDetList(0),
+    fDetIter(0),
     fVerbose(1)
 {
 }
@@ -39,43 +37,79 @@ FairGenericStack::FairGenericStack(Int_t size)
 FairGenericStack::~FairGenericStack()
 {
 }
+// -------------------------------------------------------------------------
+// -----   Copy constructor   ----------------------------------------------
+FairGenericStack::FairGenericStack(const FairGenericStack& rhs)
+  : TVirtualMCStack(rhs),
+    fLogger(0),
+    fDetList(0),
+    fDetIter(0),
+    fVerbose(rhs.fVerbose)
+{
+}
+
+// -------------------------------------------------------------------------
+// -----   Assignment operator   -------------------------------------------
+FairGenericStack& FairGenericStack::operator=(const FairGenericStack& rhs)
+{
+  // check assignment to self
+  if (this == &rhs) return *this;
+
+  // base class assignment
+  TVirtualMCStack::operator=(rhs);
+
+  // assignment oiperator
+  fLogger = 0;
+  fDetList = 0;
+  fDetIter = 0;
+  fVerbose = rhs.fVerbose;
+
+  return *this;
+}
+
 // -------------------------------------------------------------------------
 // -----   Virtual method PushTrack   --------------------------------------
-void FairGenericStack::PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode,
-                                 Double_t px, Double_t py, Double_t pz,
-                                 Double_t e, Double_t vx, Double_t vy, Double_t vz,
-                                 Double_t time, Double_t polx, Double_t poly,
-                                 Double_t polz, TMCProcess proc, Int_t& ntr,
-                                 Double_t weight, Int_t is)
+void FairGenericStack::PushTrack(Int_t, Int_t, Int_t,
+                                 Double_t, Double_t, Double_t,
+                                 Double_t, Double_t, Double_t, Double_t,
+                                 Double_t, Double_t, Double_t,
+                                 Double_t, TMCProcess, Int_t&,
+                                 Double_t, Int_t)
 {
 
 }
 
-void FairGenericStack::PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode,
-                                 Double_t px, Double_t py, Double_t pz,
-                                 Double_t e, Double_t vx, Double_t vy, Double_t vz,
-                                 Double_t time, Double_t polx, Double_t poly,
-                                 Double_t polz, TMCProcess proc, Int_t& ntr,
-                                 Double_t weight, Int_t is, Int_t secondMotherID)
+void FairGenericStack::PushTrack(Int_t, Int_t, Int_t,
+                                 Double_t, Double_t, Double_t,
+                                 Double_t, Double_t, Double_t, Double_t,
+                                 Double_t, Double_t, Double_t,
+                                 Double_t, TMCProcess, Int_t&,
+                                 Double_t, Int_t, Int_t)
 {
 
 }
 // -----   Virtual method PopNextTrack   -----------------------------------
-TParticle* FairGenericStack::PopNextTrack(Int_t& iTrack)
+TParticle* FairGenericStack::PopNextTrack(Int_t&)
 {
   return 0;
 }
 // -------------------------------------------------------------------------
 // -----   Virtual method PopPrimaryForTracking   --------------------------
-TParticle* FairGenericStack::PopPrimaryForTracking(Int_t iPrim)
+TParticle* FairGenericStack::PopPrimaryForTracking(Int_t)
 {
   return 0;
 }
 // -------------------------------------------------------------------------
 // -----   Public method AddParticle   -------------------------------------
-void FairGenericStack::AddParticle(TParticle* oldPart)
+void FairGenericStack::AddParticle(TParticle*)
 {
 }
+// -----   Public method SetDetArrayList  ----------------------------------
+void FairGenericStack::SetDetArrayList(TRefArray* detArray)
+{
+  fDetList=detArray;
+  if(fDetList!=0) { fDetIter=fDetList->MakeIterator(); }
+}
 // -------------------------------------------------------------------------
 // -----   Public method FillTrackArray   ----------------------------------
 void FairGenericStack::FillTrackArray()
@@ -83,7 +117,7 @@ void FairGenericStack::FillTrackArray()
 }
 // -------------------------------------------------------------------------
 // -----   Public method UpdateTrackIndex   --------------------------------
-void FairGenericStack::UpdateTrackIndex(TRefArray* detList)
+void FairGenericStack::UpdateTrackIndex(TRefArray*)
 {
 
 }
@@ -99,12 +133,12 @@ void FairGenericStack::Register()
 }
 // -------------------------------------------------------------------------
 // -----   Public method Print  --------------------------------------------
-void FairGenericStack::Print(Int_t iVerbose) const
+void FairGenericStack::Print(Option_t*) const
 {
 }
 // -------------------------------------------------------------------------
 // -----   Virtual method SetCurrentTrack   --------------------------------
-void FairGenericStack::SetCurrentTrack(Int_t iTrack)
+void FairGenericStack::SetCurrentTrack(Int_t)
 {
 }
 // -------------------------------------------------------------------------
@@ -137,5 +171,14 @@ Int_t FairGenericStack::GetCurrentParentTrackNumber() const
 {
   return 0;
 }
+
+// -------------------------------------------------------------------------
+// -----   Virtual method  CloneStack  -------------------------------------
+FairGenericStack* FairGenericStack::CloneStack() const
+{
+  Fatal("CloneStack","Has to be overriden in multi-threading applications.");
+  return 0;
+}
+
 // -------------------------------------------------------------------------
 ClassImp(FairGenericStack)
diff --git a/base/FairGenericStack.h b/base/sim/FairGenericStack.h
similarity index 62%
rename from base/FairGenericStack.h
rename to base/sim/FairGenericStack.h
index d1b2894..ac41e1b 100644
--- a/base/FairGenericStack.h
+++ b/base/sim/FairGenericStack.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairStack header file                    -----
 // -----           Created 10/08/04  by D. Bertini                     -----
@@ -13,17 +20,18 @@
 #ifndef FAIRGENERICSTACK_H
 #define FAIRGENERICSTACK_H
 
+#include "TClonesArray.h" 
+#include "TVirtualMCStack.h"            // for TVirtualMCStack
 
-//#include <map>
-//#include <stack>
-//#include <iostream>
-//#include "TClonesArray.h"
-#include "TVirtualMCStack.h"
-#include "FairLogger.h"
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TMCProcess.h"                 // for TMCProcess
 
+#include <stddef.h>                     // for NULL
 
+class FairLogger;
 class TParticle;
 class TRefArray;
+class TIterator;
 
 
 class FairGenericStack : public TVirtualMCStack
@@ -64,6 +72,23 @@ class FairGenericStack : public TVirtualMCStack
                            Double_t poly, Double_t polz, TMCProcess proc,
                            Int_t& ntr, Double_t weight, Int_t is);
 
+    /** Virtual method PushTrack.
+     ** Add a TParticle to the stack.
+     *@param toBeDone         Flag for tracking
+     *@param parentID         Index of mother particle
+     *@param pdgCode          Particle type (PDG encoding)
+     *@param px,py,pz         Momentum components at start vertex [GeV]
+     *@param e                Total energy at start vertex [GeV]
+     *@param vx,vy,vz         Coordinates of start vertex [cm]
+     *@param time             Start time of track [s]
+     *@param polx,poly,polz   Polarisation vector
+     *@param proc             Production mechanism (VMC encoding)
+     *@param ntr              Track number (filled by the stack)
+     *@param weight           Particle weight
+     *@param is               Generation status code (whatever that means)
+     *@param secondparentID   used fot the index of mother of primery in the list
+     **/
+
     virtual void PushTrack(Int_t toBeDone, Int_t parentID, Int_t pdgCode,
                            Double_t px, Double_t py, Double_t pz,
                            Double_t e, Double_t vx, Double_t vy,
@@ -97,9 +122,12 @@ class FairGenericStack : public TVirtualMCStack
 
 
     /** Update the track index in the MCTracks and MCPoints **/
-    virtual void UpdateTrackIndex(TRefArray* detArray);
+    virtual void UpdateTrackIndex(TRefArray* detArray=0);
 
 
+    /** Set the list of detectors to be used for filltering the stack*/
+    void SetDetArrayList(TRefArray* detArray);
+
     /** Resets arrays and stack and deletes particles and tracks **/
     virtual void Reset();
 
@@ -111,16 +139,11 @@ class FairGenericStack : public TVirtualMCStack
     /** Output to screen
      **@param iVerbose: 0=events summary, 1=track info
      **/
-    virtual void Print(Int_t iVerbose=0) const;
+    virtual void Print(Option_t* option="") const;
 
 
     /** Modifiers  **/
     virtual void SetCurrentTrack(Int_t iTrack);
-    /*  void StoreSecondaries(Bool_t choice = kTRUE) { fStoreSecondaries = choice; }
-      void SetMinPoints(Int_t min)                 { fMinPoints        = min;    }
-      void SetEnergyCut(Double_t eMin)             { fEnergyCut        = eMin;   }
-      void StoreMothers(Bool_t choice = kTRUE)     { fStoreMothers     = choice; }
-    */
 
     /** Accessors **/
     virtual Int_t GetNtrack() const;   // Total number of tracks
@@ -128,18 +151,30 @@ class FairGenericStack : public TVirtualMCStack
     virtual TParticle* GetCurrentTrack() const;
     virtual Int_t GetCurrentTrackNumber() const;
     virtual Int_t GetCurrentParentTrackNumber() const;
-    virtual TParticle* GetParticle(Int_t trackID) const { return NULL; }
+    virtual TParticle* GetParticle(Int_t) const { return NULL; }
+
+    virtual TClonesArray* GetListOfParticles() { return NULL; } 
 
+    /** Clone this object (used in MT mode only) */
+    virtual FairGenericStack* CloneStack() const;
 
   protected:
+    /** Copy constructor */
+    FairGenericStack(const FairGenericStack&);
+    /** Assignment operator */
+    FairGenericStack& operator=(const FairGenericStack&);
+
     /** Fair Logger */
     FairLogger*            fLogger;//!
 
-    Int_t fVerbose;
+    /** List of detectors registering hits in the simulation */
+    TRefArray*  fDetList;  //!
 
-  private:
-    FairGenericStack(const FairGenericStack&);
-    FairGenericStack& operator=(const FairGenericStack&);
+    /** Iterator for the detector list*/
+    TIterator* fDetIter;
+
+    /**Verbosity level*/
+    Int_t fVerbose;
 
     ClassDef(FairGenericStack,1)
 
diff --git a/base/sim/FairGeoParSet.cxx b/base/sim/FairGeoParSet.cxx
new file mode 100644
index 0000000..33b1ab6
--- /dev/null
+++ b/base/sim/FairGeoParSet.cxx
@@ -0,0 +1,56 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                       FairGeoParSet source file              -----
+// -----                Created 06/06/13  by M. Al/Turany              -----
+// -------------------------------------------------------------------------
+
+#include "FairGeoParSet.h"
+#include "TGeoManager.h"                // for TGeoManager
+#include "TObjArray.h"                  // for TObjArray
+#include "FairParamList.h"              // for FairParamList
+
+ClassImp(FairGeoParSet)
+
+FairGeoParSet::FairGeoParSet(const char* name,const char* title,const char* context)
+  : FairParGenericSet(name,title,context),
+    fGeoNodes(new TObjArray()),
+    fGeom(0)
+{
+
+
+}
+
+
+FairGeoParSet::~FairGeoParSet(void)
+{
+}
+
+void FairGeoParSet::clear(void)
+{
+  //if(fGeoNodes) { delete fGeoNodes; }
+// if(fGeom ) delete fGeom;
+
+}
+
+void FairGeoParSet::putParams(FairParamList* l)
+{
+  if (!l) { return; }
+  l->addObject("FairGeoNodes List", fGeoNodes);
+  l->addObject("Detector Geometry", fGeom);
+}
+
+Bool_t FairGeoParSet::getParams(FairParamList* l)
+{
+  if (!l) { return kFALSE; }
+  if (!l->fillObject("FairGeoNodes List", fGeoNodes)) { return kFALSE; }
+  if (!l->fillObject("Detector Geometry", fGeom)) { return kFALSE; }
+  return kTRUE;
+}
+
+
diff --git a/base/sim/FairGeoParSet.h b/base/sim/FairGeoParSet.h
new file mode 100644
index 0000000..4e79551
--- /dev/null
+++ b/base/sim/FairGeoParSet.h
@@ -0,0 +1,89 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FairGeoParSet_H
+#define FairGeoParSet_H
+
+/**
+ * Parameter class for Geometry stuff
+ * @author M. Al-Turany
+ * @version 1
+ * @since 12.10.04
+ */
+#include "FairParGenericSet.h"          // for FairParGenericSet
+#include "Rtypes.h"                     // for Double_t, etc
+#include "TGeoManager.h"                // IWYU pragma: keep needed by cint
+
+class FairParamList;
+class TObjArray;
+
+class FairGeoParSet : public FairParGenericSet
+{
+  public:
+    /**
+     * constructor
+     * @param name :  Parameter set name
+    * @param title:  Parameter set title
+    * @param context:  Parameter set context
+    */
+
+
+    FairGeoParSet(const char* name="FairGeoParSet",
+                  const char* title="Class for base parameter io",
+                  const char* context="BaseDefaultContext");
+    /** dtor*/
+    ~FairGeoParSet(void);
+    /** clear*/
+    void clear(void);
+    /**
+     * Fills all persistent data members into the list for write.
+     * @param FairParamList : Parameter list to be filled
+    */
+    void putParams(FairParamList*);
+    /**
+     * Fills all persistent data members from the list after reading. The function
+     * returns false, when a data member is not in the list.
+     * @param FairParamList : Parameter list to be filled
+     */
+
+    Bool_t getParams(FairParamList*);
+    /**
+     * Set the Geometry node list used in the simulation
+     * @param array: TObjArray of Geometry nodes
+     */
+    void SetGeoNodes(TObjArray* array) {fGeoNodes=array;}
+    /**
+     * Set the Geometry (TGeoManager) used in the simulation
+     * @param Geom: TGeoManager of the full geometry
+     */
+    void SetGeometry(TGeoManager* Geom) {fGeom=Geom;}
+    /**
+    *  Get the Geometry Nodes list used in the simulation
+    */
+    TObjArray*             GetGeoNodes() {return fGeoNodes;}
+    /**
+     *  Get the geometry (TGeoManager) used in the simulation
+     */
+    TGeoManager*           GetGeometry() {return fGeom;}
+
+  protected:
+
+    /// List of FairGeoNodes for sensitive volumes
+    TObjArray*              fGeoNodes; //!
+    /// Full Geometry
+    TGeoManager*            fGeom;
+    ClassDef(FairGeoParSet,1)
+
+  private:
+    FairGeoParSet(const FairGeoParSet& L);
+    FairGeoParSet& operator= (const FairGeoParSet&) {return *this;}
+
+
+
+};
+
+#endif /* !FairGeoParSet_H */
diff --git a/base/FairIon.cxx b/base/sim/FairIon.cxx
similarity index 61%
rename from base/FairIon.cxx
rename to base/sim/FairIon.cxx
index 48b927e..002607c 100644
--- a/base/FairIon.cxx
+++ b/base/sim/FairIon.cxx
@@ -1,15 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                         FairIon source file                    -----
 // -------------------------------------------------------------------------
 #include "FairIon.h"
+#include "FairLogger.h"
 
-#include <iostream>
 #include "TDatabasePDG.h"
 #include "TParticlePDG.h"
 
-using std::cout;
-using std::endl;
-
 const Double_t FairIon::amu=0.931494028 ; // Gev/c**2
 
 
@@ -20,7 +24,8 @@ FairIon::FairIon()
    fA(0),
    fQ(0),
    fExcEnergy(0),
-   fMass(0)
+   fMass(0),
+   fLogger(FairLogger::GetLogger())
 {
 
 }
@@ -35,7 +40,8 @@ FairIon::FairIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t e,
     fA(a),
     fQ(q),
     fExcEnergy(e),
-    fMass(0)
+    fMass(0),
+    fLogger(FairLogger::GetLogger())
 {
 
   TDatabasePDG* pdgDB = TDatabasePDG::Instance();
@@ -44,15 +50,16 @@ FairIon::FairIon(const char* name, Int_t z, Int_t a, Int_t q, Double_t e,
 
   if (mass == 0.) { fMass = kProtonMass * Double_t(a); }
   else { fMass = mass; }
-  cout << "-I- FairIon: New ion " << name << ", z = " <<  z << ", a = "
-       << a << ", charge = " << q << ", mass = " << fMass << " GeV "
-       << endl;
+  fLogger->Info(MESSAGE_ORIGIN, "New Ion %s Z=%d  A=%d  Charge=%d  Mass=%0.7f GeV ", name, z, a , q, fMass);
+
 }
 // -------------------------------------------------------------------------
 
 
 // -----   Destructor   ----------------------------------------------------
-FairIon::~FairIon() {};
+FairIon::~FairIon()
+{
+};
 // -------------------------------------------------------------------------
 
 
diff --git a/base/FairIon.h b/base/sim/FairIon.h
similarity index 74%
rename from base/FairIon.h
rename to base/sim/FairIon.h
index 0fbb190..93b7c4c 100644
--- a/base/FairIon.h
+++ b/base/sim/FairIon.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                       FairIon header file                      -----
 // -----          Created 27/08/04  by V. Friese / D.Bertini           -----
@@ -15,7 +22,11 @@
 #ifndef FAIRION_H
 #define FAIRION_H
 
-#include "TNamed.h"
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Int_t, Double_t, etc
+
+class FairLogger;
 
 class FairIon: public TNamed
 {
@@ -92,10 +103,13 @@ class FairIon: public TNamed
     Int_t    fQ;          /// Electric charge
     Double_t fExcEnergy;  /// Excitation energy [GeV]
     Double_t fMass;       /// Mass [GeV]
-
+    FairLogger* fLogger;  //! /// FairLogger
     static const Double_t amu; ///  .931494028 Gev/c**2
 
-    ClassDef(FairIon,1);
+    FairIon(const FairIon&);
+    FairIon& operator=(const FairIon&);
+
+    ClassDef(FairIon,2);
 
 };
 
diff --git a/base/sim/FairMCApplication.cxx b/base/sim/FairMCApplication.cxx
new file mode 100644
index 0000000..b441f1e
--- /dev/null
+++ b/base/sim/FairMCApplication.cxx
@@ -0,0 +1,1394 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----               FairMCApplication source file                   -----
+// -----            Created 06/01/04  by M. Al-Turany                  -----
+// -------------------------------------------------------------------------
+#include "FairMCApplication.h"
+
+#include "FairDetector.h"               // for FairDetector
+#include "FairField.h"                  // for FairField
+#include "FairGenericStack.h"           // for FairGenericStack
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairIon.h"                    // for FairIon
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairMCEventHeader.h"          // for FairMCEventHeader
+#include "FairMesh.h"                   // for FairMesh
+#include "FairModule.h"                 // for FairModule, etc
+#include "FairParticle.h"               // for FairParticle
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairRadGridManager.h"         // for FairRadGridManager
+#include "FairRadLenManager.h"          // for FairRadLenManager
+#include "FairRadMapManager.h"          // for FairRadMapManager
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRun.h"                    // for FairRun
+#include "FairRunInfo.h"                // for FairRunInfo
+#include "FairRunSim.h"                 // for FairRunSim
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairTask.h"                   // for FairTask
+#include "FairTrajFilter.h"             // for FairTrajFilter
+#include "FairVolume.h"                 // for FairVolume
+
+#include "Riosfwd.h"                    // for ostream
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TDirectory.h"                 // for TDirectory, gDirectory
+#include "TGeoManager.h"                // for gGeoManager, TGeoManager
+#include "TGeoMedium.h"                 // for TGeoMedium
+#include "TGeoNode.h"                   // for TGeoNode
+#include "TGeoPhysicalNode.h"           // for TGeoPhysicalNode
+#include "TGeoTrack.h"                  // for TGeoTrack
+#include "TGeoVolume.h"                 // for TGeoVolume
+#include "TH2.h"                        // for TH2D
+#include "TInterpreter.h"               // for TInterpreter, gInterpreter
+#include "TIterator.h"                  // for TIterator
+#include "TList.h"                      // for TList, TListIter
+#include "TObjArray.h"                  // for TObjArray
+#include "TObject.h"                    // for TObject
+#include "TParticlePDG.h"               // for TParticlePDG
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TRefArray.h"                  // for TRefArray
+#include "TSystem.h"                    // for TSystem, gSystem
+#include "TTree.h"                      // for TTree
+#include "TVirtualMC.h"                 // for TVirtualMC
+#include "TVirtualMCStack.h"            // for TVirtualMCStack
+#include "THashList.h"
+class TParticle;
+
+#include <float.h>                      // for DBL_MAX
+#include <stdlib.h>                     // for NULL, getenv, exit
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <utility>                      // for pair
+
+using std::pair;
+//_____________________________________________________________________________
+FairMCApplication::FairMCApplication(const char* name, const char* title,
+                                     TObjArray* ModList, const char*)
+  :TVirtualMCApplication(name,title),
+   fActiveDetectors(NULL),
+   fFairTaskList(NULL),
+   fDetectors(NULL),
+   fDetMap(NULL),
+   fModIter(NULL),
+   fModules(NULL),
+   fNoSenVolumes(0),
+   fPythiaDecayer(kFALSE),
+   fPythiaDecayerConfig(""),
+   fStack(NULL),
+   fRootManager(NULL),
+   fSenVolumes(NULL),
+   fxField(NULL),
+   fEvGen(NULL),
+   fMcVersion(-1),
+   fTrajFilter(NULL),
+   fTrajAccepted(kFALSE),
+   fUserDecay(kFALSE),
+   fUserDecayConfig(""),
+   fDebug(kFALSE),
+   fDisVol(NULL),
+   fDisDet(NULL),
+   fVolMap(),
+   fVolIter(),
+   fModVolMap(),
+   fModVolIter(),
+   fTrkPos(TLorentzVector(0,0,0,0)),
+   fRadLength(kFALSE),
+   fRadLenMan(NULL),
+   fRadMap(kFALSE),
+   fRadMapMan(NULL),
+   fRadGridMan(NULL),
+   fEventHeader(NULL),
+   fMCEventHeader(NULL),
+   listActiveDetectors(),
+   listDetectors(),
+   fRunInfo(),
+   fGeometryIsInitialized(kFALSE)
+{
+// Standard Simulation constructor
+// Check if the Fair root manager exist!
+  fRootManager=FairRootManager::Instance();
+// Create an ObjArray of Modules and its iterator
+  fModules=ModList;
+  fModIter = fModules->MakeIterator();
+// Create and fill a list of active detectors
+  fDetectors=new TRefArray;
+  fActiveDetectors=new TRefArray();
+  fModIter->Reset();
+  FairDetector* detector;
+  TObject* obj;
+ 
+  while((obj=fModIter->Next())) {
+    if(obj->InheritsFrom("FairDetector")) {
+      detector=dynamic_cast<FairDetector*>(obj);
+      if(detector) {
+	fDetectors->Add(detector);
+	listDetectors.push_back(detector);
+	if(detector->IsActive()) {
+	  fActiveDetectors->Add(detector);
+	  listActiveDetectors.push_back(detector);
+	}
+      } else {
+	LOG(ERROR) << "Dynamic cast fails." << FairLogger::endl;
+      }
+    }
+  }
+  
+// Create a Task list
+  fFairTaskList= new FairTask("Task List", 1);
+  gROOT->GetListOfBrowsables()->Add(fFairTaskList);
+  fMcVersion=-1;
+  // Initialise fTrajFilter pointer
+  fTrajFilter = NULL;
+  fDetMap=new TRefArray(1000);
+  fDisVol=0;
+  fDisDet=0;
+
+}
+
+//_____________________________________________________________________________
+FairMCApplication::FairMCApplication(const FairMCApplication& rhs)
+  :TVirtualMCApplication(rhs.GetName(),rhs.GetTitle()),
+   fActiveDetectors(NULL),
+   fFairTaskList(NULL),
+   fDetectors(NULL),
+   fDetMap(NULL),
+   fModIter(NULL),
+   fModules(NULL),
+   fNoSenVolumes(0),
+   fPythiaDecayer(kFALSE),
+   fPythiaDecayerConfig(rhs.fPythiaDecayerConfig),
+   fStack(NULL),
+   fRootManager(NULL),
+   fSenVolumes(NULL),
+   fxField(rhs.fxField),
+   fEvGen(NULL),
+   fMcVersion(rhs.fMcVersion),
+   fTrajFilter(NULL),
+   fTrajAccepted(kFALSE),
+   fUserDecay(kFALSE),
+   fUserDecayConfig(rhs.fUserDecayConfig),
+   fDebug(rhs.fDebug),
+   fDisVol(NULL),
+   fDisDet(NULL),
+   fVolMap(),
+   fVolIter(),
+   fModVolMap(),
+   fModVolIter(),
+   fTrkPos(rhs.fTrkPos),
+   fRadLength(kFALSE),
+   fRadLenMan(NULL),
+   fRadMap(kFALSE),
+   fRadMapMan(NULL),
+   fRadGridMan(NULL),
+   fEventHeader(NULL),
+   fMCEventHeader(NULL),
+   listActiveDetectors(),
+   listDetectors(),
+   fRunInfo(),
+   fGeometryIsInitialized(kFALSE)
+{
+// Copy constructor
+// Do not create Root manager
+
+// Create an ObjArray of Modules and its iterator
+  fModules=new TObjArray();
+  fModIter = fModules->MakeIterator();
+  // Clone modules
+  TObject* obj;
+  while((obj=rhs.fModIter->Next())) {
+    fModules->Add(static_cast<FairModule*>(obj)->CloneModule());
+  }
+
+// Create and fill a list of active detectors
+  fDetectors=new TRefArray;
+  fActiveDetectors=new TRefArray();
+  fModIter->Reset();
+  FairDetector* detector;
+  while((obj=fModIter->Next())) {
+    if(obj->InheritsFrom("FairDetector")) {
+      detector=dynamic_cast<FairDetector*>(obj);
+      if(detector) {
+	fDetectors->Add(detector);
+	listDetectors.push_back(detector);
+	if(detector->IsActive()) {
+	  fActiveDetectors->Add(detector);
+	  listActiveDetectors.push_back(detector);
+	}
+      } else {
+          LOG(ERROR) << "Dynamic cast fails." << FairLogger::endl;
+      }
+    }
+  }
+   // Clone stack
+  fStack = rhs.fStack->CloneStack();
+
+// Create a Task list
+  // Let's try without it
+  //fFairTaskList= new FairTask("Task List", 1);
+  //gROOT->GetListOfBrowsables()->Add(fFairTaskList);
+
+  fDetMap=new TRefArray(1000);
+}
+//_____________________________________________________________________________
+FairMCApplication::FairMCApplication()
+  :TVirtualMCApplication(),
+   fActiveDetectors(0),
+   fFairTaskList(0),
+   fDetectors(0),
+   fDetMap(0),
+   fModIter(0),
+   fModules(0),
+   fNoSenVolumes(0),
+   fPythiaDecayer(kFALSE),
+   fPythiaDecayerConfig(""),
+   fStack(0),
+   fRootManager(0),
+   fSenVolumes(0),
+   fxField(0),
+   fEvGen(0),
+   fMcVersion(-1),
+   fTrajFilter(NULL),
+   fTrajAccepted(kFALSE),
+   fUserDecay(kFALSE),
+   fUserDecayConfig(""),
+   fDebug(kFALSE),
+   fDisVol(0),
+   fDisDet(0),
+   fVolMap(),
+   fVolIter(),
+   fModVolMap(),
+   fModVolIter(),
+   fTrkPos(TLorentzVector(0,0,0,0)),
+   fRadLength(kFALSE),
+   fRadLenMan(NULL),
+   fRadMap(kFALSE),
+   fRadMapMan(NULL),
+   fRadGridMan(NULL),
+   fEventHeader(NULL),
+   fMCEventHeader(NULL),
+   listActiveDetectors(),
+   listDetectors(),
+   fRunInfo(),
+   fGeometryIsInitialized(kFALSE)
+{
+// Default constructor
+}
+//_____________________________________________________________________________
+FairMCApplication::~FairMCApplication()
+{
+// Destructor
+//   LOG(DEBUG3) << "Enter Destructor of FairMCApplication"
+//               << FairLogger::endl;
+  delete fStack;
+  delete fActiveDetectors; // don't do fActiveDetectors->Delete() here
+  // the modules are already deleted in FairRunSim
+  delete fDetectors;
+  delete fModIter;
+  //  LOG(DEBUG3) << "Leave Destructor of FairMCApplication"
+  //              << FairLogger::endl;
+}
+
+//_____________________________________________________________________________
+FairMCApplication& FairMCApplication::operator=(const FairMCApplication& rhs)
+{
+// Assignment operator
+
+  // check assignment to self
+  if (this != &rhs) {
+
+    // base class assignment
+    TVirtualMCApplication::operator=(rhs);
+
+    fActiveDetectors = NULL;
+    fFairTaskList = NULL;
+    fDetectors = NULL;
+    fDetMap = NULL;
+    fModIter = NULL;
+    fModules = NULL;
+    fNoSenVolumes = 0;
+    fPythiaDecayer = kFALSE;
+    fPythiaDecayerConfig = rhs.fPythiaDecayerConfig;
+    fStack = NULL;
+    fRootManager = NULL;
+    fSenVolumes = NULL;
+    fxField = rhs.fxField;
+    fEvGen = NULL;
+    fMcVersion = rhs.fMcVersion;
+    fTrajFilter = NULL;
+    fTrajAccepted = kFALSE;
+    fUserDecay = kFALSE;
+    fUserDecayConfig = rhs.fUserDecayConfig;
+    fDebug = rhs.fDebug;
+    fDisVol = NULL;
+    fDisDet = NULL;
+    fTrkPos = rhs.fTrkPos;
+    fRadLength = kFALSE;
+    fRadLenMan = NULL;
+    fRadMap = kFALSE;
+    fRadMapMan = NULL;
+    fRadGridMan = NULL;
+    fEventHeader = NULL;
+    fMCEventHeader = NULL;
+    fGeometryIsInitialized = kFALSE;
+
+    // Do not create Root manager
+    
+    // Create an ObjArray of Modules and its iterator
+    fModules=new TObjArray();
+    fModIter = fModules->MakeIterator();
+    // Clone modules
+    TObject* obj;
+    while((obj=rhs.fModIter->Next())) {
+      fModules->Add(static_cast<FairModule*>(obj)->CloneModule());
+    }
+    
+    // Create and fill a list of active detectors
+    fDetectors=new TRefArray;
+    fActiveDetectors=new TRefArray();
+    fModIter->Reset();
+    FairDetector* detector;
+    while((obj=fModIter->Next())) {
+      if(obj->InheritsFrom("FairDetector")) {
+	detector=dynamic_cast<FairDetector*>(obj);
+        if (detector) {
+	  fDetectors->Add(detector);
+	  listDetectors.push_back(detector);
+	  if(detector->IsActive()) {
+	    fActiveDetectors->Add(detector);
+	    listActiveDetectors.push_back(detector);
+	  }
+	} else {
+          LOG(ERROR) << "Dynamic cast fails." << FairLogger::endl;
+	}
+      }
+    }
+    
+    // Clone stack
+    fStack = rhs.fStack->CloneStack();
+    
+    // Create a Task list
+    // Let's try without it
+    //fFairTaskList= new FairTask("Task List", 1);
+    //gROOT->GetListOfBrowsables()->Add(fFairTaskList);
+    
+    fDetMap=new TRefArray(1000);
+  }
+  
+  return *this;
+
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::RegisterStack()
+{
+// Registers stack in Root manager.
+//  LOG(DEBUG) << "FairMCApplication::RegisterStack() " 
+//             << FairLogger::endl;
+  if(fEvGen) {
+    fStack->Register();
+  }
+}
+//_____________________________________________________________________________
+void FairMCApplication::InitMC(const char*, const char*)
+{
+// Initialize MC.
+// ---
+  fStack = dynamic_cast<FairGenericStack*>(TVirtualMC::GetMC()->GetStack()) ;
+  if(fStack==NULL) { 
+    LOG(FATAL) << "No Stack defined." << FairLogger::endl; 
+  }
+  TVirtualMC::GetMC()->SetMagField(fxField);
+
+  TVirtualMC::GetMC()->Init();
+  TVirtualMC::GetMC()->BuildPhysics();
+  TString MCName=TVirtualMC::GetMC()->GetName();
+  if     (MCName == "TGeant3" || MCName == "TGeant3TGeo") {
+    fMcVersion = 0 ;
+  } else if(MCName == "TGeant4") {
+    fMcVersion = 1;
+  } else if(MCName == "TFluka") {
+    fMcVersion = 2;
+  } else {
+    fMcVersion = 3;  //Geane
+  }
+  fTrajFilter = FairTrajFilter::Instance();
+
+  LOG(INFO) << "Monte Carlo Engine Initialisation with: " << MCName.Data()
+	    << FairLogger::endl;
+}
+//_____________________________________________________________________________
+void FairMCApplication::RunMC(Int_t nofEvents)
+{
+  // Reset the time for FairRunInfo. Otherwise the time of the
+  // first event will include the time needed for initilization.
+  fRunInfo.Reset();
+
+  /** Set the list of active detectors to the stack*/
+  fStack->SetDetArrayList(fActiveDetectors);
+
+  // MC run.
+  TVirtualMC::GetMC()->ProcessRun(nofEvents);
+  // finish run
+  FinishRun();
+  // Save histograms with memory and runtime information in the output file
+  if (FairRunSim::Instance()->IsRunInfoGenerated()) {
+    fRunInfo.WriteInfo();
+  }
+}
+//____________________________________________________________________________
+void FairMCApplication::FinishRun()
+{
+// Finish MC run.
+// ---
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+  {
+        (*listIter)->FinishRun();
+  }
+
+
+
+  fFairTaskList->FinishTask();
+  //fRootManager->Fill();
+
+  FairPrimaryGenerator* gen = FairRunSim::Instance()->GetPrimaryGenerator();
+  //FairMCEventHeader* header = gen->GetEvent();
+  Int_t nprimary = gen->GetTotPrimary();
+  TObjArray* meshlist  = NULL;
+
+  if (fRadGridMan ) {
+
+    meshlist = fRadGridMan->GetMeshList();
+
+    TH2D* tid = NULL;
+    TH2D* flu = NULL;
+    TH2D* seu = NULL;
+
+    LOG(INFO) << "======================================================="
+	      << FairLogger::endl;
+    LOG(INFO) << "   Dosimetry  histos saving " << FairLogger::endl;
+    LOG(INFO) << "======================================================="
+	      << FairLogger::endl;
+
+    TDirectory* savedir = gDirectory;
+    fRootManager->GetOutFile()->cd();
+
+    gDirectory->mkdir("Dosimetry");
+    gDirectory->cd("Dosimetry");
+
+    for(Int_t i=0; i<meshlist->GetEntriesFast(); i++ ) {
+      FairMesh* aMesh = dynamic_cast<FairMesh*>(meshlist->At(i));
+      if (aMesh) {
+        aMesh->Scale(1./nprimary); 
+        tid = aMesh->GetMeshTid();
+        flu = aMesh->GetMeshFlu();
+        seu = aMesh->GetMeshSEU();
+        tid->Write();
+        flu->Write();
+        seu->Write();
+      }
+    }
+
+    gDirectory=savedir;
+        
+  }
+
+  if (!fRadGridMan) {
+    if (fRootManager) fRootManager->Write();
+  }
+  UndoGeometryModifications();
+  //  fRootManager->Write();
+
+}
+//_____________________________________________________________________________
+void FairMCApplication::BeginEvent()
+{
+// User actions at beginning of event
+// ---
+    
+    for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+                                              listIter != listActiveDetectors.end();
+                                              listIter++)
+    {
+        (*listIter)->BeginEvent();
+    }
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::BeginPrimary()
+{
+// User actions at beginning of a primary track
+// ---
+    for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+    {
+        (*listIter)->BeginPrimary();
+    }
+
+}
+//_____________________________________________________________________________
+void FairMCApplication::PreTrack()
+{
+
+// User actions at beginning of each track
+// ---
+
+  
+ for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+                                           listIter != listActiveDetectors.end();
+                                           listIter++)
+ {
+        (*listIter)->PreTrack();
+ }
+    
+    
+  fTrajAccepted=kFALSE;
+  if(NULL != fTrajFilter) {
+    // Get the pointer to current track
+    TParticle* particle = fStack->GetCurrentTrack();
+//  LOG(DEBUG) << " FairMCApplication::PreTrack(): " << particle 
+//             << FairLogger::endl;
+    // Apply cuts
+    fTrajAccepted = fTrajFilter->IsAccepted(particle);
+    if(fTrajAccepted) {
+      // Add trajectory to geo manager
+      //    Int_t trackId = fStack->GetCurrentTrackNumber();
+      TGeoTrack* fTrack=fTrajFilter->AddTrack(particle);
+      // TLorentzVector pos;
+      TVirtualMC::GetMC()->TrackPosition(fTrkPos);
+      fTrack->AddPoint(fTrkPos.X(), fTrkPos.Y(), fTrkPos.Z(), fTrkPos.T());
+    }
+  }
+}
+
+//_____________________________________________________________________________
+TVirtualMCApplication* FairMCApplication::CloneForWorker() const
+{
+  LOG(INFO) << "FairMCApplication::CloneForWorker " 
+	    << this << FairLogger::endl;
+
+  // Create new FairRunSim object on worker
+  FairRunSim* workerRun = new FairRunSim(kFALSE);
+  workerRun->SetName(FairRunSim::Instance()->GetName()); // Transport engine
+  workerRun->SetOutputFile("file1.root"); // TO DO: must be different on each  worker
+
+  // Create new  FairMCApplication object on worker
+  FairMCApplication* workerApplication = new FairMCApplication(*this);
+  workerApplication->SetGenerator(fEvGen->ClonePrimaryGenerator());
+
+  LOG(INFO) << "FairMCApplication::CloneForWorker finished " 
+	    << this << FairLogger::endl;
+  return workerApplication;
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::InitForWorker() const
+{
+  LOG(INFO) << "FairMCApplication::InitForWorker " 
+	    << this << FairLogger::endl;
+
+  // Create Root manager
+  // TO DO
+  //fRootManager
+  //  = new TMCRootManagerMT(GetName(), TVirtualMCRootManager::kWrite);
+  //fRootManager->SetDebug(true);
+
+  // Set data to MC
+  TVirtualMC::GetMC()->SetStack(fStack);
+  TVirtualMC::GetMC()->SetMagField(fxField);
+
+  // if (fRootManager) RegisterStack();
+
+  LOG(INFO) << "Monte Carlo Engine Worker Initialisation  with: "
+	    << TVirtualMC::GetMC()->GetName() << FairLogger::endl;
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::FinishWorkerRun() const
+{
+  LOG(INFO) << "A01MCApplication::FinishWorkerRun: " << FairLogger::endl;
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::Stepping()
+{
+// User actions at each step
+// ---
+  // Work around for Fluka VMC, which does not call
+  // MCApplication::PreTrack()
+  static Int_t TrackId = 0;
+  if ( fMcVersion ==2 && TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber() != TrackId ) {
+    PreTrack();
+    TrackId = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
+  }
+
+
+  // Check if the volume with id is in the volume multimap.
+  // If it is not in the map the volume is not a sensitive volume 
+  // and we do not call nay of our ProcessHits functions.
+
+  // If the volume is in the multimap, check in second step if the current 
+  // copy is alredy inside the multimap. 
+  // If the volume is not in the multimap add the copy of the volume to the 
+  // multimap. 
+  // In any case call the ProcessHits function for this specific detector.
+  Int_t copyNo;
+  Int_t id = TVirtualMC::GetMC()->CurrentVolID(copyNo);
+  Bool_t InMap =kFALSE;
+  fDisVol=0;
+  fDisDet=0;
+  Int_t fCopyNo=0;
+  fVolIter =fVolMap.find(id);
+  if (fVolIter!=fVolMap.end()) {
+    do {
+      fDisVol=fVolIter->second;
+      fCopyNo=fDisVol->getCopyNo();
+      if(copyNo==fCopyNo) {
+        fDisDet=fDisVol->GetDetector();
+        if (fDisDet) {
+          fDisDet->ProcessHits(fDisVol);
+        }
+        InMap=kTRUE;
+        break;
+      }
+      fVolIter++;
+    } while(fVolIter!=fVolMap.upper_bound(id));
+    //    if(fDisVol && !InMap) { // fDisVolume is set previously, no check needed
+    if(!InMap) {
+      FairVolume* fNewV=new FairVolume( TVirtualMC::GetMC()->CurrentVolName(), id);
+      fNewV->setMCid(id);
+      fNewV->setModId(fDisVol->getModId());
+      fNewV->SetModule(fDisVol->GetModule());
+      fNewV->setCopyNo(copyNo);
+      fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
+      fDisDet=fDisVol->GetDetector();
+      if ( fDisDet) {
+        fDisDet->ProcessHits(fNewV);
+      }
+    }
+  }
+
+  // If information about the tracks should be stored the information as to be
+  // stored for any step.
+  // Information about each single step has also to be stored for the other 
+  // special run modes of the simulation which are used to store information 
+  // about 
+  // 1.) Radiation length in each volume
+  // 2.) Energy deposition in each volume
+  // 3.) Fluence of particles through a defined plane which can be anywhere
+  //     in the geometry. This plane has not to be correlated with any real
+  //     volume 
+  if(fTrajAccepted) {
+    if(TVirtualMC::GetMC()->TrackStep() > fTrajFilter->GetStepSizeCut()) {
+      TVirtualMC::GetMC()->TrackPosition(fTrkPos);
+      fTrajFilter->GetCurrentTrk()->AddPoint(fTrkPos.X(), fTrkPos.Y(), fTrkPos.Z(), fTrkPos.T());
+    }
+  }
+  if(fRadLenMan) {
+    id = TVirtualMC::GetMC()->CurrentVolID(copyNo);
+    fModVolIter =fModVolMap.find(id);
+    fRadLenMan->AddPoint(fModVolIter->second);
+  }
+  if(fRadMapMan) {
+    id = TVirtualMC::GetMC()->CurrentVolID(copyNo);
+    fModVolIter =fModVolMap.find(id);
+    fRadMapMan->AddPoint(fModVolIter->second);
+  }
+  if(fRadGridMan) {
+    fRadGridMan->FillMeshList();
+  }
+
+}
+//_____________________________________________________________________________
+void FairMCApplication::PostTrack()
+{
+// User actions after finishing of each track
+// ---
+    
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+  {
+        (*listIter)->PostTrack();
+  }
+
+
+
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::FinishPrimary()
+{
+// User actions after finishing of a primary track
+// ---
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+  {
+        (*listIter)->FinishPrimary();
+  }
+    
+
+    
+}
+
+//_____________________________________________________________________________
+
+void FairMCApplication::StopRun()
+{
+  FinishEvent();
+  FinishRun();
+  if (fRootManager) {
+    fRootManager->Write();
+    fRootManager->CloseOutFile();
+  }
+  LOG(WARNING) << "StopRun() exiting not safetly oopps !!!@@@!!!"
+	       << FairLogger::endl;
+  exit(0) ;
+}
+//_____________________________________________________________________________
+void FairMCApplication::FinishEvent()
+{
+// User actions after finishing of an event
+// ---
+  // --> Fill the stack output array
+  fStack->FillTrackArray();
+  // --> Update track indizes in MCTracks and MCPoints
+  fStack->UpdateTrackIndex(fActiveDetectors);
+  // --> Screen output of stack
+  if (fFairTaskList) {
+    fFairTaskList->ExecuteTask("");
+    fFairTaskList->FinishEvent();
+  }
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+  {
+        (*listIter)->FinishEvent();
+  }
+    
+    
+  if (fRootManager) fRootManager->Fill();
+  
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+  {
+       (*listIter)->EndOfEvent();
+  }
+    
+    
+    
+  fStack->Reset();
+  if(NULL != fTrajFilter) {
+    fTrajFilter->Reset();
+//    TObjArray* fListOfTracks=gGeoManager->GetListOfTracks();
+//    fListOfTracks->Delete();
+    gGeoManager->GetListOfTracks()->Delete();
+  }
+  if(NULL !=fRadLenMan) {
+    fRadLenMan->Reset();
+  }
+  if(NULL !=fRadMapMan) {
+    fRadMapMan->Reset();
+  }
+
+  // Store information about runtime for one event and memory consuption
+  // for later usage.
+  // Requires Logger instantiated
+  fRunInfo.StoreInfo();
+
+}
+//_____________________________________________________________________________
+Double_t FairMCApplication::TrackingRmax() const
+{
+// No limit
+// ---
+  return DBL_MAX;
+}
+//_____________________________________________________________________________
+Double_t FairMCApplication::TrackingZmax() const
+{
+// No limit
+// ---
+  return DBL_MAX;
+}
+//_____________________________________________________________________________
+void FairMCApplication::SetField(FairField* field)
+{
+  fxField=field;
+}
+//_____________________________________________________________________________
+void FairMCApplication::ConstructOpGeometry()
+{
+  FairGeoLoader* loader=FairGeoLoader::Instance();
+  FairGeoInterface* GeoInterface =loader->getGeoInterface();
+  FairGeoMedia* media= GeoInterface->getMedia();
+  TList* MediaList= media->getListOfMedia();
+  TListIter iter(MediaList);
+  FairGeoMedium* medium;
+  Int_t NK=0;
+  Double_t p[4];
+  while((medium=dynamic_cast<FairGeoMedium*>(iter.Next()))) {
+    NK=medium->getNpckov();
+    if(NK>0) {
+      Int_t Mid=0;
+      TGeoMedium* Med = 0;
+      if ( gGeoManager && (Med = gGeoManager->GetMedium(medium->GetName())) ) {
+        Mid=Med->GetId();
+      } else {
+        Mid=medium->getMediumIndex();
+        if(Mid<=0) {
+          continue;
+        }
+      }
+      Double_t ppckov[NK], absco[NK], effic[NK],rindex[NK];
+      for (Int_t i=0; i<NK; i++) {
+        medium->getCerenkovPar(i, p);
+        ppckov[i]=p[0]*1E-9;
+        absco[i]=p[1];
+        effic[i]=p[2];
+        rindex[i]=p[3];
+      }
+      TVirtualMC::GetMC()->SetCerenkov(Mid, NK, ppckov,absco, effic, rindex);
+    }
+  }
+  fModIter->Reset();
+  FairModule* Mod=NULL;
+  while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
+    Mod->ConstructOpGeometry();
+  }
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::ConstructGeometry()
+{
+
+  fModIter->Reset();
+  FairModule* Mod=NULL;
+  Int_t NoOfVolumes=0;
+  Int_t NoOfVolumesBefore=0;
+  Int_t ModId=0;
+  while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
+    NoOfVolumesBefore=gGeoManager->GetListOfVolumes()->GetEntriesFast();
+    Mod->InitParContainers();
+    Mod->ConstructGeometry();
+    ModId=Mod->GetModId();
+    NoOfVolumes=gGeoManager->GetListOfVolumes()->GetEntriesFast();
+    for (Int_t n=NoOfVolumesBefore; n <= NoOfVolumes; n++) {
+      fModVolMap.insert(pair<Int_t, Int_t >(n,ModId));
+    }
+  }
+  fSenVolumes=FairModule::svList;
+  if(fSenVolumes) {
+    fNoSenVolumes=fSenVolumes->GetEntries();
+  }
+  if (gGeoManager) {
+    //  LOG(DEBUG) << "FairMCApplication::ConstructGeometry() : Now closing the geometry"<< FairLogger::endl;
+    gGeoManager->CloseGeometry();   // close geometry
+    TVirtualMC::GetMC()->SetRootGeometry();         // notify VMC about Root geometry
+    Int_t Counter=0;
+    TDatabasePDG* pdgDatabase = TDatabasePDG::Instance();
+    const THashList *list=pdgDatabase->ParticleList();
+    if(list==0)pdgDatabase->ReadPDGTable();
+    list =pdgDatabase->ParticleList();
+    if(list!=0){
+      TIterator *particleIter = list->MakeIterator();
+      TParticlePDG *Particle=0;
+      while((Particle=dynamic_cast<TParticlePDG*> (particleIter->Next())) && (Counter <= 256)) {
+         TString Name= gGeoManager->GetPdgName(Particle->PdgCode());
+	 //    LOG(INFO) << Counter <<" : Particle name: "<< Name.Data() << " PDG " << Particle->PdgCode()) << FairLogger::endl;
+         if(Name=="XXX") gGeoManager->SetPdgName(Particle->PdgCode(), Particle->GetName());
+         Counter++;
+      }
+    }
+    fModIter->Reset();
+    while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
+      Mod->ModifyGeometry();
+    }
+
+    gGeoManager->RefreshPhysicalNodes(kFALSE);
+  }
+}
+//_____________________________________________________________________________
+
+void FairMCApplication::InitGeometry()
+{
+  
+  //ToBeDone
+  // Recently the InitGeometry is called twice from the G4VMC, This is a work around tell the problem get fixed in G4VMC
+  if (fGeometryIsInitialized) return;
+    
+  /// Initialize geometry
+  /** Register stack and detector collections*/
+  FairVolume* fv=0;
+  Int_t id=0;
+  fModIter->Reset();
+  if(fEvGen!=0 && fStack!=0) {
+    if (fRootManager) {
+      fStack->Register();
+    }
+  } else {
+    LOG(WARNING) << "Stack is not registered " << FairLogger::endl;
+  }
+  /** Initialize the event generator */
+  // if(fEvGen)fEvGen->Init();
+  /** Initialize the detectors.    */
+  for( std::list<FairDetector *>::iterator  listIter = listActiveDetectors.begin();
+        listIter != listActiveDetectors.end();
+        listIter++)
+ {
+     
+     (*listIter)->Initialize();
+     (*listIter)->SetSpecialPhysicsCuts();
+     (*listIter)->Register();
+  }
+  
+    
+  /**Tasks has to be initialized here, they have access to the detector branches and still can create objects in the tree*/
+  /// There is always a Main Task  !
+  /// so .. always a InitTasks() is called <D.B>
+  if (fFairTaskList) {
+    InitTasks();
+  }
+
+  // store the EventHeader Info
+  // Get and register EventHeader
+  UInt_t runId = FairRunSim::Instance()->GetRunId();
+
+  LOG(INFO) << "Simulation RunID: " << runId << FairLogger::endl;
+
+
+  // Get and register the MCEventHeader
+  fMCEventHeader = FairRunSim::Instance()->GetMCEventHeader();
+  fMCEventHeader->SetRunID(runId);
+  if (fRootManager) {
+    fMCEventHeader->Register();
+  }
+
+  if(NULL !=fRadGridMan) {
+    fRadGridMan->Init();
+  }
+
+  if(fEvGen) {
+    fEvGen->SetEvent(fMCEventHeader);
+  }
+  fTrajFilter = FairTrajFilter::Instance();
+  if(NULL != fTrajFilter ) {
+    fTrajFilter->Init();
+  }
+  if(NULL !=fRadLenMan) {
+    fRadLenMan->Init();
+  }
+  if(NULL !=fRadMapMan) {
+    fRadMapMan->Init();
+  }
+  if(NULL !=fRadGridMan) {
+    fRadGridMan->Init();
+  }
+
+  /// save Geo Params in Output file
+  if (fRootManager) {
+    fRootManager->WriteFolder();
+    TTree* outTree =new TTree(FairRootManager::GetTreeName(), "/cbmroot", 99);
+    fRootManager->TruncateBranchNames(outTree, "cbmroot");
+    fRootManager->SetOutTree(outTree);
+  }
+
+  for ( Int_t i = 0 ; i < fNoSenVolumes ; i++ ) {
+    fv= dynamic_cast<FairVolume*>(fSenVolumes->At(i));
+    if (!fv) {
+     LOG(ERROR) << "No FairVolume in fSenVolumes at position " << i 
+		 << FairLogger::endl;
+      continue; 
+    }
+    id=fv->getMCid();
+    if(fv->getGeoNode()==0) {  //handel sensetive volumes created directly by user
+      TGeoNode* fN=0;
+      TGeoVolume* v=gGeoManager->GetVolume(fv->GetName());
+      TObjArray* fNs=0;
+      if(v) {
+        fNs=v->GetNodes();
+      }
+      if(fNs) {
+        for(Int_t k=0; k<fNs->GetEntriesFast(); k++) {
+          fN=dynamic_cast<TGeoNode*>(fNs->At(k));
+          if (!fN) {
+	    LOG(ERROR) << "No TGeoNode in fNs at position " << k 
+		       << FairLogger::endl;
+	    continue; 
+	  }
+	  FairVolume* fNewV=new FairVolume( fv->GetName(), id);
+          fNewV->setModId(fv->getModId());
+          fNewV->SetModule(fv->GetModule());
+          fNewV->setCopyNo(fN->GetNumber());
+          fNewV->setMCid(id);
+          fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
+        }
+      } else {
+        FairVolume* fNewV=new FairVolume( fv->GetName(), id);
+        fNewV->setModId(fv->getModId());
+        fNewV->SetModule(fv->GetModule());
+        fNewV->setCopyNo(1);
+        fNewV->setMCid(id);
+        fVolMap.insert(pair<Int_t, FairVolume* >(id, fNewV));
+      }
+    } else {
+      fVolMap.insert(pair<Int_t, FairVolume* >(id, fv));
+    }
+  }
+  fGeometryIsInitialized=kTRUE;
+
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::GeneratePrimaries()
+{
+// Fill the user stack (derived from TVirtualMCStack) with primary particles.
+// ---
+  if(fEvGen) {
+//    LOG(DEBUG) << "FairMCApplication::GeneratePrimaries()" 
+//               << FairLogger::endl;
+    if (!fEvGen->GenerateEvent( fStack) ) {
+      StopRun();
+    }
+  }
+}
+//_____________________________________________________________________________
+FairDetector* FairMCApplication::GetDetector(const char* DetName)
+{
+  return dynamic_cast<FairDetector*>(fModules->FindObject(DetName));
+}
+//_____________________________________________________________________________
+void  FairMCApplication::AddIons()
+{
+  TDatabasePDG* pdgDatabase = TDatabasePDG::Instance();
+  FairRunSim* fRun=FairRunSim::Instance();
+  TObjArray* NewIons=fRun->GetUserDefIons();
+  TIterator* Iter=NewIons->MakeIterator();
+  Iter->Reset();
+  TObject* obj=0;
+  FairIon* ion=0;
+  while((obj=Iter->Next())) {
+    ion=dynamic_cast <FairIon*> (obj);
+    if(ion) {
+      // Check if an ion with the calculated pdg code already exists in the
+      // TDatabasePDG.
+      // If the ion already exist don't create a new one because this fails for
+      // Geant4. Instead modify the FairIon to use the already existing ion
+      // from the TDatabasePDG.
+      // The problem occured for example for Alphas which exist already.
+      Int_t ionPdg = GetIonPdg( ion->GetZ(), ion->GetA() );
+      if ( !pdgDatabase->GetParticle( ionPdg ) ) {
+        TVirtualMC::GetMC()->DefineIon(ion->GetName(), ion->GetZ(), ion->GetA(), ion->GetQ(),
+                       ion->GetExcEnergy(),ion->GetMass());
+
+      } else {
+        ion->SetName(pdgDatabase->GetParticle(ionPdg)->GetName());
+      }
+      //Add Ion to gGeoManager visualization
+      if(gGeoManager) {
+        gGeoManager->SetPdgName(pdgDatabase->GetParticle(ion->GetName())->PdgCode(),ion->GetName() );
+      }
+      LOG(INFO) << "Add Ion: " << ion->GetName() << " with PDG " <<  pdgDatabase->GetParticle(ion->GetName())->PdgCode() << FairLogger::endl;
+    }
+  }
+  delete   Iter;
+  /** Initialize the event generator */
+  if(fEvGen) {
+    fEvGen->Init();
+  }
+}
+//_____________________________________________________________________________
+void  FairMCApplication::AddParticles()
+{
+
+  FairRunSim* fRun=FairRunSim::Instance();
+  TObjArray* NewIons=fRun->GetUserDefIons();
+  TIterator* Iter=NewIons->MakeIterator();
+  Iter->Reset();
+  TObject* obj=0;
+  TObjArray* NewPart=fRun->GetUserDefParticles();
+  TIterator* parIter=NewPart->MakeIterator();
+  parIter->Reset();
+  obj=0;
+  FairParticle* particle=0;
+  while((obj=parIter->Next())) {
+    particle=dynamic_cast <FairParticle*> (obj);
+    if(particle) {                // (Int_t pdg, const char* name, TMCParticleType type,
+      //Double_t mass, Double_t charge, Double_t lifetime);
+      LOG(INFO) << "Add Particle: " << particle->GetName()  << " with PDG " <<   particle->GetPDG() << "\n"<<
+           particle->GetName() << "            // const TString& name \n" <<
+           particle->GetMCType()<<"             // TMCParticleType mcType \n" <<
+           particle->GetMass()<<"             // Double_t mass   \n" <<
+           particle->GetCharge()<<"           // Double_t charge \n" <<
+           particle->GetDecayTime()<<"        // Double_t lifetime  \n" <<
+           particle->GetPType()<<  "           // const TString& pType, \n" <<
+           particle->GetWidth()<<   "         // Double_t width   \n" <<
+           particle->GetSpin()<<    "         // Int_t iSpin  \n" <<
+           particle->GetiParity()<< "         // Int_t iParity \n" <<
+           particle->GetConjugation()<<"       // Int_t iConjugation  \n" <<
+           particle->GetIsospin()<<   "       // Int_t iIsospin   \n" <<
+           particle->GetIsospinZ()<<  "       // Int_t iIsospinZ    \n" <<
+           particle->GetgParity()<<   "       // Int_t gParity    \n" <<
+           particle->GetLepton()<<  "         // Int_t lepton  \n" <<
+           particle->GetBaryon()<<  "         // Int_t baryon   \n" <<
+           particle->IsStable() <<  "         // Bool_t stable   \n" 
+		<< FairLogger::endl;
+      TVirtualMC::GetMC()->DefineParticle(particle->GetPDG(),              // Int_t pdg
+                          particle->GetName(),             // const TString& name
+                          particle->GetMCType(),             // TMCParticleType mcType
+                          particle->GetMass(),             // Double_t mass
+                          particle->GetCharge(),           // Double_t charge
+                          particle->GetDecayTime(),        // Double_t lifetime
+                          particle->GetPType(),             // const TString& pType,
+                          particle->GetWidth(),            // Double_t width
+                          particle->GetSpin(),             // Int_t iSpin
+                          particle->GetiParity(),          // Int_t iParity
+                          particle->GetConjugation(),       // Int_t iConjugation
+                          particle->GetIsospin(),          // Int_t iIsospin
+                          particle->GetIsospinZ(),         // Int_t iIsospinZ
+                          particle->GetgParity(),          // Int_t gParity
+                          particle->GetLepton(),           // Int_t lepton
+                          particle->GetBaryon(),           // Int_t baryon
+                          particle->IsStable()             // Bool_t stable
+                         );
+      //Add Ion to gGeoManager visualization
+      if(gGeoManager) {
+        gGeoManager->SetPdgName(particle->GetPDG(),particle->GetName() );
+      }
+    }
+  }
+  delete   parIter;
+  AddDecayModes();
+  delete Iter;
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::AddDecayModes()
+{
+  TString work = getenv("VMCWORKDIR");
+  TString work_config=work+"/gconfig/";
+  work_config.ReplaceAll("//","/");
+
+  TString config_dir= getenv("CONFIG_DIR");
+  config_dir.ReplaceAll("//","/");
+
+  Bool_t AbsPath=kFALSE;
+
+  if (!config_dir.EndsWith("/")) {
+    config_dir+="/";
+  }
+  // set Pythia as external decayer
+
+  if(fPythiaDecayer) {
+    TString decayConfig;
+    if(fPythiaDecayerConfig.IsNull()) {
+      decayConfig="DecayConfig.C";
+      fPythiaDecayerConfig= decayConfig;
+    } else {
+      if (fPythiaDecayerConfig.Contains("/")) {
+        AbsPath=kTRUE;
+      }
+      decayConfig=fPythiaDecayerConfig;
+    }
+
+    if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), decayConfig)) != TString("")) {
+      LOG(INFO) << "---User path for Configuration (DecayConfig.C) is used : " 
+		<<  config_dir.Data() << FairLogger::endl;
+    } else {
+      if(AbsPath) {
+        decayConfig=   fPythiaDecayerConfig;
+      } else {
+        decayConfig=work_config+ fPythiaDecayerConfig ;
+      }
+    }
+    // Add decay modes using an external configuration script
+    LOG(INFO) << "External Decay Modes with script \n "
+	      <<  decayConfig.Data() << FairLogger::endl;
+    // Load configuration script and execute it
+    Int_t pyt= gROOT->LoadMacro(decayConfig.Data());
+    if(pyt==0) {
+      gInterpreter->ProcessLine("DecayConfig()");
+    }
+  }
+  // set user defined phase space decay for particles (ions)
+  AbsPath=kFALSE;
+  if(fUserDecay) {
+    TString Userdecay;
+    if(fUserDecayConfig.IsNull()) {
+      Userdecay="UserDecay.C";
+      fUserDecayConfig =Userdecay;
+    } else {
+      if(fUserDecayConfig.Contains("/")) {
+        AbsPath=kTRUE;
+      }
+      Userdecay=  fUserDecayConfig;
+    }
+
+
+    if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(), Userdecay)) != TString("")) {
+      LOG(INFO) << "---User path for Configuration (UserDecay.C) is used : " 
+		<<  config_dir.Data() << FairLogger::endl;
+    } else {
+      if(AbsPath) {
+        Userdecay=fUserDecayConfig;
+      } else {
+        Userdecay=work_config+fUserDecayConfig;
+      }
+    }
+    LOG(INFO) << "User Decay Modes with script \n "
+	      <<  Userdecay.Data() << FairLogger::endl;
+    Int_t dec= gROOT->LoadMacro(Userdecay.Data());
+    if(dec==0) {
+      gInterpreter->ProcessLine("UserDecayConfig()");
+    }
+  }
+}
+//_____________________________________________________________________________
+FairPrimaryGenerator* FairMCApplication::GetGenerator()
+{
+  return fEvGen;
+}
+//_____________________________________________________________________________
+void FairMCApplication::SetGenerator(FairPrimaryGenerator* pGen)
+{
+  fEvGen=pGen;
+}
+//_____________________________________________________________________________
+void FairMCApplication::AddTask(TTask* fTask)
+{
+  if (! fFairTaskList ) {
+    fFairTaskList= new FairTask("Task List", 1);
+    gROOT->GetListOfBrowsables()->Add(fFairTaskList);
+  }
+  fFairTaskList->Add(fTask);
+  SetParTask();
+}
+//_____________________________________________________________________________
+FairGenericStack* FairMCApplication::GetStack()
+{
+  return fStack;
+}
+//_____________________________________________________________________________
+TTask* FairMCApplication::GetListOfTasks()
+{
+  return fFairTaskList;
+}
+
+//_____________________________________________________________________________
+void FairMCApplication::SetParTask()
+{
+  // Only RTDB init when more than Main Task list
+  if(FairRun::Instance()->GetNTasks() >= 1 ) {
+    fFairTaskList->SetParTask();
+  }
+  fModIter->Reset();
+  FairModule* Mod=NULL;
+  while((Mod = dynamic_cast<FairModule*>(fModIter->Next()))) {
+    Mod->SetParContainers();
+  }
+  FairRuntimeDb* fRTdb=  FairRun::Instance()->GetRuntimeDb();
+  fRTdb->initContainers(FairRunSim::Instance()->GetRunId());
+
+}
+//_____________________________________________________________________________
+void FairMCApplication::InitTasks()
+{
+
+  // Only RTDB init when more than Main Task list
+  if(FairRun::Instance()->GetNTasks() >= 1 ) {
+    LOG(INFO) << "Initialize Tasks--------------------------" 
+	      << FairLogger::endl;
+    fFairTaskList->InitTask();
+
+  }
+
+
+}
+//_____________________________________________________________________________
+TChain* FairMCApplication::GetChain()
+{
+  return fRootManager->GetInChain();
+}
+//_____________________________________________________________________________
+
+void  FairMCApplication::SetRadiationLengthReg(Bool_t RadLen)
+{
+  fRadLength=RadLen;
+  if(fRadLength) {
+    fRadLenMan= new FairRadLenManager();
+  }
+}
+//_____________________________________________________________________________
+
+
+void  FairMCApplication::SetRadiationMapReg(Bool_t RadMap)
+{
+  fRadMap=RadMap;
+  if(fRadMap) {
+    fRadMapMan= new FairRadMapManager();
+  }
+}
+//_____________________________________________________________________________
+
+
+void  FairMCApplication::AddMeshList(TObjArray* meshList)
+{
+  if (!fRadGridMan) {
+    fRadGridMan = new FairRadGridManager();
+  }
+  fRadGridMan->AddMeshList (meshList);
+}
+//_____________________________________________________________________________
+
+Int_t FairMCApplication::GetIonPdg(Int_t z, Int_t a) const
+{
+  // Acording to
+  // http://pdg.lbl.gov/2012/reviews/rpp2012-rev-monte-carlo-numbering.pdf
+
+  return 1000000000 + 10*1000*z + 10*a;
+}
+
+void  FairMCApplication::UndoGeometryModifications()
+{
+  // Undo all misalignment done in the MisalignGeometry methods of the
+  // several FairModuls.
+  // In the output (parameter container and separate geometry file)
+  // only the ideal geometry is stored.
+  // I don't know any better way than to loop over all physical nodes
+  // and to set the matrix back to the original one.
+  // TODO: Check if it is more easy to write the ideal geometry before
+  //       the geometry is misaligned. In this case one does not have 
+  //       to revert the misalignment.
+
+  TObjArray* physNodes = gGeoManager->GetListOfPhysicalNodes();
+  Int_t numPhysNodes=physNodes->GetEntriesFast();
+
+  if ( 0 == numPhysNodes) return;
+
+  //fRootManager->CreateGeometryFile("misaligned_geometry.root");
+  LOG(INFO)<<"Undo all misalignment"<<FairLogger::endl;
+
+  TGeoPhysicalNode* node = NULL;
+  TGeoHMatrix* ng3 = NULL;
+  for(Int_t k=0; k<numPhysNodes; k++) {
+    node=static_cast<TGeoPhysicalNode*>(physNodes->At(k));
+    ng3 = node->GetOriginalMatrix(); //"real" global matrix, what survey sees
+    node->Align(ng3);
+  }
+
+  gGeoManager->ClearPhysicalNodes(kFALSE);
+
+}
+
+ClassImp(FairMCApplication)
diff --git a/base/FairMCApplication.h b/base/sim/FairMCApplication.h
similarity index 82%
rename from base/FairMCApplication.h
rename to base/sim/FairMCApplication.h
index ed11083..cc26aa9 100644
--- a/base/FairMCApplication.h
+++ b/base/sim/FairMCApplication.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----               FairMCApplication header file                   -----
 // -----            Created 06/01/04  by M. Al-Turany                  -----
@@ -6,31 +13,35 @@
 #ifndef FAIR_MC_APPLICATION_H
 #define FAIR_MC_APPLICATION_H
 
-#include "TVirtualMCApplication.h"
-#include "TLorentzVector.h"
-#include "FairTask.h"
-#include "FairRunInfo.h"
+#include "TVirtualMCApplication.h"      // for TVirtualMCApplication
 
-#include <map>
+#include "FairRunInfo.h"                // for FairRunInfo
+
+#include "RVersion.h"                   // for ROOT_VERSION_CODE
+#include "Rtypes.h"                     // for Int_t, Bool_t, Double_t, etc
+#include "TLorentzVector.h"             // for TLorentzVector
+#include "TString.h"                    // for TString
+
+#include <map>                           // for map, multimap, etc
+#include <list>                           // for list
 
-class FairRootManager;
-class FairGenericStack;
-class FairModule;
-class FairLogger;
 class FairDetector;
+class FairEventHeader;
 class FairField;
+class FairGenericStack;
+class FairMCEventHeader;
 class FairPrimaryGenerator;
-class FairTrajFilter;
-class FairVolume;
-class FairRadLenManager;
 class FairRadGridManager;
+class FairRadLenManager;
 class FairRadMapManager;
-class FairEventHeader;
-class FairMCEventHeader;
-
+class FairRootManager;
+class FairTask;
+class FairTrajFilter;
+class FairVolume;
 class TChain;
-class TRefArray;
+class TIterator;
 class TObjArray;
+class TRefArray;
 class TTask;
 
 /**
@@ -109,6 +120,16 @@ class FairMCApplication : public TVirtualMCApplication
     virtual void          PostTrack();                                      // MC Application
     /** Define actions at the beginning of each track*/
     virtual void          PreTrack();                                       // MC Application
+
+    /** Clone for worker (used in MT mode only) */
+    virtual TVirtualMCApplication* CloneForWorker() const;
+
+    /** Init worker run (used in MT mode only) */
+    virtual void InitForWorker() const;
+
+    /** Finish worker run (used in MT mode only) */
+    virtual void FinishWorkerRun() const;
+
     /** Run the MC engine
      * @param nofEvents : number of events to simulate
      */
@@ -171,21 +192,20 @@ class FairMCApplication : public TVirtualMCApplication
   private:
     // methods
     void RegisterStack();
+
+    Int_t GetIonPdg(Int_t z, Int_t a) const;
+
+    void UndoGeometryModifications();
+
     // data members
-    /**Iterator for active detector list*/
-    TIterator*           fActDetIter;//!
     /**List of active detector */
     TRefArray*           fActiveDetectors;
     /**List of FairTask*/
     FairTask*             fFairTaskList;//!
-    /**Iterator for detector list (Passive and Active)*/
-    TIterator*           fDetIter; //!
     /**detector list (Passive and Active)*/
     TRefArray*           fDetectors;
     /**Map used for dispatcher*/
     TRefArray*           fDetMap;
-    /** Fair Logger */
-    FairLogger*          fLogger;//!
     /**Iterator for Module list*/
     TIterator*           fModIter; //!
     /**Module list in simulation*/
@@ -247,19 +267,27 @@ class FairMCApplication : public TVirtualMCApplication
     FairEventHeader*    fEventHeader; //!
 
     FairMCEventHeader*  fMCEventHeader; //!
+    /** list of senstive detectors used in the simuation session*/
+    std::list <FairDetector *> listActiveDetectors; //!
+    /** list of all detectors used in the simuation session*/
+    std::list <FairDetector *> listDetectors;  //!
 
-    ClassDef(FairMCApplication,2)  //Interface to MonteCarlo application
+    
+    ClassDef(FairMCApplication,4)  //Interface to MonteCarlo application
 
   private:
+    /** Protected copy constructor */
     FairMCApplication(const FairMCApplication&);
+    /** Protected assignment operator */
     FairMCApplication& operator=(const FairMCApplication&);
 
     FairRunInfo fRunInfo;//!
+    Bool_t      fGeometryIsInitialized;
 };
 
 // inline functions
 
 inline FairMCApplication* FairMCApplication::Instance()
-{ return (FairMCApplication*)(TVirtualMCApplication::Instance());}
+{ return static_cast<FairMCApplication*>(TVirtualMCApplication::Instance());}
 
 #endif
diff --git a/base/sim/FairModule.cxx b/base/sim/FairModule.cxx
new file mode 100644
index 0000000..023be61
--- /dev/null
+++ b/base/sim/FairModule.cxx
@@ -0,0 +1,662 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                     FairModule source file                    -----
+// -----            Created 06/01/04  by M. Al-Turany                  -----
+// -------------------------------------------------------------------------
+/* Generated by Together */
+#include "FairModule.h"
+
+#include "FairGeoParSet.h"             // for FairBaseParSet
+#include "FairGeoBuilder.h"             // for FairGeoBuilder
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairRun.h"                    // for FairRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairVolume.h"                 // for FairVolume
+#include "FairVolumeList.h"             // for FairVolumeList
+
+#include "TBuffer.h"                    // for TBuffer, operator<<, etc
+#include "TCollection.h"                // for TIter
+#include "TFile.h"                      // for TFile
+#include "TGeoManager.h"                // for TGeoManager, gGeoManager
+#include "TGeoMaterial.h"               // for TGeoMaterial
+#include "TGeoMatrix.h"                 // for TGeoMatrix, TGeoHMatrix
+#include "TGeoNode.h"                   // for TGeoNode
+#include "TGeoVolume.h"                 // for TGeoVolume
+#include "TGeoVoxelFinder.h"            // for TGeoVoxelFinder
+#include "TKey.h"                       // for TKey
+#include "TList.h"                      // for TList, TListIter
+#include "TObjArray.h"                  // for TObjArray
+#include "TObject.h"                    // for TObject
+#include "TRefArray.h"                  // for TRefArray
+#include "TString.h"                    // for TString, operator!=, etc
+#include "TSystem.h"                    // for TSystem, gSystem
+
+#ifdef ROOT_HAS_GDML
+#include "TGDMLParse.h"
+#endif
+
+#include <stdlib.h>                     // for getenv
+#include <string.h>                     // for NULL, strcmp, strlen
+#include <map>
+
+class FairGeoMedium;
+class TGeoMedium;
+
+TArrayI* FairModule::volNumber=0;
+Int_t FairModule::fNbOfVolumes=0;
+FairVolumeList*  FairModule::vList=0;
+TRefArray*    FairModule::svList=0;
+
+
+
+//__________________________________________________________________________
+void FairModule::ConstructGeometry()
+{
+  LOG(WARNING)<<"The method ConstructGeometry has to be implemented in the detector class which inherits from FairModule"<<FairLogger::endl;
+}
+//__________________________________________________________________________
+void FairModule::ConstructOpGeometry()
+{
+  LOG(DEBUG2)<<"The method ConstructOpGeometry has to be implemented in the detector class which inherits from FairModule"<<FairLogger::endl;;
+}
+//__________________________________________________________________________
+FairModule::~FairModule()
+{
+
+}
+//__________________________________________________________________________
+FairModule::FairModule(const char* Name, const char* title ,Bool_t Active)
+  :TNamed(Name, title),
+   fMotherVolumeName(""),
+   fgeoVer("Not defined"),
+   fgeoName("Not defined"),
+   fModId(-1),
+   fActive(Active),
+   fNbOfSensitiveVol(0),
+   fVerboseLevel(0),
+   flGeoPar(0),
+   kGeoSaved(kFALSE)
+{
+  if(!svList) { svList=new TRefArray(); }
+  if(!vList) { vList=new FairVolumeList(); }
+
+}
+
+//__________________________________________________________________________
+FairModule::FairModule(const FairModule& rhs)
+  :TNamed(rhs),
+   fMotherVolumeName(rhs.fMotherVolumeName),
+   fgeoVer(rhs.fgeoVer),
+   fgeoName(rhs.fgeoName),
+   fModId(rhs.fModId),
+   fActive(rhs.fActive),
+   fNbOfSensitiveVol(rhs.fNbOfSensitiveVol),
+   fVerboseLevel(rhs.fVerboseLevel),
+   flGeoPar(0),
+   kGeoSaved(rhs.kGeoSaved)
+{
+   // Do not change anything in global fields (svList. vList)
+
+  // TO DO - add when we know what type is the elements of flGeoPar
+  //flGeoPar=new TObjArray();
+  //TIter it = rhs.flGeoPar->MakeIterator();
+  // Copy parameters
+  //TObject* obj;
+  //while((obj=it->Next())) {
+  //  flGeoPar->Add(...);
+  //}
+
+}
+
+//__________________________________________________________________________
+
+FairModule::FairModule()
+  : TNamed(),
+    fMotherVolumeName(""),
+    fgeoVer("Not defined"),
+    fgeoName("Not defined"),
+    fModId(-1),
+    fActive(kFALSE),
+    fNbOfSensitiveVol(0),
+    fVerboseLevel(0),
+    flGeoPar(0),
+    kGeoSaved(kFALSE)
+{
+
+}
+
+//__________________________________________________________________________
+FairModule& FairModule::operator= (const FairModule& rhs)
+{
+  // check assignment to self
+  if (this == &rhs) return *this;
+
+  // base class assignment
+  TNamed::operator=(rhs);
+
+  // assignment operator
+  fMotherVolumeName = rhs.fMotherVolumeName;
+  fgeoVer = rhs.fgeoVer;
+  fgeoName = rhs.fgeoName;
+  fModId = rhs.fModId;
+  fActive = rhs.fActive;
+  fNbOfSensitiveVol = rhs.fNbOfSensitiveVol;
+  fVerboseLevel = rhs.fVerboseLevel;
+  flGeoPar = 0;
+  kGeoSaved = rhs.kGeoSaved;
+
+  // TO DO - add when we know what type is the elements of flGeoPar
+  //flGeoPar=new TObjArray();
+  //TIter it = rhs.flGeoPar->MakeIterator();
+  // copy parameters
+  //TObject* obj;
+  //while((obj=it->Next())) {
+  //  flGeoPar->Add(...);
+  //}
+
+  return *this;
+}
+
+//__________________________________________________________________________
+void FairModule::Streamer(TBuffer& b)
+{
+  TNamed::Streamer(b);
+
+
+  if (b.IsReading()) {
+    fgeoVer.Streamer(b);
+    fgeoName.Streamer(b);
+    b >> fActive;
+    b >> fModId;
+  } else {
+    fgeoVer.Streamer(b);
+    fgeoName.Streamer(b);
+    b << fActive;
+    b << fModId;
+  }
+
+}
+//__________________________________________________________________________
+void FairModule::SetGeometryFileName(TString fname, TString)
+{
+
+  // If absolute path is given as argument, try to find it there.
+  // If the file don't exist break. Don't look anywhere else.
+  if ( fname.BeginsWith("/") ) {
+    if ( gSystem->AccessPathName(fname.Data()) ) {
+      LOG(FATAL) << fName << ": geometry file " << fname
+                 << " not found in absolut path!"
+                 << FairLogger::endl;
+      fgeoName = "";
+    } // file not found
+    fgeoName = fname;
+    LOG(DEBUG) << fName << ": using geometry file "
+               << fgeoName << FairLogger::endl;
+    return;
+  }
+
+  // If GEOMPATH is set, try to find the file there.
+  // If there is no such file go on to look in the default location.
+  TString userPath = getenv("GEOMPATH");
+  userPath.ReplaceAll("//","/");
+  if ( ! userPath.IsNull() ) {
+    if ( ! userPath.EndsWith("/") ) {
+      userPath += "/";
+    }
+    fgeoName = userPath + fname;
+    if ( ! gSystem->AccessPathName(fgeoName.Data()) ) {
+      LOG(DEBUG) << fName << ": using geometry file " << fgeoName
+                 << FairLogger::endl;
+      return;
+    }
+    LOG(DEBUG) << fName << ": geometry file " << fname
+               << " not found in GEOMPATH "
+               << userPath << FairLogger::endl;
+  }
+
+  // Look in the standard path
+  fgeoName = getenv("VMCWORKDIR");
+  fgeoName += "/geometry/" + fname;
+  if ( ! gSystem->AccessPathName(fgeoName.Data()) ) {
+    LOG(DEBUG) << fName << ": using geometry file "
+               << fgeoName << FairLogger::endl;
+    return;
+  }
+
+  // File not found
+  LOG(FATAL) << fName << ": geometry file " << fname
+             << " not found in standard path "
+             << FairLogger::endl;
+  fgeoName = "";
+  return;
+
+}
+//__________________________________________________________________________
+void FairModule::ProcessNodes(TList* aList)
+{
+
+  TListIter iter(aList);
+  FairGeoNode* node   = NULL;
+  FairGeoNode* MotherNode =NULL;
+  FairVolume*  volume = NULL;
+  FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
+  FairGeoParSet* par=static_cast<FairGeoParSet*>(rtdb->getContainer("FairGeoParSet"));
+  TObjArray* fNodes = par->GetGeoNodes();
+  while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
+
+    node->calcLabTransform();
+    MotherNode=node->getMotherNode();
+    volume = new FairVolume( node->getTruncName(), fNbOfVolumes++);
+    volume->setRealName(node->GetName());
+    vList->addVolume(volume);
+    volume->setGeoNode(node);
+    volume->setCopyNo(  node->getCopyNo());
+
+    if(MotherNode!=0) {
+      volume->setMotherId(node->getMCid());
+      volume->setMotherCopyNo(MotherNode->getCopyNo());
+    }
+    FairGeoVolume* aVol=NULL;
+
+    if ( node->isSensitive() && fActive ) {
+      volume->setModId(fModId);
+      volume->SetModule(this);
+      svList->Add(volume);
+      aVol = dynamic_cast<FairGeoVolume*> ( node );
+      fNodes->AddLast( aVol );
+      fNbOfSensitiveVol++;
+    }
+
+  }
+}
+//__________________________________________________________________________
+void  FairModule::AddSensitiveVolume(TGeoVolume* v)
+{
+
+  LOG(DEBUG2)<<"AddSensitiveVolume " << v->GetName() << FairLogger::endl;
+  // Only register volumes which are not already registered
+  // Otherwise the stepping will be slowed down
+  if( ! vList->findObject(v->GetName() ) ) {
+    FairVolume*  volume = NULL;
+    volume = new FairVolume(v->GetName(), fNbOfVolumes++);
+    vList->addVolume(volume);
+    volume->setModId(fModId);
+    volume->SetModule(this);
+    svList->Add(volume);
+    fNbOfSensitiveVol++;
+  }
+}
+
+
+//__________________________________________________________________________
+FairVolume* FairModule::getFairVolume(FairGeoNode* fN)
+{
+  FairVolume* fv;
+  FairVolume*  fvol=0;
+  for(Int_t i=0; i<vList->getEntries(); i++) {
+    fv=vList->At(i);
+    if((fv->getGeoNode())==fN) {
+      fvol=fv;
+      return fvol;
+      break;
+    }
+  }
+  return fvol;
+}
+//__________________________________________________________________________
+void FairModule::ConstructRootGeometry()
+{
+  /** Construct the detector geometry from ROOT files, possible inputs are:
+   * 1. A TGeoVolume as a mother (master) volume containing the detector geometry
+   * 2. A TGeoManager with the detector geometry
+   * 3. A TGeoVolume as a mother or Master volume which is the output of the CAD2ROOT geometry, in this case
+   *    the materials are not proprely defined and had to be reset
+   *  In all cases we have to check that the material properties are the same or is the materials defined in
+   *  the current simulation session
+   */
+  TGeoManager* OldGeo=gGeoManager;
+  TGeoManager* NewGeo=0;
+  TGeoVolume* volume=0;;
+  TFile* f=new TFile(GetGeometryFileName().Data());
+  TList* l= f->GetListOfKeys();
+  TKey* key;
+  TIter next( l);
+  TGeoNode* n=0;
+  TGeoVolume* v1=0;
+  while ((key = static_cast<TKey*>(next()))) {
+    /**loop inside the delivered root file and try to fine a TGeoManager object
+     * the first TGeoManager found will be read
+     */
+    if (strcmp(key->GetClassName(),"TGeoManager") != 0) { continue; }
+    gGeoManager=0;
+    NewGeo = static_cast<TGeoManager*>(key->ReadObj());
+    break;
+  }
+  if (NewGeo!=0) {
+    /** in case a TGeoManager was found get the top most volume and the node
+     */
+
+    NewGeo->cd();
+    volume=static_cast<TGeoVolume*>(NewGeo->GetNode(0)->GetDaughter(0)->GetVolume());
+    v1=volume->MakeCopyVolume(volume->GetShape());
+    // n=NewGeo->GetTopNode();
+    n=v1->GetNode(0);
+    //  NewGeo=0;
+    // delete NewGeo; //move it to the end of the method
+
+  } else {
+    /** The file does not contain any TGeoManager, so we assume to have a file with a TGeoVolume
+     * try to look for a TGeoVolume inside the file
+     */
+
+    key=static_cast<TKey*>(l->At(0));  //Get the first key in the list
+    volume=dynamic_cast<TGeoVolume*> (key->ReadObj());
+    if(volume!=0) { n=volume->GetNode(0); }
+    if(n!=0) { v1=n->GetVolume(); }
+  }
+
+  if(v1==0) {
+    LOG(FATAL)<<"Could not find any geometry in file " << GetGeometryFileName().Data() << FairLogger::endl;
+  } else {
+    gGeoManager=OldGeo;
+    gGeoManager->cd();
+    // If AddToVolume is empty add the volume to the top volume Cave
+    // If it is defined check i´f the volume exists and if it exists add the volume from the root file
+    // to the already existing volume
+    TGeoVolume* Cave=NULL;
+    if ( 0 == fMotherVolumeName.Length() ) {
+      Cave= gGeoManager->GetTopVolume();
+    } else {
+      Cave = gGeoManager->GetVolume(fMotherVolumeName);
+    }
+    if(Cave!=NULL) {
+      /**Every thing is OK, we have a TGeoVolume and now we add it to the simulation TGeoManager  */
+      gGeoManager->AddVolume(v1);
+      /** force rebuilding of voxels */
+      TGeoVoxelFinder* voxels = v1->GetVoxels();
+      if (voxels) { voxels->SetNeedRebuild(); }
+
+      // else { fLogger->Fatal(MESSAGE_ORIGIN, "\033[5m\033[31mFairModule::ConstructRootGeometry(): could not find voxels  \033[0m"); }
+
+      /**To avoid having different names of the default matrices because we could have get the volume from another
+       * TGeoManager, we reset the default matrix name
+       */
+      TGeoMatrix* M = n->GetMatrix();
+      SetDefaultMatrixName(M);
+
+      /** NOw we can remove the matrix so that the new geomanager will rebuild it properly*/
+      gGeoManager->GetListOfMatrices()->Remove(M);
+      TGeoHMatrix* global = gGeoManager->GetHMatrix();
+      gGeoManager->GetListOfMatrices()->Remove(global); //Remove the Identity matrix
+      /**Now we can add the node to the existing cave */
+      Cave->AddNode(v1,0, M);
+      /** correction from O. Merle: in case of a TGeoVolume (v1) set the material properly */
+
+      AssignMediumAtImport(v1);
+      /** now go through the herachy and set the materials properly, this is important becase the CAD converter
+       *  produce TGeoVolumes with materials that have only names and no properties
+       */
+      ExpandNode(n);
+      if(NewGeo!=0) { delete NewGeo; }
+      delete f;
+    } else {
+      LOG(FATAL)<<"Could not find the given mother volume "<< fMotherVolumeName.Data() << " where the geomanger should be added."<<FairLogger::endl;
+    }
+  }
+}
+
+#ifdef ROOT_HAS_GDML
+
+void FairModule::ConstructGDMLGeometry(TGeoMatrix* posrot)
+{
+    // Parse the GDML file
+    TFile *old = gFile;
+	TGDMLParse parser;
+	TGeoVolume* gdmlTop;
+	gdmlTop = parser.GDMLReadFile(GetGeometryFileName());
+
+    // Change ID of media. TGDMLParse starts allways from 0. Need to shift.
+    ReAssignMediaId();
+
+    // Add volume to the cave and go through it recursively
+	gGeoManager->GetTopVolume()->AddNode(gdmlTop,1,posrot);
+	ExpandNodeForGDML(gGeoManager->GetTopVolume()->GetNode(gGeoManager->GetTopVolume()->GetNdaughters()-1));
+    gFile = old;
+}
+
+void FairModule::ExpandNodeForGDML(TGeoNode* curNode)
+{
+    // Get pointer to volume and assign medium
+	TGeoVolume* curVol = curNode->GetVolume();
+    AssignMediumAtImport(curVol);
+
+    // Check if the volume is sensitive
+    if ( (this->InheritsFrom("FairDetector")) && CheckIfSensitive(curVol->GetName())) {
+        LOG(DEBUG2)<<"Sensitive Volume "<< curVol->GetName() << FairLogger::endl;
+        AddSensitiveVolume(curVol);
+    }
+
+	//! Recursevly go down the tree of nodes
+	if (curVol->GetNdaughters() != 0)
+	{
+		TObjArray* NodeChildList = curVol->GetNodes();
+		TGeoNode* curNodeChild;
+		for (Int_t j=0; j<NodeChildList->GetEntriesFast(); j++)
+		{
+			curNodeChild = static_cast<TGeoNode*>(NodeChildList->At(j));
+			ExpandNodeForGDML(curNodeChild);
+		}
+	}
+}
+
+#else
+
+void FairModule::ConstructGDMLGeometry(TGeoMatrix* posrot)
+{
+    gLogger->Error(MESSAGE_ORIGIN," Could not construct magnet geometry from gdml file. ");
+    gLogger->Error(MESSAGE_ORIGIN," The used ROOT version does not support gdml. ");
+    gLogger->Error(MESSAGE_ORIGIN," Please recompile ROOT with gdml support. ");
+    gLogger->Fatal(MESSAGE_ORIGIN," Stop execution at this point. ");
+}
+
+void FairModule::ExpandNodeForGDML(TGeoNode* curNode)
+{
+}
+
+#endif
+
+void FairModule::ReAssignMediaId()
+{
+    // Initialise pointer to GeoBuilder
+    FairGeoBuilder* geoBuilder = FairGeoLoader::Instance()->getGeoBuilder();
+    // Get list of TGeo media
+    TList* media = gGeoManager->GetListOfMedia();
+    // Loop over new media which are not in GeoBase and shift the ID
+    TGeoMedium* med;
+//    TGeoMedium* med2;
+    for(Int_t i = geoBuilder->GetNMedia(); i < media->GetEntries(); i++)
+    {
+        med = static_cast<TGeoMedium*>(media->At(i));
+        med->SetId(i+1);
+    }
+    // Change GeoBase medium index
+    geoBuilder->SetNMedia(media->GetEntries());
+
+    // Revove dublicated materials
+    TList* materials = gGeoManager->GetListOfMaterials();
+    TIter next1(materials);
+    // map for existing materials
+    std::map<TString, Bool_t> mapMatName;
+    TGeoMaterial* mat;
+    while( (mat = static_cast<TGeoMaterial*>(next1())) )
+    {
+        // If material exist - delete dublicated. If not - set the flag
+        if(mapMatName[mat->GetName()])
+        {
+            materials->Remove(mat);
+        }
+        else
+        {
+            mapMatName[mat->GetName()] = kTRUE;
+        }
+    }
+}
+
+//__________________________________________________________________________
+void FairModule::ConstructASCIIGeometry()
+{
+  LOG(WARNING)<<"The method ConstructASCIIGeometry has to be implemented in the detector class which inherits from FairModule"<<FairLogger::endl;
+}
+
+//__________________________________________________________________________
+Bool_t FairModule::CheckIfSensitive(std::string)
+{
+  LOG(WARNING)<<"The method CheckIfSensitive has to be implemented in the detector class which inherits from FairModule"<<FairLogger::endl;
+  return kFALSE;
+}
+
+//__________________________________________________________________________
+void FairModule::ExpandNode(TGeoNode* fN)
+{
+  //FairGeoLoader* geoLoad = FairGeoLoader::Instance();
+  //FairGeoInterface* geoFace = geoLoad->getGeoInterface();
+  //FairGeoMedia* Media =  geoFace->getMedia();
+  //FairGeoBuilder* geobuild=geoLoad->getGeoBuilder();
+  TGeoMatrix* Matrix =fN->GetMatrix();
+  if(gGeoManager->GetListOfMatrices()->FindObject(Matrix)) { gGeoManager->GetListOfMatrices()->Remove(Matrix); }
+  TGeoVolume* v1=fN->GetVolume();
+  TObjArray* NodeList=v1->GetNodes();
+  for (Int_t Nod=0; Nod<NodeList->GetEntriesFast(); Nod++) {
+    TGeoNode* fNode =static_cast<TGeoNode*>(NodeList->At(Nod));
+    TGeoMatrix* M =fNode->GetMatrix();
+    //M->SetDefaultName();
+    SetDefaultMatrixName(M);
+    if(fNode->GetNdaughters()>0) { ExpandNode(fNode); }
+    TGeoVolume* v= fNode->GetVolume();
+    AssignMediumAtImport(v);
+    if (!gGeoManager->FindVolumeFast(v->GetName())) {
+      LOG(DEBUG2)<<"Register Volume " << v->GetName()<<FairLogger::endl;
+      v->RegisterYourself();
+    }
+    if ( (this->InheritsFrom("FairDetector")) && CheckIfSensitive(v->GetName())) {
+      LOG(DEBUG2)<<"Sensitive Volume "<< v->GetName() << FairLogger::endl;
+      AddSensitiveVolume(v);
+    }
+  }
+}
+
+//__________________________________________________________________________
+void FairModule::SetDefaultMatrixName(TGeoMatrix* matrix)
+{
+  // Copied from root TGeoMatrix::SetDefaultName() and modified (memory leak)
+  // If no name was supplied in the ctor, the type of transformation is checked.
+  // A letter will be prepended to the name :
+  //   t - translation
+  //   r - rotation
+  //   s - scale
+  //   c - combi (translation + rotation)
+  //   g - general (tr+rot+scale)
+  // The index of the transformation in gGeoManager list of transformations will
+  // be appended.
+  if (!gGeoManager) { return; }
+  if (strlen(matrix->GetName())) { return; }
+  char type = 'n';
+  if (matrix->IsTranslation()) { type = 't'; }
+  if (matrix->IsRotation()) { type = 'r'; }
+  if (matrix->IsScale()) { type = 's'; }
+  if (matrix->IsCombi()) { type = 'c'; }
+  if (matrix->IsGeneral()) { type = 'g'; }
+  TObjArray* matrices = gGeoManager->GetListOfMatrices();
+  Int_t index = 0;
+  if (matrices) { index =matrices->GetEntriesFast() - 1; }
+  matrix->SetName(Form("%c%i", type, index));
+}
+
+//__________________________________________________________________________
+
+void FairModule::AssignMediumAtImport(TGeoVolume* v)
+{
+
+  /**
+   * Assign medium to the the volume v, this has to be done in all cases:
+   * case 1: For CAD converted volumes they have no mediums (only names)
+   * case 2: TGeoVolumes, we need to be sure that the material is defined in this session
+   */
+  FairGeoMedia* Media       = FairGeoLoader::Instance()->getGeoInterface()->getMedia();
+  FairGeoBuilder* geobuild  = FairGeoLoader::Instance()->getGeoBuilder();
+
+  TGeoMedium* med1=v->GetMedium();
+
+
+  if(med1) {
+    // In newer ROOT version also a TGeoVolumeAssembly has a material and medium.
+    // This medium is called dummy and is automatically set when the geometry is constructed.
+    // Since this material and medium is neither in the TGeoManager (at this point) nor in our
+    // ASCII file we have to create it the same way it is done in TGeoVolume::CreateDummyMedium()
+    // In the end the new medium and material has to be added to the TGeomanager, because this is
+    // not done automatically when using the default constructor. For all other constructors the
+    // newly created medium or material is added to the TGeomanger.
+    // Create the medium and material only the first time.
+    TString medName = static_cast<TString>(med1->GetName());
+    if ( medName.EqualTo("dummy") && NULL == gGeoManager->GetMedium(medName) ) {
+
+      TGeoMaterial *dummyMaterial = new TGeoMaterial();
+      dummyMaterial->SetName("dummy");
+
+      TGeoMedium* dummyMedium = new TGeoMedium();
+      dummyMedium->SetName("dummy");
+      dummyMedium->SetMaterial(dummyMaterial);
+
+      gGeoManager->GetListOfMedia()->Add(dummyMedium);
+      gGeoManager->AddMaterial(dummyMaterial);
+    }
+
+    TGeoMaterial* mat1=v->GetMaterial();
+    TGeoMaterial* newMat = gGeoManager->GetMaterial(mat1->GetName());
+    if( newMat==0) {
+      /**The Material is not defined in the TGeoManager, we try to create one if we have enough information about it*/
+      FairGeoMedium* FairMedium=Media->getMedium(mat1->GetName());
+      if (!FairMedium) {
+        LOG(FATAL)<<"Material "<< mat1->GetName() << "is not defined in ASCII file nor in Root file." << FairLogger::endl;
+        //     FairMedium=new FairGeoMedium(mat1->GetName());
+        //      Media->addMedium(FairMedium);
+      } else {
+
+        Int_t nmed=geobuild->createMedium(FairMedium);
+        v->SetMedium(gGeoManager->GetMedium(nmed));
+        gGeoManager->SetAllIndex();
+      }
+    } else {
+      /**Material is already available in the TGeoManager and we can set it */
+      TGeoMedium* med2= gGeoManager->GetMedium(mat1->GetName());
+      v->SetMedium(med2);
+    }
+  } else {
+    if (strcmp(v->ClassName(),"TGeoVolumeAssembly") != 0) {
+      //[R.K.-3.3.08]  // When there is NO material defined, set it to avoid conflicts in Geant
+      LOG(FATAL)<<"The volume "<< v->GetName() << "has no medium information and not an Assembly so we have to quit"<<FairLogger::endl;
+    }
+  }
+}
+
+//__________________________________________________________________________
+FairModule* FairModule::CloneModule() const
+{
+  Fatal("CloneModule","Has to be overriden in multi-threading applications.");
+  return 0;
+}
+
+//__________________________________________________________________________
+ClassImp(FairModule)
+
+
+
diff --git a/base/sim/FairModule.h b/base/sim/FairModule.h
new file mode 100644
index 0000000..00fdf88
--- /dev/null
+++ b/base/sim/FairModule.h
@@ -0,0 +1,203 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRMODULE_H
+#define FAIRMODULE_H
+
+#include "TNamed.h"                     // for TNamed
+
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoVolume.h"              // for FairGeoVolume
+#include "FairLogger.h"                 // for FairLogLevel::INFO, etc
+#include "FairRun.h"                    // for FairRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+
+#include "Rtypes.h"                     // for Bool_t, Int_t, etc
+#include "TList.h"                      // for TList (ptr only), TListIter
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString, operator!=
+
+#include <stddef.h>                     // for NULL
+#include <string>                       // for string
+
+class FairVolumeList;
+class FairVolume;
+class TArrayI;
+class TGeoMatrix;
+class TGeoNode;
+class TGeoVolume;
+class TGeoMedium;
+class TRefArray;
+
+/**
+ * Base class for constructing all detecors and passive volumes
+ * @author M. Al-Turany, Denis Bertini
+ * @version 1.0
+ * @since 01.04.08 M.Al-Turany
+ * Add methods to construct geometry via ROOT files
+ * Add some documentation
+ *
+ * Changelog: 29.02.2012 [O.Merle] Fixed missing material assignment for top volume.
+ *                                 ... and please - add some documentation to your code.
+ */
+class FairModule:  public TNamed
+{
+  public:
+    /**default ctor*/
+    FairModule();
+    /**Standard ctor*/
+    FairModule(const char* Name, const char* title, Bool_t Active=kFALSE);
+    /**default dtor*/
+    virtual  ~FairModule();
+    /**Print method should be implemented in detector or module*/
+    virtual void        Print(Option_t*) const {;}
+    /**Set the geometry file name o be used*/
+    virtual void        SetGeometryFileName(TString fname, TString geoVer="0");
+    /**Get the Geometry file name*/
+    virtual TString     GetGeometryFileName() {return  fgeoName ;}
+    /**Get the geometry file version if used*/
+    virtual TString     GetGeometryFileVer() {return   fgeoVer ;}
+    /**method called from the MC application to construct the geometry, has to be implimented by user*/
+    virtual void        ConstructGeometry();
+    /**method called from the MC application to set optical geometry properties*/
+    virtual void        ConstructOpGeometry();
+    /**construct geometry from root files (TGeo)*/
+    virtual void        ConstructRootGeometry();
+    /**construct geometry from standard ASSCII files (Hades Format)*/
+    virtual void        ConstructASCIIGeometry();
+    /** Modify the geometry for the simulation run using methods of the Root geometry package */
+    virtual void        ModifyGeometry() {;}
+    /**construct geometry from GDML files*/
+    virtual void        ConstructGDMLGeometry(TGeoMatrix*);
+    /** Clone this object (used in MT mode only)*/
+    virtual FairModule* CloneModule() const;
+    /** Init worker run (used in MT mode only) */
+    virtual void BeginWorkerRun() const {;}
+    /** Finish worker run (used in MT mode only) */
+    virtual void FinishWorkerRun() const {;}
+
+    /**template function to construct geometry. to be used in derived classes.*/
+    template<class T, class U>
+    void ConstructASCIIGeometry(T dataType1, TString containerName="", U datatype2 = NULL);
+
+    /**Set the sensitivity flag for volumes, called from ConstructASCIIRootGeometry(), and has to be implimented for detectors
+     * which use ConstructASCIIRootGeometry() to build the geometry */
+    virtual Bool_t      CheckIfSensitive(std::string name);
+    /**called from ConstructRootGeometry()*/
+    virtual void        ExpandNode(TGeoNode* Node);
+    /**called from ConstructGDMLGeometry()*/
+    virtual void        ExpandNodeForGDML(TGeoNode*);
+    /**return the MC id of a volume named vname*/
+    virtual Int_t       getVolId( const TString& ) const {return 0;}
+    /**return the detector/Module id (which was set in the sim macro for the detector)*/
+    Int_t               GetModId() {return fModId;}
+    /**Set the verbose level in this detector*/
+    void                SetVerboseLevel(Int_t level) {fVerboseLevel=level;}
+    /**return the detector status */
+    Bool_t              IsActive() {return fActive;}
+    /**set the detector/module id*/
+    void                SetModId(Int_t id) {fModId=id;}
+    /** Set the name of the mother volume to which a new geometry is added.
+     ** This function is needed for geometries which are defined as ROOT geometry manager.
+     **/
+    void                SetMotherVolume(TString volName) {fMotherVolumeName=volName;}
+    /**called from ConstuctASCIIGeometry*/
+    void   ProcessNodes ( TList* aList );
+    /**Set the parameter containers*/
+    virtual  void       SetParContainers() {;}
+    /** Initialize everything which has to be done before the construction and modification
+     ** of the geometry. Mostly this is needed to read data from the parameter containers.*/
+    virtual  void       InitParContainers() {;}
+    /**return the geo parameter of this detector/module*/
+    TList* GetListOfGeoPar() { return flGeoPar;}
+
+    /**list of volumes in a simulation session*/
+    static              FairVolumeList*   vList; //!
+    /**total number of volumes in a simulaion session*/
+    static Int_t        fNbOfVolumes;  //!
+    /**list of all sensitive volumes in  a simulaion session*/
+    static TRefArray*   svList;   //!
+
+    static TArrayI*     volNumber; //!
+    TString             fMotherVolumeName; //!
+    FairVolume*   getFairVolume(FairGeoNode* fNode);
+    void    AddSensitiveVolume(TGeoVolume* v);
+  private:
+    /** Re-implimented from ROOT:  TGeoMatrix::SetDefaultName()  */
+    void SetDefaultMatrixName(TGeoMatrix* matrix);
+    void AssignMediumAtImport(TGeoVolume* v);  // O.Merle, 29.02.2012 - see impl.
+
+    /**called from ConstructGDMLGeometry. Changes default ID created by TGDMLParse*/
+    void ReAssignMediaId();
+    void swap(FairModule& other) throw();
+
+  protected:
+    FairModule(const FairModule&);
+    FairModule& operator=(const FairModule&);
+    TString             fgeoVer;
+    TString             fgeoName;
+    Int_t               fModId;
+    Bool_t              fActive;
+    Int_t               fNbOfSensitiveVol; //!
+    Int_t               fVerboseLevel;
+    TList*              flGeoPar; //!  list of Detector Geometry parameters
+    Bool_t              kGeoSaved; //! flag for initialisation
+
+    ClassDef( FairModule,4)
+};
+
+template<class T, class U>
+void FairModule::ConstructASCIIGeometry(T dataType1, TString containerName, U)
+{
+  FairGeoLoader* loader=FairGeoLoader::Instance();
+  FairGeoInterface* GeoInterface =loader->getGeoInterface();
+  T* MGeo=new T();
+  MGeo->print();
+  MGeo->setGeomFile(GetGeometryFileName());
+  GeoInterface->addGeoModule(MGeo);
+  Bool_t rc = GeoInterface->readSet(MGeo);
+  if ( rc ) { MGeo->create(loader->getGeoBuilder()); }
+
+  TList* volList = MGeo->getListOfVolumes();
+  // store geo parameter
+  FairRun* fRun = FairRun::Instance();
+  FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
+
+  dataType1 = *MGeo;
+
+  if ( "" != containerName) {
+    LOG(INFO) << "Add GeoNodes for "<< MGeo->getDescription()
+              << " to container " << containerName << FairLogger::endl;
+
+    //    U par=(U)(rtdb->getContainer(containerName));
+    U*      par=static_cast<U*>(rtdb->getContainer(containerName));
+    TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
+    TObjArray* fPassNodes = par->GetGeoPassiveNodes();
+
+    TListIter iter(volList);
+    FairGeoNode* node   = NULL;
+    FairGeoVolume* aVol=NULL;
+
+    while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
+      aVol = dynamic_cast<FairGeoVolume*> ( node );
+      if ( node->isSensitive()  ) {
+        fSensNodes->AddLast( aVol );
+      } else {
+        fPassNodes->AddLast( aVol );
+      }
+    }
+    ProcessNodes( volList );
+    par->setChanged();
+    par->setInputVersion(fRun->GetRunId(),1);
+
+  }
+}
+
+
+#endif //FAIRMODULE_H
diff --git a/base/FairParticle.cxx b/base/sim/FairParticle.cxx
similarity index 85%
rename from base/FairParticle.cxx
rename to base/sim/FairParticle.cxx
index 69b636b..f30f722 100644
--- a/base/FairParticle.cxx
+++ b/base/sim/FairParticle.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                   FairParticle source file                    -----
 // -----            Created 06/01/04  by M. Al-Turany                  -----
@@ -6,14 +13,16 @@
 
 // Extended TParticle with pointers to mother and daughters
 // particles
-
 #include "FairParticle.h"
 
-#include "TParticle.h"
-#include "TMCParticleType.h"
-#include <iostream>
-#include "TParticlePDG.h"
-#include "TDatabasePDG.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TMCParticleType.h"            // for TMCParticleType::kPTIon, etc
+#include "TParticle.h"                  // for TParticle
+#include "TParticlePDG.h"               // for TParticlePDG
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
 using std::cout;
 using std::endl;
 
@@ -32,10 +41,10 @@ FairParticle::FairParticle(Int_t id, TParticle* particle)
     fDecayTime(particle->GetPDG()->Lifetime()),
     fpType("Ion"),
     fwidth(particle->GetPDG()->Width()),
-    fiSpin((Int_t)particle->GetPDG()->Spin()),
+    fiSpin(static_cast<Int_t>(particle->GetPDG()->Spin())),
     fiParity(particle->GetPDG()->Parity()),
     fiConjugation(0),
-    fiIsospin((Int_t)particle->GetPDG()->Isospin()),
+    fiIsospin(static_cast<Int_t>(particle->GetPDG()->Isospin())),
     fiIsospinZ(0),
     fgParity(0),
     flepton(0),
@@ -88,10 +97,10 @@ FairParticle::FairParticle(const char* name, Int_t z, Int_t a, Int_t s,Double_t
   fcharge= fParticle->GetPDG()->Charge();
   fDecayTime=decaytime ;
   fwidth=   fParticle->GetPDG()->Width();
-  fiSpin=   (Int_t)fParticle->GetPDG()->Spin();
+  fiSpin=   static_cast<Int_t>(fParticle->GetPDG()->Spin());
   fiParity=  fParticle->GetPDG()->Parity();
   fiConjugation= 0;
-  fiIsospin= (Int_t) fParticle->GetPDG()->Isospin();
+  fiIsospin= static_cast<Int_t>(fParticle->GetPDG()->Isospin());
   fiIsospinZ= 0;
   fgParity= 0;
   flepton=  0;
@@ -148,10 +157,10 @@ FairParticle::FairParticle(const char* name, Int_t z, Int_t a, Double_t mass ,In
   fcharge= fParticle->GetPDG()->Charge();
   fDecayTime=decaytime ;
   fwidth=   fParticle->GetPDG()->Width();
-  fiSpin=   (Int_t)fParticle->GetPDG()->Spin();
+  fiSpin=   static_cast<Int_t>(fParticle->GetPDG()->Spin());
   fiParity=  fParticle->GetPDG()->Parity();
   fiConjugation= 0;
-  fiIsospin= (Int_t) fParticle->GetPDG()->Isospin();
+  fiIsospin= static_cast<Int_t>(fParticle->GetPDG()->Isospin());
   fiIsospinZ= 0;
   fgParity= 0;
   flepton=  0;
@@ -297,7 +306,7 @@ void FairParticle::AddDaughter(FairParticle* particle)
 }
 
 //_____________________________________________________________________________
-void FairParticle::Print(Option_t* option) const
+void FairParticle::Print(Option_t*) const
 {
 // Prints particle properties.
 // ---
@@ -355,7 +364,7 @@ FairParticle* FairParticle::GetMother() const
 // Returns particle definition (TParticle).
 // ---
 
-  return (FairParticle*) fMother.GetObject();
+  return static_cast<FairParticle*>(fMother.GetObject());
 }
 
 //_____________________________________________________________________________
@@ -377,6 +386,6 @@ FairParticle* FairParticle::GetDaughter(Int_t i) const
     Fatal("GetDaughter", "Index out of range");
   }
 
-  return (FairParticle*) fDaughters.At(i);
+  return static_cast<FairParticle*>(fDaughters.At(i));
 }
 
diff --git a/base/FairParticle.h b/base/sim/FairParticle.h
similarity index 77%
rename from base/FairParticle.h
rename to base/sim/FairParticle.h
index 6738559..e006496 100644
--- a/base/FairParticle.h
+++ b/base/sim/FairParticle.h
@@ -1,18 +1,27 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /// Class FAIRParticle
 /// ------------------
 /// Extended TParticle with persistent pointers to mother and daughters
 /// particles  (Ivana Hrivnacova, 5.4.2002)
 /// Used to define particles which will be added to Geant3/4 (M. Al-Turany)
 
-
 #ifndef FAIR_PARTICLE_H
 #define FAIR_PARTICLE_H
 
-#include "TObject.h"
-#include "TRef.h"
-#include "TRefArray.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Int_t, Double_t, Bool_t, etc
+#include "TMCParticleType.h"            // for TMCParticleType
+#include "TRef.h"                       // for TRef
+#include "TRefArray.h"                  // for TRefArray
+#include "TString.h"                    // for TString
 
-#include "TMCParticleType.h"
 class TParticle;
 
 class FairParticle : public TObject
diff --git a/base/sim/FairPrimaryGenerator.cxx b/base/sim/FairPrimaryGenerator.cxx
new file mode 100644
index 0000000..006b358
--- /dev/null
+++ b/base/sim/FairPrimaryGenerator.cxx
@@ -0,0 +1,489 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ *                                                                              *
+ *              This software is distributed under the terms of the *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3, *
+ *                  copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
+
+#include "FairPrimaryGenerator.h"
+
+#include "FairGenerator.h"     // for FairGenerator
+#include "FairGenericStack.h"  // for FairGenericStack
+#include "FairLogger.h"        // for FairLogger, MESSAGE_ORIGIN
+#include "FairMCEventHeader.h" // for FairMCEventHeader
+
+#include "TDatabasePDG.h" // for TDatabasePDG
+#include "TF1.h"          // for TF1
+#include "TIterator.h"    // for TIterator
+#include "TMCProcess.h"   // for TMCProcess::kPPrimary
+#include "TMath.h"        // for Sqrt
+#include "TObject.h"      // for TObject
+#include "TParticlePDG.h" // for TParticlePDG
+#include "TRandom.h"      // for TRandom, gRandom
+#include "TString.h"      // for TString
+
+#include <stddef.h> // for NULL
+#include <iostream> // for operator<<, basic_ostream, etc
+
+using std::cout;
+using std::cerr;
+using std::endl;
+
+Int_t FairPrimaryGenerator::fTotPrim = 0;
+
+// -----   Default constructor   -------------------------------------------
+FairPrimaryGenerator::FairPrimaryGenerator()
+    : TNamed(), fBeamX0(0.), fBeamY0(0.), fBeamSigmaX(0.), fBeamSigmaY(0.),
+      fBeamAngleX0(0.), fBeamAngleY0(0.), fBeamAngleX(0.), fBeamAngleY(0.),
+      fBeamAngleSigmaX(0.), fBeamAngleSigmaY(0.),
+      fBeamDirection(TVector3(0., 0., 1.)), fPhiMin(0.), fPhiMax(0.), fPhi(0.),
+      fTargetZ(new Double_t[1]), fNrTargets(1), fTargetDz(0),
+      fVertex(TVector3(0., 0., 0.)), fNTracks(0), fSmearVertexZ(kFALSE),
+      fSmearGausVertexZ(kFALSE), fSmearVertexXY(kFALSE),
+      fSmearGausVertexXY(kFALSE), fBeamAngle(kFALSE), fEventPlane(kFALSE),
+      fStack(NULL), fGenList(new TObjArray()),
+      fListIter(fGenList->MakeIterator()), fEvent(NULL), fdoTracking(kTRUE),
+      fMCIndexOffset(0), fEventNr(0) {
+  fTargetZ[0] = 0.;
+}
+// -------------------------------------------------------------------------
+
+// -----   Constructor with title and name   -------------------------------
+FairPrimaryGenerator::FairPrimaryGenerator(const char *name, const char *title)
+    : TNamed(name, title), fBeamX0(0), fBeamY0(0), fBeamSigmaX(0),
+      fBeamSigmaY(0), fBeamAngleX0(0), fBeamAngleY0(0), fBeamAngleX(0),
+      fBeamAngleY(0), fBeamAngleSigmaX(0), fBeamAngleSigmaY(0),
+      fBeamDirection(TVector3(0., 0., 1.)), fPhiMin(0.), fPhiMax(0.), fPhi(0.),
+      fTargetZ(new Double_t[1]), fNrTargets(1), fTargetDz(0),
+      fVertex(TVector3(0., 0., 0.)), fNTracks(0), fSmearVertexZ(kFALSE),
+      fSmearGausVertexZ(kFALSE), fSmearVertexXY(kFALSE),
+      fSmearGausVertexXY(kFALSE), fBeamAngle(kFALSE), fEventPlane(kFALSE),
+      fStack(NULL), fGenList(new TObjArray()),
+      fListIter(fGenList->MakeIterator()), fEvent(NULL), fdoTracking(kTRUE),
+      fMCIndexOffset(0), fEventNr(0) {
+  fTargetZ[0] = 0.;
+}
+
+// -----   Copy constructor   ----------------------------------------------
+FairPrimaryGenerator::FairPrimaryGenerator(const FairPrimaryGenerator &rhs)
+    : TNamed(rhs), fBeamX0(rhs.fBeamX0), fBeamY0(rhs.fBeamY0),
+      fBeamSigmaX(rhs.fBeamSigmaX), fBeamSigmaY(rhs.fBeamSigmaY),
+      fBeamAngleX0(rhs.fBeamAngleX0), fBeamAngleY0(rhs.fBeamAngleY0),
+      fBeamAngleX(rhs.fBeamAngleX), fBeamAngleY(rhs.fBeamAngleY),
+      fBeamAngleSigmaX(rhs.fBeamAngleSigmaX), fBeamAngleSigmaY(rhs.fBeamAngleSigmaY),
+      fBeamDirection(rhs.fBeamDirection),
+      fPhiMin(rhs.fPhiMin), fPhiMax(rhs.fPhiMax), fPhi(rhs.fPhi),
+      fTargetZ(new Double_t[1]), fNrTargets(rhs.fNrTargets),
+      fTargetDz(rhs.fTargetDz), fVertex(rhs.fVertex), fNTracks(rhs.fNTracks),
+      fSmearVertexZ(rhs.fSmearVertexZ), fSmearGausVertexZ(rhs.fSmearGausVertexZ),
+      fSmearVertexXY(rhs.fSmearVertexXY), fSmearGausVertexXY(rhs.fSmearGausVertexXY),
+      fBeamAngle(rhs.fBeamAngle), fEventPlane(rhs.fEventPlane),
+      fStack(NULL), fGenList(new TObjArray()),
+      fListIter(fGenList->MakeIterator()), fEvent(NULL), fdoTracking(rhs.fdoTracking),
+      fMCIndexOffset(rhs.fMCIndexOffset), fEventNr(rhs.fEventNr) {
+  fTargetZ[0] = rhs.fTargetZ[0];
+}
+
+// -------------------------------------------------------------------------
+Bool_t FairPrimaryGenerator::Init() {
+  /** Initialize list of generators*/
+  for (Int_t i = 0; i < fGenList->GetEntries(); i++) {
+    FairGenerator *gen = static_cast<FairGenerator*>(fGenList->At(i));
+    if (gen) {
+      gen->Init();
+    }
+  }
+  return kTRUE;
+}
+
+// -----   Destructor   ----------------------------------------------------
+FairPrimaryGenerator::~FairPrimaryGenerator() {
+  //  cout<<"Enter Destructor of FairPrimaryGenerator"<<endl;
+  // the stack is deleted by FairMCApplication
+  if (1 == fNrTargets) {
+    delete fTargetZ;
+  } else {
+    delete[] fTargetZ;
+  }
+  fGenList->Delete();
+  delete fGenList;
+  delete fListIter;
+
+  //  cout<<"Leave Destructor of FairPrimaryGenerator"<<endl;
+}
+// -------------------------------------------------------------------------
+
+// -----   Assignment operator   -------------------------------------------
+FairPrimaryGenerator& FairPrimaryGenerator::operator=(const FairPrimaryGenerator& rhs)
+{
+  // check assignment to self
+  if (this != &rhs) {
+    
+    // base class assignment
+    TNamed::operator=(rhs);
+    
+    // assignment operator
+    fBeamX0 = rhs.fBeamX0;
+    fBeamY0 = rhs.fBeamY0;
+    fBeamSigmaX = rhs.fBeamSigmaX;
+    fBeamSigmaY = rhs.fBeamSigmaY;
+    fBeamAngleX0 = rhs.fBeamAngleX0;
+    fBeamAngleY0 = rhs.fBeamAngleY0;
+    fBeamAngleX = rhs.fBeamAngleX;
+    fBeamAngleY = rhs.fBeamAngleY;
+    fBeamAngleSigmaX = rhs.fBeamAngleSigmaX;
+    fBeamAngleSigmaY = rhs.fBeamAngleSigmaY;
+    fBeamDirection = rhs.fBeamDirection;
+    fPhiMin = rhs.fPhiMin;
+    fPhiMax = rhs.fPhiMax;
+    fPhi = rhs.fPhi;
+    fTargetZ = new Double_t[1];
+    fNrTargets = rhs.fNrTargets;
+    fTargetDz = rhs.fTargetDz;
+    fVertex = rhs.fVertex;
+    fNTracks = rhs.fNTracks;
+    fSmearVertexZ = rhs.fSmearVertexZ;
+    fSmearGausVertexZ = rhs.fSmearGausVertexZ;
+    fSmearVertexXY = rhs.fSmearVertexXY;
+    fSmearGausVertexXY = rhs.fSmearGausVertexXY;
+    fBeamAngle = rhs.fBeamAngle;
+    fEventPlane = rhs.fEventPlane;
+    fStack = NULL;
+    fGenList =new TObjArray();
+    fListIter = fGenList->MakeIterator();
+    fEvent = NULL;
+    fdoTracking = rhs.fdoTracking;
+    fMCIndexOffset = rhs.fMCIndexOffset;
+    fEventNr = rhs.fEventNr;
+    fTargetZ[0] = rhs.fTargetZ[0];
+  }
+  
+  return *this;
+
+}
+
+// -----   Public method GenerateEvent   -----------------------------------
+Bool_t FairPrimaryGenerator::GenerateEvent(FairGenericStack *pStack) {
+  // Check for MCEventHeader
+  if (!fEvent) {
+    LOG(FATAL) << "No MCEventHeader branch!" << FairLogger::endl;
+    return kFALSE;
+  } else {
+
+    // Initialise
+    fStack = pStack;
+    fNTracks = 0;
+    fEvent->Reset();
+
+    // Create event vertex
+    MakeVertex();
+    fEvent->SetVertex(fVertex);
+
+    // Create beam angle
+    // Here we only randomly generate two angles (anglex, angley)
+    // for the event and later on (in AddTrack())
+    // all our particles will be rotated accordingly.
+    if (fBeamAngle) {
+      MakeBeamAngle();
+    }
+
+    // Create event plane
+    // Randomly generate an angle by which each track added (in AddTrack())
+    // to the event is rotated around the z-axis
+    if (fEventPlane) {
+      MakeEventPlane();
+    }
+
+    // Call the ReadEvent methods from all registered generators
+    fListIter->Reset();
+    TObject *obj = 0;
+    FairGenerator *gen = 0;
+    while ((obj = fListIter->Next())) {
+      gen = dynamic_cast<FairGenerator *>(obj);
+      if (!gen) {
+        return kFALSE;
+      }
+      const char *genName = gen->GetName();
+      fMCIndexOffset = fNTracks; // number tracks before generator is called
+      Bool_t test = gen->ReadEvent(this);
+      if (!test) {
+        LOG(ERROR) << "ReadEvent failed for generator " << genName
+                   << FairLogger::endl;
+        return kFALSE;
+      }
+    }
+
+  
+    fTotPrim += fNTracks;
+    // Screen output
+
+    // Set the event number if not set already by one of the dedicated generators
+    if (-1 == fEvent->GetEventID()) {
+      fEventNr++;
+      fEvent->SetEventID(fEventNr);
+    }
+    LOG(DEBUG) << "(Event " << fEvent->GetEventID() << ") " << fNTracks
+               << " primary tracks from vertex (" << fVertex.X() << ", "
+               << fVertex.Y() << ", " << fVertex.Z() << ") with beam angle ("
+               << fBeamAngleX << ", " << fBeamAngleY << ") " << FairLogger::endl;
+
+    fEvent->SetNPrim(fNTracks);
+
+    return kTRUE;
+  }
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method AddTrack   ----------------------------------------
+void FairPrimaryGenerator::AddTrack(Int_t pdgid, Double_t px_raw,
+                                    Double_t py_raw, Double_t pz_raw,
+                                    Double_t vx, Double_t vy, Double_t vz,
+                                    Int_t parent, Bool_t wanttracking,
+                                    Double_t e, Double_t tof, Double_t weight) {
+
+  // ---> Add event vertex to track vertex
+  vx += fVertex.X();
+  vy += fVertex.Y();
+  vz += fVertex.Z();
+
+  // cout << "FairPrimaryGenerator::AddTrack +Z" <<  fVertex.Z() << " pdgid " <<
+  // pdgid << "?"<< wanttracking << endl;
+
+  TVector3 mom(px_raw, py_raw, pz_raw);
+
+  if (fEventPlane) {
+    // Rotate the track (event) by the randomly generated angle which is fixed
+    // for the complete event.
+    // The coordinate system is not changed by this rotation.
+    mom.RotateZ(fPhi);
+  }
+
+  if (fBeamAngle) {
+    // Rotate the track (event) from the rotated beam direction system into
+    // the fixed global experiment coordinate system
+    mom.RotateUz(fBeamDirection.Unit());
+  }
+
+  // ---> Convert K0 and AntiK0 into K0s and K0L
+  if (pdgid == 311 || pdgid == -311) {
+    Double_t test = gRandom->Uniform(0., 1.);
+    if (test >= 0.5) {
+      pdgid = 310;
+    } // K0S
+    else {
+      pdgid = 130;
+    } // K0L
+  }
+
+  // ---> Check whether particle type is in PDG Database
+  TDatabasePDG *pdgBase = TDatabasePDG::Instance();
+  if (!pdgBase) {
+    Fatal("FairPrimaryGenerator", "No TDatabasePDG instantiated");
+  } else {
+    TParticlePDG *pdgPart = pdgBase->GetParticle(pdgid);
+    if (!pdgPart) {
+      if (e < 0) {
+        cerr << "\033[5m\033[31m -E FairPrimaryGenerator: PDG code " << pdgid
+             << " not found in database.\033[0m " << endl;
+        cerr << "\033[5m\033[31m -E FairPrimaryGenerator: Discarding particle "
+                "\033[0m " << endl;
+        cerr << "\033[5m\033[31m -E FairPrimaryGenerator: now MC Index is "
+                "corrupted \033[0m " << endl;
+        return;
+      } else {
+        cout << "\033[5m\033[31m -W FairPrimaryGenerator: PDG code " << pdgid
+             << " not found in database. This warning can be savely "
+                "ignored.\033[0m " << endl;
+      }
+    }
+  }
+  // ---> Get mass and calculate energy of particle
+  if (e < 0) {
+    Double_t mass = pdgBase->GetParticle(pdgid)->Mass();
+    e = TMath::Sqrt(mom.Mag2() + mass * mass);
+  } // else, use the value of e given to the function
+
+  // ---> Set all other parameters required by PushTrack
+  Int_t doTracking = 0; // Go to tracking
+  if (fdoTracking && wanttracking) {
+    doTracking = 1;
+  }
+  Int_t dummyparent = -1; // Primary particle (now the value is -1 by default)
+  Double_t polx = 0.;     // Polarisation
+  Double_t poly = 0.;
+  Double_t polz = 0.;
+  Int_t ntr = 0;    // Track number; to be filled by the stack
+  Int_t status = 0; // Generation status
+
+  if (parent != -1) {
+    parent += fMCIndexOffset;
+  } // correct for tracks which are in list before generator is called
+  // Add track to stack
+  fStack->PushTrack(doTracking, dummyparent, pdgid, mom.X(), mom.Y(), mom.Z(),
+                    e, vx, vy, vz, tof, polx, poly, polz, kPPrimary, ntr,
+                    weight, status, parent);
+  fNTracks++;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method ClonePrimaryGenerator   ---------------------------
+FairPrimaryGenerator* FairPrimaryGenerator::ClonePrimaryGenerator() const
+{
+  FairPrimaryGenerator* newPrimaryGenerator = new FairPrimaryGenerator(*this);
+
+  /** Clone generators in the list*/
+  for (Int_t i = 0; i < fGenList->GetEntries(); i++) {
+    FairGenerator *gen = static_cast<FairGenerator*>(fGenList->At(i));
+    if (gen) {
+      newPrimaryGenerator->AddGenerator(gen->CloneGenerator());
+    }
+  }
+
+  return newPrimaryGenerator;
+}
+
+// -----   Public method SetBeam   -----------------------------------------
+void FairPrimaryGenerator::SetBeam(Double_t x0, Double_t y0, Double_t sigmaX,
+                                   Double_t sigmaY) {
+  fBeamX0 = x0;
+  fBeamY0 = y0;
+  fBeamSigmaX = sigmaX;
+  fBeamSigmaY = sigmaY;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method SetBeamAngle   -------------------------------------
+void FairPrimaryGenerator::SetBeamAngle(Double_t beamAngleX0,
+                                        Double_t beamAngleY0,
+                                        Double_t beamAngleSigmaX,
+                                        Double_t beamAngleSigmaY) {
+  fBeamAngleX0 = beamAngleX0;
+  fBeamAngleY0 = beamAngleY0;
+  fBeamAngleSigmaX = beamAngleSigmaX;
+  fBeamAngleSigmaY = beamAngleSigmaY;
+  fBeamAngle = kTRUE;
+}
+// ------------------------------------------------------------------------
+
+// -----   Public method SetEventPlane   ----------------------------------
+void FairPrimaryGenerator::SetEventPlane(Double_t phiMin, Double_t phiMax) {
+  fPhiMin = phiMin;
+  fPhiMax = phiMax;
+  fEventPlane = kTRUE;
+}
+// ------------------------------------------------------------------------
+
+// -----   Public method SetTarget   ---------------------------------------
+void FairPrimaryGenerator::SetTarget(Double_t z, Double_t dz) {
+
+  fTargetZ[0] = z;
+  fTargetDz = dz;
+}
+// -------------------------------------------------------------------------
+
+// -----   Public method SetMultTarget   -----------------------------------
+void FairPrimaryGenerator::SetMultTarget(Int_t nroftargets, Double_t *targetpos,
+                                         Double_t dz) {
+
+  if (1 == fNrTargets) {
+    delete fTargetZ;
+  } else {
+    delete[] fTargetZ;
+  }
+
+  fNrTargets = nroftargets;
+
+  fTargetZ = new Double_t[nroftargets];
+  for (Int_t i = 0; i < nroftargets; i++) {
+    fTargetZ[i] = targetpos[i];
+  }
+  fTargetDz = dz;
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method MakeVertex   -------------------------------------
+void FairPrimaryGenerator::MakeVertex() {
+  Double_t vx = fBeamX0;
+  Double_t vy = fBeamY0;
+  Double_t vz;
+  if (1 == fNrTargets) {
+    vz = fTargetZ[0];
+  } else {
+    Int_t Target = static_cast<Int_t>(gRandom->Uniform(fNrTargets));
+    vz = fTargetZ[Target];
+  }
+
+  if (fSmearVertexZ)
+    vz = gRandom->Uniform(vz - fTargetDz / 2., vz + fTargetDz / 2.);
+
+  if (fSmearGausVertexZ) {
+    vz = gRandom->Gaus(vz, fTargetDz);
+  }
+
+  if (fSmearGausVertexXY) {
+    if (fBeamSigmaX != 0.) {
+      vx = gRandom->Gaus(fBeamX0, fBeamSigmaX);
+    }
+    if (fBeamSigmaY != 0.) {
+      vy = gRandom->Gaus(fBeamY0, fBeamSigmaY);
+    }
+  }
+
+  if (fSmearVertexXY) {
+    if (fBeamSigmaX != 0.) {
+      vx = gRandom->Uniform(vx - fBeamSigmaX / 2., vx + fBeamSigmaX / 2.);
+    }
+    if (fBeamSigmaY != 0.) {
+      vy = gRandom->Uniform(vy - fBeamSigmaY / 2., vy + fBeamSigmaY / 2.);
+    }
+  }
+
+  fVertex = TVector3(vx, vy, vz);
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method MakeBeamAngle   -------------------------------
+void FairPrimaryGenerator::MakeBeamAngle() {
+  fBeamAngleX = gRandom->Gaus(fBeamAngleX0, fBeamAngleSigmaX);
+  fBeamAngleY = gRandom->Gaus(fBeamAngleY0, fBeamAngleSigmaY);
+  fBeamDirection.SetXYZ(TMath::Tan(fBeamAngleX), TMath::Tan(fBeamAngleY), 1.);
+  fEvent->SetRotX(fBeamAngleX);
+  fEvent->SetRotY(fBeamAngleY);
+}
+// -------------------------------------------------------------------------
+
+// -----   Private method MakeEventPlane   -------------------------------
+void FairPrimaryGenerator::MakeEventPlane() {
+  fPhi = gRandom->Uniform(fPhiMin, fPhiMax);
+  fEvent->SetRotZ(fPhi);
+}
+// -------------------------------------------------------------------------
+
+void FairPrimaryGenerator::SmearVertexZ(Bool_t flag) {
+  fSmearVertexZ = flag;
+  if (fSmearVertexZ && fSmearGausVertexZ) {
+    fSmearGausVertexZ = kFALSE;
+  }
+}
+
+void FairPrimaryGenerator::SmearGausVertexZ(Bool_t flag) {
+  fSmearGausVertexZ = flag;
+  if (fSmearGausVertexZ && fSmearVertexZ) {
+    fSmearVertexZ = kFALSE;
+  }
+}
+void FairPrimaryGenerator::SmearVertexXY(Bool_t flag) {
+  fSmearVertexXY = flag;
+  if (fSmearVertexXY && fSmearGausVertexXY) {
+    fSmearGausVertexXY = kFALSE;
+  }
+}
+void FairPrimaryGenerator::SmearGausVertexXY(Bool_t flag) {
+  fSmearGausVertexXY = flag;
+  if (fSmearGausVertexXY && fSmearVertexXY) {
+    fSmearVertexXY = kFALSE;
+  }
+}
+
+ClassImp(FairPrimaryGenerator)
diff --git a/base/sim/FairPrimaryGenerator.h b/base/sim/FairPrimaryGenerator.h
new file mode 100644
index 0000000..420d47a
--- /dev/null
+++ b/base/sim/FairPrimaryGenerator.h
@@ -0,0 +1,270 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ *                                                                              *
+ *              This software is distributed under the terms of the *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3, *
+ *                  copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
+
+/** FairPrimaryGenerator.h
+ *@author V.Friese  <v.friese@gsi.de>
+ *
+The FairPrimaryGenerator is responsible for the handling of the MC input.
+Several input generators can be registered to it; these have to be
+derived from the FairGenerator class. The FairPrimaryGenerator defines
+position and (optionally) smearing of the primary vertex.
+This class should be instantised only once.
+
+Modified 05.06.07:  add a method DoTracking(Bool_t) to be able to switch on/off
+the tracking from the macro (M. Al-Turany)
+
+**/
+
+#ifndef FAIRPRIMARYGENERATOR_H
+#define FAIRPRIMARYGENERATOR_H
+
+#include "TNamed.h" // for TNamed
+
+#include "FairGenerator.h" // for FairGenerator
+
+#include "Riosfwd.h"   // for ostream
+#include "Rtypes.h"    // for Double_t, Bool_t, Int_t, etc
+#include "TObjArray.h" // for TObjArray
+#include "TVector3.h"  // for TVector3
+
+#include <iostream> // for operator<<, basic_ostream, etc
+
+class FairGenericStack;
+class FairMCEventHeader;
+class TF1;
+class TIterator;
+
+class FairPrimaryGenerator : public TNamed {
+
+public:
+  /** Default constructor. **/
+  FairPrimaryGenerator();
+
+  /** Constructor with name and title **/
+  FairPrimaryGenerator(const char *name, const char *title = "FAIR Generator");
+
+  /** Destructor. **/
+  virtual ~FairPrimaryGenerator();
+
+  /** Initialize the generater (if needed!)*/
+  virtual Bool_t Init();
+
+  /** Register a generator derived from FairGenerator.  **/
+  void AddGenerator(FairGenerator *generator) {
+    if (!fGenList) {
+      std::cout << "Empty fGenList pointer ! " << std::endl;
+      return;
+    }
+    fGenList->Add(generator);
+  }
+
+  /** Public method GenerateEvent
+      To be called at the beginning of each event from FairMCApplication.
+      Generates an event vertex and calls the ReadEvent methods from the
+      registered generators.
+      *@param pStack The particle stack
+      *@return kTRUE if successful, kFALSE if not
+      **/
+  virtual Bool_t GenerateEvent(FairGenericStack *pStack);
+
+  /** Public method AddTrack
+      Adding a track to the MC stack. To be called within the ReadEvent
+      methods of the registered generators.
+      *@param pdgid Particle ID (PDG code)
+      *@param px,py,pz Momentum coordinates [GeV]
+      *@param vx,vy,vz Track origin relative to event vertex
+      **/
+  virtual void AddTrack(Int_t pdgid, Double_t px, Double_t py, Double_t pz,
+                        Double_t vx, Double_t vy, Double_t vz,
+                        Int_t parent = -1, Bool_t wanttracking = true,
+                        Double_t e = -9e9, Double_t tof = 0.,
+                        Double_t weight = 0.);
+
+  /** Clone this object (used in MT mode only) */
+  virtual FairPrimaryGenerator* ClonePrimaryGenerator() const;
+
+  /** Set beam position and widths.
+   *@param beamX0      mean x position of beam at target
+   *@param beamY0      mean y position of beam at target
+   *@param beamSigmaX  Gaussian beam width in x
+   *@param beamSigmaY  Gaussian beam width in y
+   **/
+  void SetBeam(Double_t beamX0, Double_t beamY0, Double_t beamSigmaX,
+               Double_t beamSigmaY);
+
+  /** Set nominal beam angle and angle widths.
+   *@param beamAngleX0      mean x angle of beam at target
+   *@param beamAngleY0      mean y angle of beam at target
+   *@param beamAngleSigmaX  Gaussian beam angle width in x
+   *@param beamAngleSigmaY  Gaussian beam angle width in y
+   **/
+  void SetBeamAngle(Double_t beamAngleX0, Double_t beamAngleY0,
+                    Double_t beamAngleSigmaX, Double_t beamAngleSigmaY);
+
+  /** Public method SetEventPlane
+   **@param phiMin   Lower limit for event plane angle [rad]
+   **@param phiMax   Upper limit for event plane angle [rad]
+   **If set, an event plane angle will be generated with flat
+   **distrtibution between phiMin and phiMax.
+   **/
+  void SetEventPlane(Double_t phiMin, Double_t phiMax);
+
+  /** Set target position and thickness.
+   *@param targetZ   z position of target center
+   *@param targetDz  full target thickness
+   **/
+  void SetTarget(Double_t targetZ, Double_t targetDz);
+
+  /** Set target position for multiple tagets. The thickness
+   * is the same for all targets.
+   *@param nroftargets   number of targets
+   *@param *targetZ      z positions of target center
+   *@param targetDz      full target thickness
+   **/
+  void SetMultTarget(Int_t nroftargets, Double_t *targetZ, Double_t targetDz);
+
+  /** Enable vertex smearing in z and/or xy direction **/
+  void SmearVertexZ(Bool_t flag);
+  void SmearGausVertexZ(Bool_t flag);
+  void SmearVertexXY(Bool_t flag);
+  void SmearGausVertexXY(Bool_t flag);
+
+  TObjArray *GetListOfGenerators() { return fGenList; }
+
+  /** Set the pointer to the MCEvent **/
+  void SetEvent(FairMCEventHeader *event) {
+    fEvent = event;
+  };
+
+  /** Accessor to the MCEvent **/
+  FairMCEventHeader *GetEvent() {
+    return fEvent;
+  };
+
+  /** Swich on/off the tracking of a particle*/
+
+  void DoTracking(Bool_t doTracking = kTRUE) { fdoTracking = doTracking; }
+
+  Int_t GetTotPrimary() { return fTotPrim; }
+
+protected:
+  /**  Copy constructor */
+  FairPrimaryGenerator(const FairPrimaryGenerator&);
+  /**  Assignment operator */
+  FairPrimaryGenerator &operator=(const FairPrimaryGenerator&);
+
+  /**  Nominal beam position at target in x [cm] */
+  Double_t fBeamX0;
+  /** Nominal beam position at target in y [cm]*/
+  Double_t fBeamY0;
+  /** Beam width (Gaussian) in x [cm]*/
+  Double_t fBeamSigmaX;
+  /**  Beam width (Gaussian) in y [cm]*/
+  Double_t fBeamSigmaY;
+
+  /**  Nominal beam angle at target in x [rad] */
+  Double_t fBeamAngleX0;
+  /**  Nominal beam angle at target in y [rad] */
+  Double_t fBeamAngleY0;
+  /**  Actual beam angle at target in x [rad] */
+  Double_t fBeamAngleX;
+  /**  Actual beam angle at target in y [rad] */
+  Double_t fBeamAngleY;
+  /** Beam angle width (Gaussian) in x [rad]*/
+  Double_t fBeamAngleSigmaX;
+  /** Beam angle width (Gaussian) in y [rad]*/
+  Double_t fBeamAngleSigmaY;
+  /** Actual beam direction at the vertex */
+  TVector3 fBeamDirection;
+
+  /** Lower limit for the event plane rotation angle [rad] */
+  Double_t fPhiMin;
+  /** Upper limit for the event plane rotation angle [rad] */
+  Double_t fPhiMax;
+  /** Actual event plane rotation angle [rad] */
+  Double_t fPhi;
+
+  /**  Nominal z position of center of targets [cm]*/
+  Double_t *fTargetZ; //!
+  /**  Number of targets;*/
+  Int_t fNrTargets;
+  /**  Full target thickness [cm]*/
+  Double_t fTargetDz;
+
+  /** Vertex position of current event [cm]*/
+  TVector3 fVertex;
+
+  /** Number of primary tracks in current event*/
+  Int_t fNTracks;
+
+  /**  Flag for uniform vertex smearing in z*/
+  Bool_t fSmearVertexZ;
+  /**  Flag for gaus vertex smearing in z*/
+  Bool_t fSmearGausVertexZ;
+  /**  Flag for vertex smearing in xy*/
+  Bool_t fSmearVertexXY;
+  /**  Flag for gaus vertex smearing in xy*/
+  Bool_t fSmearGausVertexXY;
+  /**  Flag for beam gradient calculation*/
+  Bool_t fBeamAngle;
+  /**  Flag for event plane rotation*/
+  Bool_t fEventPlane;
+
+  /**  Pointer to MC stack*/
+  FairGenericStack *fStack; //!
+  /**  List of registered generators */
+  TObjArray *fGenList;
+  /**  Iterator over generator list */
+  TIterator *fListIter; //!
+  /**  Pointer to MCEventHeader */
+  FairMCEventHeader *fEvent; //!
+  /** go to tracking  */
+  Bool_t fdoTracking; //!
+  /** Number of MC tracks before a Generator is called, needed for MC index
+   * update */
+  Int_t fMCIndexOffset; //!
+  /** Number of all primaries of this run*/
+  static Int_t fTotPrim; //!
+  /** Event number (Set by the primary generator if not set already by one of
+      the specific generators
+   **/
+  Int_t fEventNr;
+
+  /** Private method MakeVertex. If vertex smearing in xy is switched on,
+      the event vertex is smeared Gaussianlike in x and y direction
+      according to the mean beam positions and widths set by the
+      SetBeam method. If vertex smearing in z is switched on, the z
+      coordinate of the event vertex is flatly distributed over the
+      extension of the target.
+      To be called at the beginning of the event from the
+      GenerateEvent method.
+  **/
+  void MakeVertex();
+
+  /** Private method MakeBeamAngle. If beam angle smearing in xy
+  is switched on, all tracks in an event are rotated by a Gaussianlike
+  angle distribution around the x and y axis according to the mean
+  beam angle and angle widths set by the SetBeamAngle method.
+  To be called at the beginning of the event from the GenerateEvent
+  method.
+  **/
+  void MakeBeamAngle();
+
+  /** Private method MakeEventPlane. If the rotation of the event around the
+      z-axis by a random angle is switched on, the complete event is rotated
+      by the chosen angle. This function is called at the beginning of the
+      event from the GenerateEvent method. The function pick a random
+      rotation angle between fPhiMin and fPhiMax which are set using the
+      function SetEventPlane.
+  **/
+  void MakeEventPlane();
+
+  ClassDef(FairPrimaryGenerator, 5);
+};
+
+#endif
diff --git a/base/FairRunIdGenerator.cxx b/base/sim/FairRunIdGenerator.cxx
similarity index 77%
rename from base/FairRunIdGenerator.cxx
rename to base/sim/FairRunIdGenerator.cxx
index 3c108c5..b6c1860 100644
--- a/base/FairRunIdGenerator.cxx
+++ b/base/sim/FairRunIdGenerator.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * gen_uuid.c --- generate a DCE-compatible uuid
  *
@@ -15,23 +22,19 @@
  */
 #define _SVID_SOURCE
 
-#include "unistd.h"
-#include "stdlib.h"
-#include "string.h"
-#include "fcntl.h"
-#include "errno.h"
-#include "sys/types.h"
-#include "sys/time.h"
-#include "sys/stat.h"
-#include "sys/file.h"
-#include "sys/ioctl.h"
-#include "sys/socket.h"
-#include "net/if.h"
-#include "netinet/in.h"
+#include "FairRunIdGenerator.h"
+#include <sys/errno.h>                  // for errno, EAGAIN, EINTR
+#include <sys/fcntl.h>                  // for open, O_RDONLY, O_NONBLOCK
+#include <stdlib.h>                     // for rand, srand
+#include <string.h>                     // for memcpy
+#include <sys/time.h>                   // for gettimeofday
+#include <unistd.h>                     // for getpid, getuid, read
 
 #define srand(x)  srandom(x)
 #define rand()    random()
 
+//using namespace std;
+
 //#include "genid32.h"    replaced by hrunidgenerator.h
 
 /*
@@ -45,7 +48,6 @@
  * %End-Header%
  */
 
-#include "FairRunIdGenerator.h"
 
 /*
  * Offset between 15-Oct-1582 and 1-Jan-70
@@ -84,7 +86,7 @@ void FairRunIdGenerator::get_random_bytes(void* buf, int nbytes)
 {
   int i, fd = get_random_fd();
   int lose_counter = 0;
-  char* cp = (char*) buf;
+  char* cp = static_cast<char*>(buf);
 
   if (fd >= 0) {
     while (nbytes > 0) {
@@ -114,7 +116,7 @@ void FairRunIdGenerator::get_random_bytes(void* buf, int nbytes)
 /*
  * Get the ethernet hardware address, if we can find it...
  */
-int FairRunIdGenerator::get_node_id(unsigned char* node_id)
+int FairRunIdGenerator::get_node_id(unsigned char* /*node_id*/)
 {
 #ifdef HAVE_NET_IF_H
   int sd;
@@ -227,12 +229,17 @@ try_again:
   }
 
   clock_reg = tv.tv_usec * 10 + adjustment;
-  clock_reg += ((unsigned long long) tv.tv_sec) * 10000000;
-  clock_reg += (((unsigned long long) 0x01B21DD2) << 32) + 0x13814000;
+  clock_reg += (static_cast<unsigned long long>(tv.tv_sec)) * 10000000;
+  clock_reg += ((static_cast<unsigned long long>(0x01B21DD2)) << 32) + 0x13814000;
 
   *clock_high = clock_reg >> 32;
   *clock_low = clock_reg;
   *ret_clock_seq = clock_seq;
+
+  fTimeSpec.tv_sec = last.tv_sec;
+  //  fTimeSpec.tv_nsec = last.tv_usec*1000.;
+  fTimeSpec.tv_nsec = 0.;
+
   return 0;
 }
 
@@ -257,7 +264,7 @@ void FairRunIdGenerator::uuid_generate_time(uuid_t out)
   }
   get_clock(&clock_mid, &uu.time_low, &uu.clock_seq);
   uu.clock_seq |= 0x8000;
-  uu.time_mid = (uint16_t) clock_mid;
+  uu.time_mid = static_cast<uint16_t>(clock_mid);
   uu.time_hi_and_version = (clock_mid >> 16) | 0x1000;
   memcpy(uu.node, node_id, 6);
   uuid_pack(&uu, out);
@@ -284,11 +291,15 @@ void FairRunIdGenerator::uuid_generate_random(uuid_t out)
  */
 void FairRunIdGenerator::uuid_generate(uuid_t out)
 {
+  /*
   if (get_random_fd() >= 0) {
     uuid_generate_random(out);
   } else {
     uuid_generate_time(out);
   }
+  */
+  uuid_generate_time(out);
+
 }
 
 /*
@@ -308,28 +319,28 @@ void FairRunIdGenerator::uuid_pack(const struct uuid* uu, uuid_t ptr)
   unsigned char* out = ptr;
 
   tmp = uu->time_low;
-  out[3] = (unsigned char) tmp;
+  out[3] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[2] = (unsigned char) tmp;
+  out[2] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[1] = (unsigned char) tmp;
+  out[1] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[0] = (unsigned char) tmp;
+  out[0] = static_cast<unsigned char>(tmp);
 
   tmp = uu->time_mid;
-  out[5] = (unsigned char) tmp;
+  out[5] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[4] = (unsigned char) tmp;
+  out[4] = static_cast<unsigned char>(tmp);
 
   tmp = uu->time_hi_and_version;
-  out[7] = (unsigned char) tmp;
+  out[7] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[6] = (unsigned char) tmp;
+  out[6] = static_cast<unsigned char>(tmp);
 
   tmp = uu->clock_seq;
-  out[9] = (unsigned char) tmp;
+  out[9] = static_cast<unsigned char>(tmp);
   tmp >>= 8;
-  out[8] = (unsigned char) tmp;
+  out[8] = static_cast<unsigned char>(tmp);
 
   memcpy(out + 10, uu->node, 6);
 }
@@ -375,12 +386,32 @@ void FairRunIdGenerator::uuid_unpack(const uuid_t in, struct uuid* uu)
 unsigned int FairRunIdGenerator::generateId(void)
 {
   uuid_t uu;
-  unsigned int v;
-
+//  unsigned int v;
+//  struct timeval ret_tv;
   uuid_generate(uu);
+
+/*
   v = ((uu[0] ^ uu[4] ^ uu[8] ^ uu[12]) << 0)
       | ((uu[1] ^ uu[5] ^ uu[9] ^ uu[13]) << 8)
       | ((uu[2] ^ uu[6] ^ uu[10] ^ uu[14]) << 16)
       | ((uu[3] ^ uu[7] ^ uu[11] ^ uu[15]) << 24);
-  return v & 0x7fffffff;
+*/
+
+  //  return v & 0x7fffffff;
+  return getTID();
 }
+
+unsigned  int FairRunIdGenerator::getTID()
+{
+  return  (fTimeSpec.tv_sec );
+}
+
+struct timespec FairRunIdGenerator::getTimeSpecFromTID( unsigned  int ms) {
+  struct timespec ret_tv;
+  ret_tv.tv_sec  =  ms;
+  ret_tv.tv_nsec = 0. ; // truncate the ns resolution
+  return ret_tv;
+}
+
+
+
diff --git a/base/sim/FairRunIdGenerator.h b/base/sim/FairRunIdGenerator.h
new file mode 100644
index 0000000..3d0a16d
--- /dev/null
+++ b/base/sim/FairRunIdGenerator.h
@@ -0,0 +1,54 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRRUNIDGENERATOR_H
+#define FAIRRUNIDGENERATOR_H
+
+#include <time.h>               // IWYU pragma: keep for timespec
+// IWYU pragma: no_include <sys/_structs.h>
+
+typedef unsigned char      uint8_t;
+typedef unsigned short int uint16_t;
+typedef unsigned int       uint32_t;
+typedef unsigned char      uuid_t[16];
+
+class FairRunIdGenerator
+{
+    struct uuid {
+      uint32_t time_low;
+      uint16_t time_mid;
+      uint16_t time_hi_and_version;
+      uint16_t clock_seq;
+      uint8_t node[6];
+    };
+
+    struct timespec fTimeSpec;
+
+    int get_random_fd(void);
+    void get_random_bytes(void*, int);
+    int get_node_id(unsigned char*);
+    int get_clock(uint32_t*, uint32_t*, uint16_t*);
+    void uuid_generate_time(uuid_t);
+    void uuid_generate_random(uuid_t);
+    void uuid_generate(uuid_t);
+    void uuid_pack(const struct uuid*, uuid_t);
+    void uuid_unpack(const uuid_t, struct uuid*);
+  public:
+    struct timespec getTimeSpec() {return fTimeSpec;}
+    struct timespec getTimeSpecFromTID( unsigned  int ms);
+    unsigned  int getTID();
+
+  public:
+    FairRunIdGenerator() : fTimeSpec() {}
+    ~FairRunIdGenerator() {}
+    unsigned int generateId(void);
+
+
+
+};
+
+#endif
diff --git a/base/FairVolume.cxx b/base/sim/FairVolume.cxx
similarity index 70%
rename from base/FairVolume.cxx
rename to base/sim/FairVolume.cxx
index 1b03eb2..cf0956e 100644
--- a/base/FairVolume.cxx
+++ b/base/sim/FairVolume.cxx
@@ -1,12 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairVolume source file                   -----
 // -----          Created 12/01/04  by M. Al-Turany                    -----
 // -------------------------------------------------------------------------
 
-
-
 #include "FairVolume.h"
 
+#include <stddef.h>                     // for NULL
+
 //_____________________________________________________________________________
 FairVolume::FairVolume()
   : TNamed(),
@@ -18,6 +25,7 @@ FairVolume::FairVolume()
     fCopyNo(-1),        /**Volume Copy No*/
     fMotherId(-1),    /**Mother Volume Id*/
     fMotherCopyNo(-1),  /**Mother Volume Copy No*/
+    fDetector(0),
     fModule(NULL),         /**The Module (detector) which will proccess the hits for this volume*/
     fNode(NULL)            /**Node corre*/
 {
@@ -36,10 +44,14 @@ FairVolume::FairVolume(TString name, Int_t id, Int_t ModId, FairModule* fMod)
    fCopyNo(-1),        /**Volume Copy No*/
    fMotherId(0),     /**Mother Volume Id*/
    fMotherCopyNo(0),  /**Mother Volume Copy No*/
+   fDetector(0),
    fModule(fMod),        /**The Module (detector) which will proccess the hits for this volume*/
    fNode(NULL)            /**Node corre*/
 
 {
+    if (fModule && fModule->InheritsFrom("FairDetector")){
+        fDetector=dynamic_cast<FairDetector *>(fModule);
+    }
 
 }
 
diff --git a/base/FairVolume.h b/base/sim/FairVolume.h
similarity index 57%
rename from base/FairVolume.h
rename to base/sim/FairVolume.h
index cc0f15b..8a7e556 100644
--- a/base/FairVolume.h
+++ b/base/sim/FairVolume.h
@@ -1,15 +1,21 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIR_VOLUME_H
 #define FAIR_VOLUME_H
 
-#include "TNamed.h"
-
-//#include "TObject.h"
-//#include "TObjArray.h"
-
-#include <iostream>
+#include "TNamed.h"                     // for TNamed
 
+#include "Rtypes.h"                     // for Int_t, FairVolume::Class, etc
+#include "TString.h"                    // for TString
+#include "FairModule.h"
+#include "FairDetector.h"
 class FairGeoNode;
-class FairModule;
+
 /**
  * This Object is only used for internal book keeping!
  * @author M. Al-Turany, D. Bertini
@@ -41,8 +47,14 @@ class FairVolume : public TNamed
     void  setMotherId(Int_t fM) {fMotherId=fM;}
     void  setMotherCopyNo(Int_t CopyNo) {fMotherCopyNo=CopyNo;}
 
-    FairModule* GetModule() {return fModule;}
-    void SetModule(FairModule* mod) {fModule=mod;}
+    FairModule*   GetModule()     {return fModule;}
+    FairDetector* GetDetector() { return fDetector;}
+    void SetModule(FairModule* mod) {
+        fModule=mod;
+        if (mod->InheritsFrom("FairDetector")){
+           fDetector=dynamic_cast<FairDetector *>(mod);
+        }
+    }
 
     Int_t getMCid() {return fMCid;}
     Int_t getCopyNo() { return fCopyNo;}
@@ -64,8 +76,10 @@ class FairVolume : public TNamed
     Int_t fCopyNo;         /**Volume Copy No*/
     Int_t fMotherId; /**Mother Volume Id*/
     Int_t fMotherCopyNo;   /**Mother Volume Copy No*/
-    FairModule* fModule; /**The Module (detector) which will proccess the hits for this volume*/
-    FairGeoNode* fNode;     /**Node corresponding to this volume*/
+    FairDetector* fDetector; /** The Detector which will proccess the hits for this volume*/
+    FairModule*   fModule;    /**The Module in which the volume is */
+    FairGeoNode*  fNode;     /**Node corresponding to this volume*/
+    
 
     ClassDef(FairVolume,2) // Volume Definition
 
diff --git a/base/FairVolumeList.cxx b/base/sim/FairVolumeList.cxx
similarity index 51%
rename from base/FairVolumeList.cxx
rename to base/sim/FairVolumeList.cxx
index 07cafea..a92cdf4 100644
--- a/base/FairVolumeList.cxx
+++ b/base/sim/FairVolumeList.cxx
@@ -1,15 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                 FairVolumeList  source file                   -----
 // -----          Created 12/01/04  by M. Al-Turany                    -----
 // -------------------------------------------------------------------------
 
-
 #include "FairVolumeList.h"
-#include "FairVolume.h"
 
-using std::cout;
-using std::cerr;
-using std::endl;
+#include "FairVolume.h"                 // for FairVolume
+#include "FairLogger.h"                 // for logging
 
 //_____________________________________________________________________________
 
@@ -17,8 +21,6 @@ FairVolumeList::FairVolumeList()
   :TObject(),
    fData(new TObjArray())
 {
-  //
-
 }
 
 //_____________________________________________________________________________
@@ -35,18 +37,24 @@ FairVolume* FairVolumeList::getVolume(TString* name)
 {
 
   TObject* obj = findObject(* name);
-  if (obj) { cout << "-I FairVolume getVolume " << name->Data() << "found" << endl; }
-  return (FairVolume*) obj;
+  if (obj) { 
+    LOG(INFO) << "FairVolume getVolume " << name->Data() 
+	      << "found" << FairLogger::endl; 
+  }
+
+  return static_cast<FairVolume*>(obj);
 }
 
 //_____________________________________________________________________________
 Int_t FairVolumeList::getVolumeId(TString* name)
 {
+  FairVolume* vol = getVolume(name);
 
-  TObject* obj = findObject(* name);
-  if (obj) { cout << "-I FairVolume getVolume " << name->Data() << "found" << endl; }
-  FairVolume* vol = (FairVolume*) obj;
-  return vol->getVolumeId();
+  if (vol) {
+    return vol->getVolumeId();
+  } else {
+    return -111;
+  }
 }
 
 
@@ -55,14 +63,16 @@ Int_t FairVolumeList::getVolumeId(TString* name)
 FairVolume* FairVolumeList::findObject(TString name)
 {
   FairVolume* obj = NULL;
-  for (int i = 0; i < fData->GetEntriesFast(); i++) {
-    obj = (FairVolume*) fData->At(i);
-    if (obj ) {
 
-      if (obj->GetName() == name) { return (FairVolume*) obj; }
+  for (int i = 0; i < fData->GetEntriesFast(); i++) {
+    obj = static_cast<FairVolume*>(fData->At(i));
+    if (obj) {
+      if (obj->GetName() == name) { 
+	return static_cast<FairVolume*>(obj); 
+      }
     }
-
   }
+
   return NULL;
 }
 
@@ -70,12 +80,14 @@ FairVolume* FairVolumeList::findObject(TString name)
 void FairVolumeList::addVolume(FairVolume* elem)
 {
 
-  FairVolume* v= (FairVolume*)findObject(elem->GetName());
+  FairVolume* v= static_cast<FairVolume*>(findObject(elem->GetName()));
 
   if (v) {
-    if(gDebug>0) { cerr << "-I FairVolumeList element: " << elem->GetName() <<  " VolId : " << elem->getVolumeId() << " already defined " << v->getVolumeId()<< endl; }
+    LOG(ERROR) << "FairVolumeList element: " << elem->GetName() 
+	       << " VolId : " << elem->getVolumeId() 
+	       << " already defined " << v->getVolumeId() 
+	       << FairLogger::endl; 
   } else {
-
     fData->Add(elem);
   }
 }
diff --git a/base/sim/FairVolumeList.h b/base/sim/FairVolumeList.h
new file mode 100644
index 0000000..a452fca
--- /dev/null
+++ b/base/sim/FairVolumeList.h
@@ -0,0 +1,53 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIR_VOLUMELIST_H
+#define FAIR_VOLUMELIST_H
+
+#include "TObject.h"                    // for TObject
+
+#include "FairVolume.h"
+
+#include "Rtypes.h"                     // for Int_t, etc
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+
+//class FairVolume;
+
+/**
+* This Object is only used for internal book keeping!
+* @author M. Al-Turany, D. Bertini
+* @version 0.1
+* @since 12.01.04
+*/
+
+class FairVolumeList : public TObject
+{
+  private:
+    TObjArray* fData;
+    FairVolumeList(const FairVolumeList&);
+    FairVolumeList& operator=(const FairVolumeList&);
+
+  public:
+    FairVolumeList();
+    virtual ~FairVolumeList();
+
+    FairVolume* getVolume( TString* name );
+    Int_t getVolumeId( TString* name );
+
+    FairVolume* findObject( TString name );
+    void addVolume( FairVolume* elem);
+
+    Int_t getEntries () { return fData->GetEntries();}
+    FairVolume* At(Int_t pos ) { return ( dynamic_cast<FairVolume*>(fData->At(pos))); }
+
+    ClassDef(FairVolumeList,1) // Volume List
+};
+
+#endif //FAIR_VOLUMELIST_H
+
+
diff --git a/base/sim/README.md b/base/sim/README.md
new file mode 100644
index 0000000..4aee51f
--- /dev/null
+++ b/base/sim/README.md
@@ -0,0 +1,9 @@
+sim
+========
+
+Classes related to the Monte Carlo transport:
+
+ * transport steering program (`FairMCApplication`);
+ * geometry description base classes (`FairModule` for inactive volumes and `FairDetector` for active detectors);
+ * event generator classes (`FairGenerator` - the base class and several implementations);
+ * base parameter (`FairBaseParSet`) and geometry (`FairGeoParSet`) containers;
\ No newline at end of file
diff --git a/base/source/FairFileSource.cxx b/base/source/FairFileSource.cxx
new file mode 100644
index 0000000..5a85dfd
--- /dev/null
+++ b/base/source/FairFileSource.cxx
@@ -0,0 +1,875 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+
+//
+//  FairFileSource.cxx
+//  FAIRROOT
+//
+//  Created by Mohammad Al-Turany on 08/02/14.
+//
+//
+#include "FairFileSource.h"
+#include "TString.h"
+#include "FairEventHeader.h"
+#include "FairFileHeader.h"
+#include "FairMCEventHeader.h"
+#include "FairLogger.h"
+#include "TObjArray.h"
+#include <map> 
+#include <set> 
+#include <algorithm>                    // for find
+#include "TChainElement.h"
+#include "TFolder.h"
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairRootManager.h"
+#include "TRandom.h"                    // for TRandom, gRandom
+#include "TROOT.h"
+#include <list>                         // for _List_iterator, list, etc
+using std::map;
+using std::set;
+
+//_____________________________________________________________________________
+
+FairFileSource::FairFileSource(TFile *f, const char* Title, UInt_t)
+  :FairSource()
+  , fInputTitle(Title)
+  , fRootFile(f)
+  , fCurrentEntryNr(0)
+  , fFriendFileList()
+  , fInputChainList()
+  , fFriendTypeList()
+  , fCheckInputBranches()
+  , fInputLevel()
+  , fRunIdInfoAll()
+  , fInChain(0)
+  , fInTree(0)
+  , fListFolder(new TObjArray(16))
+  , fRtdb(FairRuntimeDb::instance())
+  , fCbmout(0)
+  , fCbmroot(0)
+  , fSourceIdentifier(0)
+  , fNoOfEntries(-1)
+  , IsInitialized(kFALSE)
+  , fMCHeader(0)
+  , fEvtHeader(0)
+  , fFileHeader(0)
+  , fEventTimeInMCHeader(kTRUE)
+  , fEvtHeaderIsNew(kFALSE)
+  , fCurrentEntryNo(0)
+  , fTimeforEntryNo(-1)
+  , fEventTimeMin(0.)
+  , fEventTimeMax(0.)
+  , fEventTime(0.)
+  , fBeamTime(-1.)
+  , fGapTime(-1.)
+  , fEventMeanTime(0.)
+  , fTimeProb(0)
+  , fCheckFileLayout(kTRUE)
+{
+    if (fRootFile->IsZombie()) {
+     LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+  }
+  LOG(DEBUG) << "FairFileSource created------------" << FairLogger::endl;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairFileSource::FairFileSource(const TString* RootFileName, const char* Title, UInt_t)
+  :FairSource()
+  , fInputTitle(Title)
+  , fRootFile(0)
+  , fCurrentEntryNr(0)
+  , fFriendFileList()
+  , fInputChainList()
+  , fFriendTypeList()
+  , fCheckInputBranches()
+  , fInputLevel()
+  , fRunIdInfoAll()
+  , fInChain(0)
+  , fInTree(0)
+  , fListFolder(new TObjArray(16))
+  , fRtdb(FairRuntimeDb::instance())
+  , fCbmout(0)
+  , fCbmroot(0)
+  , fSourceIdentifier(0)
+  , fNoOfEntries(-1)
+  , IsInitialized(kFALSE)
+  , fMCHeader(0)
+  , fEvtHeader(0)
+  , fFileHeader(0)
+  , fEventTimeInMCHeader(kTRUE)
+  , fEvtHeaderIsNew(kFALSE)
+  , fCurrentEntryNo(0)
+  , fTimeforEntryNo(-1)
+  , fEventTimeMin(0.)
+  , fEventTimeMax(0.)
+  , fEventTime(0.)
+  , fBeamTime(-1.)
+  , fGapTime(-1.)
+  , fEventMeanTime(0.)
+  , fTimeProb(0)
+  , fCheckFileLayout(kTRUE)
+{
+  fRootFile = new TFile(RootFileName->Data());
+  if (fRootFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+  }
+  LOG(DEBUG) << "FairFileSource created------------" << FairLogger::endl;
+  }
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairFileSource::FairFileSource(const TString RootFileName, const char* Title, UInt_t)
+  :FairSource()
+  , fInputTitle(Title)
+  , fRootFile(0)
+  , fCurrentEntryNr(0)
+  , fFriendFileList()
+  , fInputChainList()
+  , fFriendTypeList()
+  , fCheckInputBranches()
+  , fInputLevel()
+  , fRunIdInfoAll()
+  , fInChain(0)
+  , fInTree(0)
+  , fListFolder(new TObjArray(16))
+  , fRtdb(FairRuntimeDb::instance())
+  , fCbmout(0)
+  , fCbmroot(0)
+  , fSourceIdentifier(0)
+  , fNoOfEntries(-1)
+  , IsInitialized(kFALSE)
+  , fMCHeader(0)
+  , fEvtHeader(0)
+  , fFileHeader(0)
+  , fEventTimeInMCHeader(kTRUE)
+  , fEvtHeaderIsNew(kFALSE)
+  , fCurrentEntryNo(0)
+  , fTimeforEntryNo(-1)
+  , fEventTimeMin(0.)
+  , fEventTimeMax(0.)
+  , fEventTime(0.)
+  , fBeamTime(-1.)
+  , fGapTime(-1.)
+  , fEventMeanTime(0.)
+  , fTimeProb(0)
+  , fCheckFileLayout(kTRUE)
+{
+    fRootFile = new TFile(RootFileName.Data());
+    if (fRootFile->IsZombie()) {
+      LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+    }
+    LOG(DEBUG) << "FairFileSource created------------" << FairLogger::endl;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairFileSource::~FairFileSource()
+{
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairFileSource::Init()
+{
+    if(IsInitialized){
+      LOG(INFO) << "FairFileSource already initialized" << FairLogger::endl;
+       return kTRUE;
+    }
+    if (!fInChain ) {
+        fInChain = new TChain(FairRootManager::GetTreeName(), "/cbmroot");
+        LOG(DEBUG) << "FairFileSource::Init() chain created"
+		   << FairLogger::endl;
+	FairRootManager::Instance()->SetInChain(fInChain);
+    }
+    fInChain->Add( fRootFile->GetName() );
+    
+    // Get the folder structure from file which describes the input tree.
+    // There are two different names possible, so check both.
+    fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmroot"));
+    if(!fCbmroot) {
+        fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmout"));
+        if(!fCbmroot) {
+            fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
+        } else {
+            fCbmroot->SetName("cbmroot");
+        }
+    }
+    // Get The list of branches from the input file and add it to the
+    // actual list of existing branches.
+    // Add this list of branches also to the map of input trees, which
+    // stores the information which branches belong to which input tree.
+    // There is at least one primary input tree, but there can be many
+    // additional friend trees.
+    // This information is needed to add new files to the correct friend
+    // tree. With this information it is also possible to check if the
+    // input files which are added to the input chain all have the same
+    // branch structure. Without this check it is possible to add trees
+    // with a different branch structure but the same tree name. ROOT
+    // probably only checks if the name of the tree is the same.
+    TList* list= dynamic_cast <TList*> (fRootFile->Get("BranchList"));
+    if(list==0) {
+      LOG(FATAL) << "No Branch list in input file" << FairLogger::endl;
+    }
+    TString chainName = fInputTitle;
+    TString ObjName;
+    fInputLevel.push_back(chainName);
+    fCheckInputBranches[chainName] = new std::list<TString>;
+    if(list) {
+      TObjString* Obj=0;
+      LOG(DEBUG) << "Enteries in the list " 
+		 << list->GetEntries() << FairLogger::endl;
+      for(Int_t i =0; i< list->GetEntries(); i++) {
+	Obj=dynamic_cast <TObjString*> (list->At(i));
+	if(Obj!=0){
+	  ObjName=Obj->GetString();
+	  LOG(DEBUG) << "Branch name " << ObjName.Data()
+		     << FairLogger::endl;
+	  fCheckInputBranches[chainName]->push_back(ObjName.Data());
+	  
+	  FairRootManager::Instance()->AddBranchToList(ObjName.Data());
+	}
+      }
+    }
+
+    gROOT->GetListOfBrowsables()->Add(fCbmroot);
+    fListFolder->Add( fCbmroot );
+
+    // Store the information about the unique runids in the input file
+    // together with the filename and the number of events for each runid
+    // this information is needed later to check if inconsitencies exist
+    // between the main input chain and any of the friend chains.
+    
+    //  GetRunIdInfo(fInFile->GetName(), chainName);
+    
+    // Add all additional input files to the input chain and do a
+    // consitency check
+    std::list<TString>::const_iterator iter;
+    for(iter = fInputChainList.begin(); iter != fInputChainList.end(); iter++) {
+        // Store global gFile pointer for safety reasons.
+        // Set gFile to old value at the end of the routine.R
+        TFile* temp = gFile;
+        
+        // Temporarily open the input file to extract information which
+        // is needed to bring the friend trees in the correct order
+        TFile* inputFile = new TFile((*iter));
+        if (inputFile->IsZombie()) {
+	  LOG(FATAL) << "Error opening the file " << (*iter).Data() << " which should be added to the input chain or as friend chain" << FairLogger::endl;
+        }
+
+        if (fCheckFileLayout) {
+          // Check if the branchlist is the same as for the first input file.
+          Bool_t isOk = CompareBranchList(inputFile, chainName);
+          if ( !isOk ) {
+            LOG(FATAL) << "Branch structure of the input file " << fRootFile->GetName() << " and the file to be added " << (*iter).Data() << " are different." << FairLogger::endl;
+            return kFALSE;
+          }
+        }
+
+        // Add the runid information for all files in the chain.
+        //GetRunIdInfo(inputFile->GetName(), chainName);
+        // Add the file to the input chain
+        fInChain->Add( (*iter) );
+        
+        // Close the temporarly file and restore the gFile pointer.
+        inputFile->Close();
+        gFile = temp;
+
+    }
+    fNoOfEntries = fInChain->GetEntries();
+     
+    LOG(DEBUG) << "Entries in this Source " << fNoOfEntries << FairLogger::endl;
+    
+    for(Int_t i=0; i<fListFolder->GetEntriesFast(); i++) {
+       TFolder* fold = static_cast<TFolder*>(fListFolder->At(i));
+       fEvtHeader = static_cast<FairEventHeader*>(fold->FindObjectAny("EventHeader."));
+       fMCHeader  = static_cast<FairMCEventHeader*>(fold->FindObjectAny("MCEventHeader."));
+       if ( fEvtHeader ) {
+	  ActivateObject(reinterpret_cast<TObject**>(&fEvtHeader),"EventHeader.");
+       }
+       if ( fMCHeader  ) {
+	  ActivateObject(reinterpret_cast<TObject**>(&fMCHeader),"MCEventHeader.");
+       }
+    }
+
+    FairRootManager::Instance()->SetListOfFolders(fListFolder);
+
+    AddFriendsToChain();
+
+   TList* timebasedlist= dynamic_cast <TList*> (fRootFile->Get("TimeBasedBranchList"));
+   if(timebasedlist==0) {
+      LOG(WARNING) << "No time based branch list in input file" << FairLogger::endl;
+   }else{
+     FairRootManager::Instance()->SetTimeBasedBranchNameList(timebasedlist);
+   }
+ 
+   return kTRUE;
+   
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::SetInTree(TTree*  tempTree)  {
+  fInTree = NULL; 
+  fInTree  = tempTree; 
+  fRootFile=static_cast<TFile*>(tempTree->GetCurrentFile());
+  fInChain->Reset();
+  IsInitialized=kFALSE;
+  Init();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t FairFileSource::ReadEvent(UInt_t i)
+{
+    fCurrentEntryNo = i;
+    SetEventTime();
+    if ( fInChain->GetEntry(i) ) return 0;
+
+    return 1;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::Close()
+{
+    CloseInFile();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::Reset()
+{
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::AddFriend(TString fName)
+{
+    fFriendFileList.push_back(fName);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::AddFile(TString FileName)
+{
+    fInputChainList.push_back(FileName);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::AddFriendsToChain()
+{
+    // Loop over all Friend files and extract the type. The type is defined by
+    // the tree which is stored in the file. If there is already a chain of with
+    // this type of tree then the file will be added to this chain.
+    // If there is no such chain it will be created.
+    //
+    // Check if the order of runids and the event numbers per runid for all
+    // friend chains is the same as the one defined by the input chain.
+    // TODO: Should the order be corrected or should the execution be stopped.
+    // The order in the input tree defined by the order in which the files have
+    // been added. A file is defined by the runid.
+    
+    // In the old way it was needed sometimes to add a freind file more
+    // than once. This is not needed any longer, so we remove deuplicates
+    // from the list and display a warning.
+    std::list<TString> friendList;
+    std::list<TString>::iterator iter1;
+    for(iter1 = fFriendFileList.begin();
+        iter1 != fFriendFileList.end(); iter1++) {
+        if (find(friendList.begin(), friendList.end(), (*iter1))
+            == friendList.end()) {
+            friendList.push_back(*iter1);
+        }
+    }
+    // TODO: print a warning if it was neccessary to remove a filname from the
+    // list. This can be chacked by comparing the size of both list
+    
+    TFile* temp = gFile;
+    
+    Int_t friendType = 1;
+    // Loop over all files which have been added as friends
+    for(iter1 = friendList.begin();
+        iter1 != friendList.end(); iter1++) {
+        std::list<TString>::iterator iter;
+        TString inputLevel;
+        // Loop over all already defined input levels to check if this type
+        // of friend tree is already added.
+        // If this type of friend tree already exist add the file to the
+        // then already existing friend chain. If this type of friend tree
+        // does not exist already create a new friend chain and add the file.
+        Bool_t inputLevelFound = kFALSE;
+        TFile* inputFile;
+        for ( iter = fInputLevel.begin(); iter !=fInputLevel.end(); iter++ ) {
+            inputLevel = (*iter);
+            
+            inputFile = new TFile((*iter1));
+            if (inputFile->IsZombie()) {
+	      LOG(FATAL) << "Error opening the file " << (*iter).Data()
+			 << " which should be added to the input chain or as friend chain" << FairLogger::endl;
+            }
+            
+            // Check if the branchlist is already stored in the map. If it is
+            // already stored add the file to the chain.
+            Bool_t isOk = CompareBranchList(inputFile, inputLevel);
+            if ( isOk ) {
+                inputLevelFound = kTRUE;
+                inputFile->Close();
+                continue;
+            }
+            inputFile->Close();
+        }
+        if (!inputLevelFound) {
+            inputLevel= Form("FriendTree_%i",friendType);
+            CreateNewFriendChain((*iter1), inputLevel);
+            friendType++;
+        }
+
+        TChain* chain = static_cast<TChain*>(fFriendTypeList[inputLevel]);
+        chain->AddFile((*iter1), 1234567890, FairRootManager::GetTreeName());
+    }
+    gFile=temp;
+    
+    // Check if all friend chains have the same runids and the same
+    // number of event numbers as the corresponding input chain
+    // CheckFriendChains();
+    
+    // Add all the friend chains which have been created to the
+    // main input chain.
+    std::map< TString, TChain* >::iterator mapIterator;
+    for (mapIterator = fFriendTypeList.begin();
+         mapIterator != fFriendTypeList.end(); mapIterator++ ) {
+        
+        TChain* chain = static_cast<TChain*>(mapIterator->second);
+        fInChain->AddFriend(chain);
+    }
+    
+    // Print some output about the input structure
+    PrintFriendList();
+    
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::PrintFriendList( )
+{
+    // Print information about the input structure
+    // List files from the input chain together with all files of
+    // all friend chains
+    
+  LOG(INFO) << "The input consists out of the following trees and files: "
+	    <<FairLogger::endl;
+  LOG(INFO) << " - " << fInChain->GetName() << FairLogger::endl;
+    TObjArray* fileElements=fInChain->GetListOfFiles();
+    TIter next(fileElements);
+    TChainElement* chEl=0;
+    while (( chEl=static_cast<TChainElement*>(next()) )) {
+      LOG(INFO) << "    - " << chEl->GetTitle() << FairLogger::endl;
+    }
+    
+    map< TString, TChain* >::iterator mapIterator;
+    for (mapIterator = fFriendTypeList.begin();
+         mapIterator != fFriendTypeList.end(); mapIterator++ ) {
+        TChain* chain = static_cast<TChain*>(mapIterator->second);
+        LOG(INFO) << " - " << chain->GetName() << FairLogger::endl;
+        fileElements=chain->GetListOfFiles();
+        TIter next1(fileElements);
+        chEl=0;
+        while (( chEl=static_cast<TChainElement*>(next1()) )) {
+	  LOG(INFO) << "    - " << chEl->GetTitle() << FairLogger::endl;
+        }
+    }
+    
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::CheckFriendChains()
+{
+    std::multimap< TString, std::multimap<TString,TArrayI> >::iterator it1;
+    std::multimap<TString,TArrayI> map1;
+    
+    // Get the structure from the input chain
+    it1=fRunIdInfoAll.find("InputChain");
+    map1 = it1->second;
+    std::vector<Int_t> runid;
+    std::vector<Int_t> events;
+    std::multimap<TString,TArrayI>::iterator it;
+    for ( it=map1.begin() ; it != map1.end(); it++ ) {
+        TArrayI bla = (*it).second;
+        runid.push_back(bla[0]);
+        events.push_back(bla[1]);
+    }
+    
+    // Now loop over all chains except the input chain and comapare the
+    // runids and event numbers.
+    // If there is a mismatch stop the execution.
+    Int_t errorFlag = 0;
+    TString inputLevel;
+    std::list<TString>::iterator listit;
+    for ( listit=fInputLevel.begin() ; listit != fInputLevel.end(); listit++ ) {
+        inputLevel = (*listit);
+        if ( !inputLevel.Contains("InputChain") ) {
+            it1=fRunIdInfoAll.find(inputLevel);
+            map1 = it1->second;
+            if ( runid.size() != map1.size()) {
+                errorFlag = 1;
+                //        goto error_label;
+                break;
+            }
+            Int_t counter = 0;
+            for ( it=map1.begin() ; it != map1.end(); it++ ) {
+                TArrayI bla = (*it).second;
+                if ( (bla[0] != runid[counter]) || (bla[1] != events[counter]) ) {
+                    errorFlag = 2;
+                    //          goto error_label;
+                    break;
+                }
+                counter++;
+            }
+            if (errorFlag>0) {
+                break;
+            }
+        }
+    }
+    
+    // Use goto to leave double loop at once in case of error
+    // error_label:
+    if (errorFlag>0) {
+      LOG(ERROR) << "The input chain and the friend chain " << inputLevel.Data() 
+		 << " have a different structure:" << FairLogger::endl;
+        if (errorFlag == 1) {
+	  LOG(ERROR) << "The input chain has the following runids and event numbers:" << FairLogger::endl;
+            for ( UInt_t i=0; i<runid.size(); i++) {
+	      LOG(ERROR) << " - Runid " << runid[i] << " with " << events[i] 
+			 << " events" << FairLogger::endl;
+            }
+            LOG(ERROR) << "The " << inputLevel.Data() 
+		       << " chain has the following runids and event numbers:"
+		       << FairLogger::endl;
+            for ( it=map1.begin() ; it != map1.end(); it++ ) {
+                TArrayI bla = (*it).second;
+                LOG(ERROR) << " - Runid " << bla[0] << " with " << bla[1] 
+			   << " events" << FairLogger::endl;
+            }
+        }
+        if (errorFlag == 2) {
+            Int_t counter = 0;
+            for ( it=map1.begin() ; it != map1.end(); it++ ) {
+                TArrayI bla = (*it).second;
+                LOG(ERROR) << "Runid Input Chain, " << inputLevel.Data() 
+			   << " chain: " << bla[0] << ", " << runid[counter]
+			   << FairLogger::endl;
+                LOG(ERROR) << "Event number Input Chain, " << inputLevel.Data()
+			   << " chain: " << bla[1] 
+			   << ", " << events[counter] << FairLogger::endl;
+                counter++;
+            }
+        }
+        LOG(FATAL) << "Event structure mismatch" << FairLogger::endl;
+    }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::CreateNewFriendChain(TString inputFile, TString inputLevel)
+{
+    
+    TFile* temp = gFile;
+    TFile* f = new TFile(inputFile);
+    
+    TFolder* added=NULL;
+    TString folderName = "/cbmout";
+    TString folderName1 = "cbmout";
+    added = dynamic_cast <TFolder*> (f->Get("cbmout"));
+    if(!added) {
+        folderName = "/cbmroot";
+        folderName1 = "cbmroot";
+        added = dynamic_cast <TFolder*> (f->Get("cbmroot"));
+	if (!added) {
+	  LOG(FATAL) << "Could not find folder cbmout nor cbmroot." 
+		     <<FairLogger::endl;
+	  exit(-1);
+	}
+    }
+    folderName1=folderName1+"_"+inputLevel;
+    added->SetName(folderName1);
+    fListFolder->Add( added );
+    
+    /**Get The list of branches from the friend file and add it to the actual list*/
+    TList* list= dynamic_cast <TList*> (f->Get("BranchList"));
+    TString chainName = inputLevel;
+    fInputLevel.push_back(chainName);
+    fCheckInputBranches[chainName] = new std::list<TString>;
+    if(list) {
+        TObjString* Obj=0;
+        for(Int_t i =0; i< list->GetEntries(); i++) {
+            Obj=dynamic_cast <TObjString*> (list->At(i));
+            fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
+	    FairRootManager::Instance()->AddBranchToList(Obj->GetString().Data());
+        }
+    }
+    
+    TChain* chain = new TChain(inputLevel,folderName);
+    fFriendTypeList[inputLevel]=chain;
+    
+    f->Close();
+    gFile = temp;
+    
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairFileSource::CompareBranchList(TFile* fileHandle, TString inputLevel)
+{
+  // fill a set with the original branch structure
+  // This allows to use functions find and erase
+  std::set<TString> branches;
+  std::list<TString>::const_iterator iter;
+  for(iter = fCheckInputBranches[inputLevel]->begin();
+      iter != fCheckInputBranches[inputLevel]->end(); iter++) {
+    branches.insert(*iter);
+  }
+
+  // To do so we have to loop over the branches in the file and to compare
+  // the branches in the file with the information stored in
+  // fCheckInputBranches["InputChain"]. If both lists are equal everything
+  // is okay
+
+  // Get The list of branches from the input file one by one and compare
+  // it to the reference list of branches which is defined for this tree.
+  // If a branch with the same name is found, this branch is removed from
+  // the list. If in the end no branch is left in the list everything is
+  // fine.
+  set<TString>::iterator iter1;
+  TList* list= dynamic_cast <TList*> (fileHandle->Get("BranchList"));
+  if(list) {
+    TObjString* Obj=0;
+    for(Int_t i =0; i< list->GetEntries(); i++) {
+      Obj=dynamic_cast <TObjString*> (list->At(i));
+      iter1=branches.find(Obj->GetString().Data());
+      if (iter1 != branches.end() ) {
+        branches.erase (iter1);
+      } else {
+        // Not found is an error because branch structure is
+        // different. It is impossible to add to tree with a
+        // different branch structure
+        return kFALSE;
+      }
+    }
+  }
+  // If the size of branches is !=0 after removing all branches also in the
+  // reference list, this is also a sign that both branch list are not the
+  // same
+  if (branches.size() != 0 ) {
+    LOG(INFO) << "Compare Branch List will return kFALSE. The list has " << branches.size() << " branches:" << FairLogger::endl;
+    for (std::set<TString>::iterator it=branches.begin(); it!=branches.end(); ++it)
+      LOG(INFO) << "  -> " << *it << FairLogger::endl;
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t   FairFileSource::ActivateObject(TObject** obj, const char* BrName) {
+    if ( fInTree ) {
+        fInTree->SetBranchStatus(BrName,1);
+        fInTree->SetBranchAddress(BrName,obj);
+    }
+    if ( fInChain ) {
+        fInChain->SetBranchStatus(BrName,1);
+        fInChain->SetBranchAddress(BrName,obj);
+    }
+    
+    return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::SetInputFile(TString name) {
+  fRootFile = new TFile(name.Data());
+  if (fRootFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+  }
+  LOG(INFO) << "FairFileSource set------------" << FairLogger::endl;
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t  FairFileSource::CheckMaxEventNo(Int_t EvtEnd)
+{
+  Int_t MaxEventNo=0;
+  if(EvtEnd!=0) {
+    MaxEventNo=EvtEnd;
+  }
+  else {
+    MaxEventNo=fInChain->GetEntries();
+  }
+  return MaxEventNo;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairFileSource::SetEventMeanTime(Double_t mean)
+{
+  fEventMeanTime =mean;
+/*
+  TString form="(1/";
+  form+= mean;
+  form+=")*exp(-x/";
+  form+=mean;
+  form+=")";
+  fTimeProb= new TF1("TimeProb.", form.Data(), 0., mean*10);
+*/
+  fTimeProb = new TF1("TimeProb","(1/[0])*exp(-x/[0])", 0., mean*10);
+  fTimeProb->SetParameter(0,mean);
+  fTimeProb->GetRandom();
+  fEventTimeInMCHeader=kFALSE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::SetEventTimeInterval(Double_t min, Double_t max)
+{
+  fEventTimeMin=min;
+  fEventTimeMax=max;
+  fEventMeanTime=(fEventTimeMin+fEventTimeMax)/2;
+  fEventTimeInMCHeader=kFALSE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::SetBeamTime(Double_t beamTime, Double_t gapTime)
+{
+  fBeamTime = beamTime;
+  fGapTime = gapTime;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::SetEventTime()
+{
+  //Check if the time for the current entry is already set
+  if(fTimeforEntryNo==fCurrentEntryNo) return;
+  LOG(DEBUG) << "Set event time for Entry = "
+	     << fTimeforEntryNo << " , where the current entry is "
+	     << fCurrentEntryNo << " and eventTime is "
+	     << fEventTime << FairLogger::endl;
+  if (fBeamTime < 0){
+	  fEventTime += GetDeltaEventTime();
+  } else {
+	  do {
+		  fEventTime += GetDeltaEventTime();
+	  } while( fmod(fEventTime, fBeamTime + fGapTime) > fBeamTime );
+  }
+  LOG(DEBUG) << "New time = " << fEventTime << FairLogger::endl;
+  fTimeforEntryNo=fCurrentEntryNo;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Double_t FairFileSource::GetDeltaEventTime()
+{
+  Double_t deltaTime = 0;
+  if (fTimeProb != 0) {
+    deltaTime = fTimeProb->GetRandom();
+    LOG(DEBUG) << "Time set via sampling method : " <<  deltaTime
+	       << FairLogger::endl;
+  } else {
+    deltaTime = gRandom->Uniform(fEventTimeMin, fEventTimeMax);
+    LOG(DEBUG) << "Time set via Uniform Random : "
+	       << deltaTime << FairLogger::endl;
+  }
+  return deltaTime;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Double_t FairFileSource::GetEventTime()
+{
+ LOG(DEBUG) << "-- Get Event Time --" << FairLogger::endl;
+  if(!fEvtHeaderIsNew && fEvtHeader!=0) {
+    Double_t EvtTime=fEvtHeader->GetEventTime();
+    if( !(EvtTime<0)) {
+      return   EvtTime;
+    }
+  }
+
+  if (fEventTimeInMCHeader && !fMCHeader) {
+    LOG(DEBUG) << "No MCEventHeader, time is set to 0" << FairLogger::endl;
+    return 0;
+  } else if(fEventTimeInMCHeader && fMCHeader) {
+    fEventTime=fMCHeader->GetT();
+    LOG(DEBUG) << "Get event time from MCEventHeader : "
+	       << fEventTime << " ns" << FairLogger::endl;
+    return fEventTime;
+  } else {
+
+    if(fTimeforEntryNo!=fCurrentEntryNo) {
+      SetEventTime();
+    }
+    LOG(DEBUG) << "Calculate event time from user input : " 
+	       << fEventTime << " ns" << FairLogger::endl;
+    return fEventTime;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairFileSource::ReadBranchEvent(const char* BrName)
+{
+  /**fill the object with content if the other branches in this tree entry were already read**/
+  if(fEvtHeader == 0) { return; } //No event header, Reading will start later
+  if ( fInTree ) {
+    fInTree->FindBranch(BrName)->GetEntry(fEvtHeader->GetMCEntryNumber());
+    return;
+  }
+  if ( fInChain ) { 
+    fInChain->FindBranch(BrName)->GetEntry(fEvtHeader->GetMCEntryNumber());
+    return;
+  } 
+  return;
+}
+//_____________________________________________________________________________
+void   FairFileSource::ReadBranchEvent(const char* BrName, Int_t Entry)
+{
+
+    if ( fInTree ) {
+        fInTree->FindBranch(BrName)->GetEntry(Entry);
+        return;
+    }
+    if ( fInChain ) {
+        fInChain->FindBranch(BrName)->GetEntry(Entry);
+        return;
+    } 
+    return;
+}
+
+//_____________________________________________________________________________
+void FairFileSource::FillEventHeader(FairEventHeader* feh) 
+{
+  feh->SetEventTime(fEventTime);
+  if ( fEvtHeader ) {
+    feh->SetRunId(fEvtHeader->GetRunId());
+    feh->SetMCEntryNumber(fEvtHeader->GetMCEntryNumber());
+  }
+  if ( fMCHeader ) {
+    feh->SetRunId(fMCHeader->GetRunID());
+    feh->SetMCEntryNumber(fMCHeader->GetEventID());
+  }
+  feh->SetInputFileId(0);
+  return;
+}
+//_____________________________________________________________________________
+
+ClassImp(FairFileSource)
+
diff --git a/base/source/FairFileSource.h b/base/source/FairFileSource.h
new file mode 100644
index 0000000..ed58df6
--- /dev/null
+++ b/base/source/FairFileSource.h
@@ -0,0 +1,194 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//
+//  FairFileSource.h
+//  FAIRROOT
+//
+//  Created by Mohammad Al-Turany on 08/02/14.
+//
+//
+
+#ifndef __FAIRROOT__FairFileSource__
+#define __FAIRROOT__FairFileSource__
+
+#include "FairSource.h"
+#include <list>    
+#include "TChain.h"
+#include "TFile.h"
+#include "TFolder.h"
+#include "TF1.h"
+class FairEventHeader;
+class FairFileHeader;
+class FairMCEventHeader;
+class TString;
+class FairLogger;
+class FairRuntimeDb;
+
+class FairFileSource : public FairSource
+{
+public:
+    FairFileSource(TFile *f, const char* Title="InputRootFile", UInt_t identifier=0);
+    FairFileSource(const TString* RootFileName, const char* Title="InputRootFile", UInt_t identifier=0);
+    FairFileSource(const TString RootFileName, const char* Title="InputRootFile", UInt_t identifier=0);
+  //  FairFileSource(const FairFileSource& file);
+    virtual ~FairFileSource();
+    
+    Bool_t              Init();
+    Int_t               ReadEvent(UInt_t i=0);
+    void                Close();
+    void                Reset();
+
+    virtual Source_Type GetSourceType() { return kFILE; }
+
+    virtual void SetParUnpackers() {}
+
+    virtual Bool_t InitUnpackers() { return kTRUE; }
+
+    virtual Bool_t ReInitUnpackers() { return kTRUE; }
+
+    /**Check the maximum event number we can run to*/
+    virtual Int_t  CheckMaxEventNo(Int_t EvtEnd=0);
+    /**Read the tree entry on one branch**/
+    virtual void   ReadBranchEvent(const char* BrName);
+    /**Read specific tree entry on one branch**/
+    virtual void   ReadBranchEvent(const char* BrName, Int_t Entry);
+    virtual void FillEventHeader(FairEventHeader* feh);
+
+    const TFile*        GetRootFile(){return fRootFile;}
+    /** Add a friend file (input) by name)*/
+    void                AddFriend(TString FileName);
+    /**Add ROOT file to input, the file will be chained to already added files*/
+    void                AddFile(TString FileName);
+    void                AddFriendsToChain();
+    void                PrintFriendList();
+    Bool_t              CompareBranchList(TFile* fileHandle, TString inputLevel);
+    void                CheckFriendChains();
+    void                CreateNewFriendChain(TString inputFile, TString inputLevel);
+    TTree*              GetInTree() {return fInChain->GetTree();}
+    TChain*             GetInChain() {return fInChain;}
+    TFile*              GetInFile() {return  fRootFile;}
+    void                CloseInFile() { if(fRootFile) { fRootFile->Close(); }}
+    /**Set the input tree when running on PROOF worker*/
+    void                SetInTree (TTree*  tempTree);
+    TObjArray*          GetListOfFolders(){return fListFolder;}
+    TFolder*            GetBranchDescriptionFolder(){return fCbmroot;}
+    UInt_t              GetEntries(){return fNoOfEntries; }
+
+    //    TList*              GetBranchNameList() {return fBranchNameList;}
+
+    void                SetInputFile(TString name);
+
+    /** Set the repetition time of the beam when it can interact (beamTime) and when no interaction happen (gapTime). The total repetition time is beamTime + gapTime */
+    void                SetBeamTime(Double_t beamTime, Double_t gapTime);
+    /** Set the min and max limit for event time in ns */
+    void                SetEventTimeInterval(Double_t min, Double_t max);
+    /** Set the mean time for the event in ns */
+    void                SetEventMeanTime(Double_t mean);
+    void                SetEventTime();
+    Double_t		GetDeltaEventTime();
+    void                SetFileHeader(FairFileHeader* f) {fFileHeader =f;}
+    Double_t            GetEventTime();
+
+    //    virtual Bool_t   SetObject(TObject* obj, const char* ObjType);
+    //    virtual void     SetObjectName(const char* ObjName, const char* ObjType);
+
+    virtual Bool_t   ActivateObject(TObject** obj, const char* BrName);
+
+    /**Set the status of the EvtHeader
+     *@param Status:  True: The header was creatged in this session and has to be filled
+              FALSE: We use an existing header from previous data level
+     */
+    void                SetEvtHeaderNew(Bool_t Status) {fEvtHeaderIsNew = Status;}
+    Bool_t              IsEvtHeaderNew() {return fEvtHeaderIsNew;}
+
+    /** Allow to disable the testing the file layout when adding files to a chain.
+     */
+    void                SetCheckFileLayout(Bool_t enable) {fCheckFileLayout = enable;}
+
+private:
+    /** Title of input source, could be input, background or signal*/
+    TString                           fInputTitle;
+    /**ROOT file*/
+    TFile*                            fRootFile;
+    /** Current Entry number */
+    Int_t                             fCurrentEntryNr;  //!
+    /** List of all files added with AddFriend */
+    std::list<TString>                fFriendFileList; //!
+    std::list<TString>                fInputChainList;//!
+    std::map<TString, TChain*>          fFriendTypeList;//!
+    std::map<TString, std::list<TString>* > fCheckInputBranches; //!
+    std::list<TString>                      fInputLevel; //!
+    std::map<TString, std::multimap<TString, TArrayI> > fRunIdInfoAll; //!
+    /**Input Chain */
+    TChain*                             fInChain;
+    /**Input Tree */
+    TTree*                              fInTree;
+    /** list of folders from all input (and friends) files*/
+    TObjArray                           *fListFolder; //!
+    /** RuntimeDb*/
+    FairRuntimeDb*           fRtdb;
+    /**folder structure of output*/
+    TFolder*                            fCbmout;
+    /**folder structure of input*/
+    TFolder*                            fCbmroot;
+    /***/
+    UInt_t                              fSourceIdentifier;
+    /**No of Entries in this source*/
+    UInt_t                              fNoOfEntries;
+    /**Initialization flag, true if initialized*/
+    Bool_t                              IsInitialized;
+    
+    FairFileSource(const FairFileSource&);
+    FairFileSource operator=(const FairFileSource&);
+
+    /** MC Event header */
+    FairMCEventHeader*                      fMCHeader; //!
+
+    /**Event Header*/
+    FairEventHeader*                        fEvtHeader; //!
+
+    /**File Header*/
+    FairFileHeader*                        fFileHeader; //!
+
+    /** This is true if the event time used, came from simulation*/
+    Bool_t                                  fEventTimeInMCHeader; //!
+    /**This flag is true if the event header was created in this session
+    * otherwise it is false which means the header was created in a previous data
+    * level and used here (e.g. in the digi)
+    */
+    Bool_t      fEvtHeaderIsNew; //!
+
+    /** for internal use, to return the same event time for the same entry*/
+    UInt_t                                  fCurrentEntryNo; //!
+    /** for internal use, to return the same event time for the same entry*/
+    UInt_t                                  fTimeforEntryNo; //!
+
+    /** min time for one event (ns) */
+    Double_t                                fEventTimeMin;  //!
+    /** max time for one Event (ns) */
+    Double_t                                fEventTimeMax;  //!
+    /** Time of event since th start (ns) */
+    Double_t                                fEventTime;     //!
+    /** Time of particles in beam (ns) */
+    Double_t                                fBeamTime; //!
+    /** Time without particles in beam (gap) (ns) */
+    Double_t                                fGapTime; //!
+    /** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
+    Double_t                                fEventMeanTime; //!
+    /** used to generate random numbers for event time; */
+    TF1*                                    fTimeProb;      //!
+    /** True if the file layout should be checked when adding files to a chain.
+     *  Default value is true.
+     */
+     Bool_t                                 fCheckFileLayout; //!
+
+    ClassDef(FairFileSource, 3)
+};
+
+
+#endif /* defined(__FAIRROOT__FairFileSource__) */
diff --git a/base/source/FairLmdSource.cxx b/base/source/FairLmdSource.cxx
new file mode 100644
index 0000000..b89d47a
--- /dev/null
+++ b/base/source/FairLmdSource.cxx
@@ -0,0 +1,269 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                           FairLmdSource                           -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+#include <iostream>
+using namespace std;
+
+#include "TList.h"
+#include "TObjString.h"
+#include "TRegexp.h"
+#include "TSystemDirectory.h"
+#include "TSystem.h"
+
+#include "FairLmdSource.h"
+#include "FairLogger.h"
+
+FairLmdSource::FairLmdSource()
+  : FairMbsSource(),
+    fCurrentFile(0),
+	fNEvent(0),
+    fCurrentEvent(0),
+    fFileNames(new TList()),
+    fxInputChannel(NULL),
+    fxEvent(NULL),
+    fxBuffer(NULL),
+    fxEventData(NULL),
+    fxSubEvent(NULL),
+    fxInfoHeader(NULL)
+{
+}
+
+
+FairLmdSource::FairLmdSource(const FairLmdSource& source)
+  : FairMbsSource(source),
+    fCurrentFile(source.GetCurrentFile()),
+	fNEvent(0),
+    fCurrentEvent(0),
+    fFileNames(new TList()),
+    fxInputChannel(NULL),
+    fxEvent(NULL),
+    fxBuffer(NULL),
+    fxEventData(NULL),
+    fxSubEvent(NULL),
+    fxInfoHeader(NULL)
+{
+}
+
+
+FairLmdSource::~FairLmdSource()
+{
+  fFileNames->Delete();
+  delete fFileNames;
+}
+
+
+void FairLmdSource::AddFile(TString fileName)
+{
+  FileStat_t buf;
+  if(1 == gSystem->GetPathInfo(fileName.Data(), buf))
+  {
+    LOG(WARNING) << "FairLmdSource: not found: " << fileName << FairLogger::endl;
+    return;
+  }
+
+  TObjString* str = new TObjString(fileName);
+  fFileNames->Add(str);
+}
+
+
+void FairLmdSource::AddPath(TString dir, TString wildCard)
+{
+  FileStat_t buf;
+  if(1 == gSystem->GetPathInfo(dir.Data(), buf))
+  {
+    LOG(WARNING) << "FairLmdSource: not found: " << dir << FairLogger::endl;
+    return;
+  }
+
+  TRegexp *re = new TRegexp(wildCard.Data(), kTRUE);
+  TSystemDirectory *sdir = new TSystemDirectory("dir", dir.Data());
+  TString dname(dir);
+  if(! dname.EndsWith("/"))
+  {
+      dname += "/";
+  }
+  TList *list = sdir->GetListOfFiles();
+
+  TIterator *iter = list->MakeIterator();
+  TSystemFile *file;
+  TString name;
+  while(NULL != (file = static_cast<TSystemFile*>(iter->Next())))
+  {
+    name = file->GetName();
+    if(name.Contains(*re))
+    {
+      name = dname + name;
+      AddFile(name);
+    }
+  }
+
+  list->Delete();
+}
+
+
+Bool_t FairLmdSource::Init()
+{
+  if(fFileNames->GetSize() == 0) {
+    return kFALSE;
+  }
+
+  TString name = (static_cast<TObjString*>(fFileNames->At(fCurrentFile)))->GetString();
+  if(! OpenNextFile(name)) {
+    return kFALSE;
+  }
+
+  fCurrentFile += 1;
+
+ // Init Counters
+  fNEvent=fCurrentEvent=0;
+
+  return kTRUE;
+}
+
+
+Bool_t FairLmdSource::OpenNextFile(TString fileName)
+{
+  Int_t inputMode = GETEVT__FILE;
+  fxInputChannel = new s_evt_channel;
+  void* headptr = &fxInfoHeader;
+  INTS4 status;
+
+  LOG(INFO) << "File " << fileName << " will be opened." << FairLogger::endl;
+
+  status = f_evt_get_open(inputMode,
+                          const_cast<char*>(fileName.Data()),
+                          fxInputChannel,
+                          static_cast<Char_t**>(headptr),
+                          1,
+                          1);
+
+  if(status) {
+     LOG(ERROR) << "File " << fileName << " opening failed." << FairLogger::endl;
+    return kFALSE;
+  }
+
+  LOG(INFO) << "File " << fileName << " opened." << FairLogger::endl;
+
+  // Decode File Header
+  //Bool_t result = Unpack((Int_t*)fxInfoHeader, sizeof(s_filhe), -4, -4, -4, -4, -4);
+  Unpack(reinterpret_cast<Int_t*>(fxInfoHeader), sizeof(s_filhe), -4, -4, -4, -4, -4);
+
+  return kTRUE;
+}
+
+
+Int_t FairLmdSource::ReadEvent(UInt_t)
+{
+  void* evtptr = &fxEvent;
+  void* buffptr = &fxBuffer;
+
+  Int_t status = f_evt_get_event(fxInputChannel, static_cast<INTS4**>(evtptr),static_cast<INTS4**>(buffptr));
+  //Int_t fuEventCounter = fxEvent->l_count;
+  //Int_t fCurrentMbsEventNo = fuEventCounter;
+
+  if(GETEVT__SUCCESS != status) {
+
+    LOG(INFO) << "FairMbsStreamSource::ReadEvent()"
+              << FairLogger::endl;
+
+    CHARS* sErrorString = NULL;
+    f_evt_error(status, sErrorString , 0);
+
+    if(fCurrentFile >= fFileNames->GetSize()) {
+      return 1;
+    }
+
+    if(GETEVT__NOMORE == status) {
+      Close();
+    }
+
+    TString name = (static_cast<TObjString*>(fFileNames->At(fCurrentFile)))->GetString();
+    if(! OpenNextFile(name)) {
+      return 1;
+    } else {
+      fCurrentFile += 1;
+      return ReadEvent();
+    }
+  }
+
+ //Store Start Times
+  if (fCurrentEvent==0 ) 
+      Unpack(reinterpret_cast<Int_t*>(fxBuffer), sizeof(s_bufhe), -4, -4, -4, -4, -4);
+
+
+  // Decode event header
+  Bool_t result = kFALSE;
+  /*Bool_t result = */Unpack(reinterpret_cast<Int_t*>(fxEvent), sizeof(s_ve10_1), -2, -2, -2, -2, -2);
+
+  Int_t nrSubEvts = f_evt_get_subevent(fxEvent, 0, NULL, NULL, NULL);
+  Int_t sebuflength;
+  Short_t setype;
+  Short_t sesubtype;
+  Short_t seprocid;
+  Short_t sesubcrate;
+  Short_t secontrol;
+
+  LOG(DEBUG2)<< "FairLmdSource::ReadEvent => Found " << nrSubEvts << " Sub-event "
+             << FairLogger::endl;
+  //if (fCurrentEvent%10000==0)
+  //cout << " -I- LMD_ANA:  evt# " <<  fCurrentEvent << "  n_subevt# " << nrSubEvts << " evt processed# " << fNEvent <<  " : " << fxEvent->l_count << endl;
+
+
+//  Int_t* SubEventDataPtr = new Int_t;
+  for(Int_t i = 1; i <= nrSubEvts; i++) {
+    void* SubEvtptr = &fxSubEvent;
+    void* EvtDataptr = &fxEventData;
+    Int_t nrlongwords;
+    status = f_evt_get_subevent(fxEvent, i, static_cast<Int_t**>(SubEvtptr), static_cast<Int_t**>(EvtDataptr), &nrlongwords);
+    if(status) {
+      return 1;
+    }
+    sebuflength = nrlongwords;
+    setype = fxSubEvent->i_type;
+    sesubtype = fxSubEvent->i_subtype;
+    seprocid = fxSubEvent->i_procid;
+    sesubcrate = fxSubEvent->h_subcrate;
+    secontrol = fxSubEvent->h_control;
+
+    //cout << setype << "  " << sesubtype << "  " << seprocid << "  " << sesubcrate << "  " << secontrol << endl;
+
+    if(Unpack(fxEventData, sebuflength,
+              setype, sesubtype,
+              seprocid, sesubcrate, secontrol)) {
+      result = kTRUE;
+    }
+  }
+
+  // Increment evt counters.
+  fNEvent++;
+  fCurrentEvent++;
+ 
+  if(! result)
+  {
+    return 2;
+  }
+
+ return 0;
+}
+
+
+void FairLmdSource::Close()
+{
+  f_evt_get_close(fxInputChannel);
+  Unpack(reinterpret_cast<Int_t*>(fxBuffer), sizeof(s_bufhe), -4, -4, -4, -4, -4);  
+  fCurrentEvent=0;
+}
+
+
+ClassImp(FairLmdSource)
+
+
diff --git a/base/source/FairLmdSource.h b/base/source/FairLmdSource.h
new file mode 100644
index 0000000..a7c6b6a
--- /dev/null
+++ b/base/source/FairLmdSource.h
@@ -0,0 +1,68 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                           FairLmdSource                           -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRLMDSOURCE_H
+#define FAIRLMDSOURCE_H
+
+extern "C"
+{
+#include "f_evt.h"
+#include "s_filhe_swap.h"
+#include "s_bufhe_swap.h"
+}
+
+#include "TString.h"
+
+#include "FairMbsSource.h"
+
+
+class TList;
+
+
+class FairLmdSource : public FairMbsSource
+{
+  public:
+    FairLmdSource();
+    FairLmdSource(const FairLmdSource& source);
+    virtual ~FairLmdSource();
+
+    void AddFile(TString fileName);
+    void AddPath(TString dir, TString wildCard);
+    inline Int_t GetCurrentFile() const { return fCurrentFile; }
+    inline const TList* GetFileNames() const { return fFileNames; }
+
+    virtual Bool_t Init();
+    virtual Int_t ReadEvent(UInt_t=0);
+    virtual void Close();
+
+  protected:
+    Bool_t OpenNextFile(TString fileName);
+
+    Int_t fCurrentFile;
+	Int_t fNEvent;
+	Int_t fCurrentEvent;
+    TList* fFileNames;
+    s_evt_channel* fxInputChannel;
+    s_ve10_1* fxEvent;
+    s_bufhe* fxBuffer;
+    Int_t* fxEventData;
+    s_ves10_1* fxSubEvent;
+	s_filhe* fxInfoHeader;
+
+    FairLmdSource& operator=(const FairLmdSource&);
+
+    ClassDef(FairLmdSource, 0)
+};
+
+
+#endif
diff --git a/base/source/FairMbsSource.cxx b/base/source/FairMbsSource.cxx
new file mode 100644
index 0000000..96a90d8
--- /dev/null
+++ b/base/source/FairMbsSource.cxx
@@ -0,0 +1,66 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairMbsSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----              Copied from FairSource 01.11.2013 by F.Uhlig         -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#include <iostream>
+
+#include "FairMbsSource.h"
+#include "FairLogger.h"
+
+FairMbsSource::FairMbsSource() : FairOnlineSource() {}
+
+FairMbsSource::FairMbsSource(const FairMbsSource &source)
+    : FairOnlineSource(source) {}
+
+FairMbsSource::~FairMbsSource() {
+}
+
+Bool_t FairMbsSource::Unpack(Int_t *data, Int_t size, Short_t type,
+                             Short_t subType, Short_t procId, Short_t subCrate,
+                             Short_t control) {
+
+  LOG(DEBUG2)<< "FairMbsSource::Unpack => Found Sub-event with flags: " 
+             << " Type " << type << " SubType " << subType
+             << " ProcId " << procId << " SubCrate " << subCrate
+             << " Control " << control
+             << FairLogger::endl;
+  
+  FairUnpack *unpack;
+  Bool_t seen = kFALSE;
+  for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
+    unpack = static_cast<FairUnpack*>(fUnpackers->At(i));
+
+    if (unpack->GetSubCrate() < 0) { // All sub-crates
+      if (type != unpack->GetType() || subType != unpack->GetSubType() ||
+          procId != unpack->GetProcId() || control != unpack->GetControl()) {
+        continue;
+      }
+    } else { // specified sub-crate
+      if (type != unpack->GetType() || subType != unpack->GetSubType() ||
+          procId != unpack->GetProcId() || subCrate != unpack->GetSubCrate() ||
+          control != unpack->GetControl()) {
+        continue;
+      }
+    }
+
+    if (!unpack->DoUnpack(data, size)) {
+      return kFALSE;
+    }
+
+    seen = kTRUE;
+  }
+  return seen;
+}
+
+ClassImp(FairMbsSource)
diff --git a/base/source/FairMbsSource.h b/base/source/FairMbsSource.h
new file mode 100644
index 0000000..f65cc0b
--- /dev/null
+++ b/base/source/FairMbsSource.h
@@ -0,0 +1,45 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairMbsSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----              Copied from FairSource 01.11.2013 by F.Uhlig         -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRMBSSOURCE_H
+#define FAIRMBSSOURCE_H
+
+#include "FairOnlineSource.h"
+#include "TObjArray.h"
+
+#include "FairUnpack.h"
+
+
+class FairMbsSource : public FairOnlineSource
+{
+  public:
+    FairMbsSource();
+    FairMbsSource(const FairMbsSource& source);
+    virtual ~FairMbsSource();
+
+    virtual Bool_t Init() = 0;
+    virtual Int_t ReadEvent(UInt_t=0) = 0;
+    virtual void Close() = 0;
+
+  protected:
+    Bool_t Unpack(Int_t* data, Int_t size,
+                  Short_t type, Short_t subType,
+                  Short_t procId, Short_t subCrate, Short_t control);
+
+    ClassDef(FairMbsSource, 0)
+};
+
+
+#endif
diff --git a/base/source/FairMbsStreamSource.cxx b/base/source/FairMbsStreamSource.cxx
new file mode 100644
index 0000000..480c060
--- /dev/null
+++ b/base/source/FairMbsStreamSource.cxx
@@ -0,0 +1,162 @@
+// -----------------------------------------------------------------------------
+// ----- FairMbsStreamSource source file                                   -----
+// -----                                                                   -----
+// ----- created by C. Simon on 2014-09-12                                 -----
+// -----                                                                   -----
+// ----- based on FairLmdSource by D. Kresan                               -----
+// -----                                                                   -----
+// ----- revision 24905, 2014-05-12                                        -----
+// -----------------------------------------------------------------------------
+
+#include "FairMbsStreamSource.h"
+
+#include "FairLogger.h"
+
+FairMbsStreamSource::FairMbsStreamSource(TString tServerName)
+  : FairMbsSource(),
+    fServerName(tServerName),
+    fxInputChannel(NULL),
+    fxEvent(NULL),
+    fxBuffer(NULL),
+    fxEventData(NULL),
+    fxSubEvent(NULL)
+{
+}
+
+
+FairMbsStreamSource::FairMbsStreamSource(const FairMbsStreamSource& source)
+  : FairMbsSource(source),
+    fServerName(source.GetServerName()),
+    fxInputChannel(NULL),
+    fxEvent(NULL),
+    fxBuffer(NULL),
+    fxEventData(NULL),
+    fxSubEvent(NULL)
+{
+}
+
+
+FairMbsStreamSource::~FairMbsStreamSource()
+{
+}
+
+
+Bool_t FairMbsStreamSource::Init()
+{
+  if(! ConnectToServer()) {
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
+
+
+Bool_t FairMbsStreamSource::ConnectToServer()
+{
+  Int_t inputMode = GETEVT__STREAM;
+  fxInputChannel = new s_evt_channel;
+  s_filhe fxInfoHeader;
+  void* headptr = &fxInfoHeader;
+  INTS4 status;
+
+  LOG(INFO) << "FairMbsStreamSource::ConnectToServer()"
+		    << FairLogger::endl;
+  LOG(INFO) << Form("- open connection to MBS stream server %s...", fServerName.Data())
+		    << FairLogger::endl;
+
+  status = f_evt_get_open(inputMode,
+                          const_cast<char*>(fServerName.Data()),
+                          fxInputChannel,
+                          static_cast<Char_t**>(headptr),
+                          1,
+                          1);
+
+  CHARS* sErrorString = NULL;
+  f_evt_error(status, sErrorString , 0);
+
+  if(GETEVT__SUCCESS != status) {
+    return kFALSE;
+  }
+
+  LOG(INFO) << Form("- connection to MBS stream server %s established.", fServerName.Data())
+		    << FairLogger::endl;
+
+  return kTRUE;
+}
+
+
+Int_t FairMbsStreamSource::ReadEvent(UInt_t)
+{
+  void* evtptr = &fxEvent;
+  void* buffptr = &fxBuffer;
+
+  LOG(DEBUG2)<< "FairLmdSource::ReadEvent => New event "
+             << FairLogger::endl;
+
+  Int_t status = f_evt_get_event(fxInputChannel, static_cast<INTS4**>(evtptr),static_cast<INTS4**>(buffptr));
+
+  LOG(DEBUG2)<< "FairLmdSource::ReadEvent => f_evt_get_event status: " << status
+             << FairLogger::endl;
+
+  if(GETEVT__SUCCESS != status) {
+    LOG(INFO) << "FairMbsStreamSource::ReadEvent()"
+              << FairLogger::endl;
+
+    CHARS* sErrorString = NULL;
+    f_evt_error(status, sErrorString , 0);
+
+    return 1;
+  }
+
+  Int_t nrSubEvts = f_evt_get_subevent(fxEvent, 0, NULL, NULL, NULL);
+
+  Int_t sebuflength;
+  Short_t setype;
+  Short_t sesubtype;
+  Short_t seprocid;
+  Short_t sesubcrate;
+  Short_t secontrol;
+
+  LOG(DEBUG2)<< "FairLmdSource::ReadEvent => Found " << nrSubEvts << " Sub-event "
+             << FairLogger::endl;
+
+  for(Int_t i = 1; i <= nrSubEvts; i++) {
+    void* SubEvtptr = &fxSubEvent;
+    void* EvtDataptr = &fxEventData;
+    Int_t nrlongwords;
+
+    status = f_evt_get_subevent(fxEvent, i, static_cast<Int_t**>(SubEvtptr), static_cast<Int_t**>(EvtDataptr), &nrlongwords);
+
+    sebuflength = nrlongwords;
+    setype = fxSubEvent->i_type;
+    sesubtype = fxSubEvent->i_subtype;
+    seprocid = fxSubEvent->i_procid;
+    sesubcrate = fxSubEvent->h_subcrate;
+    secontrol = fxSubEvent->h_control;
+
+    if(! Unpack(fxEventData, sebuflength,
+                setype, sesubtype,
+                seprocid, sesubcrate, secontrol)) {
+      return 2;
+    }
+  }
+
+  return 0;
+}
+
+
+void FairMbsStreamSource::Close()
+{
+  Int_t status = f_evt_get_close(fxInputChannel);
+
+  LOG(INFO) << "FairMbsStreamSource::Close()"
+  		    << FairLogger::endl;
+
+  CHARS* sErrorString = NULL;
+  f_evt_error(status, sErrorString , 0);
+}
+
+
+ClassImp(FairMbsStreamSource)
+
+
diff --git a/base/source/FairMbsStreamSource.h b/base/source/FairMbsStreamSource.h
new file mode 100644
index 0000000..2db00c9
--- /dev/null
+++ b/base/source/FairMbsStreamSource.h
@@ -0,0 +1,57 @@
+// -----------------------------------------------------------------------------
+// ----- FairMbsStreamSource header file                                   -----
+// -----                                                                   -----
+// ----- created by C. Simon on 2014-09-12                                 -----
+// -----                                                                   -----
+// ----- based on FairLmdSource by D. Kresan                               -----
+// -----                                                                   -----
+// ----- revision 23363, 2013-12-26                                        -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRMBSSTREAMSOURCE_H
+#define FAIRMBSSTREAMSOURCE_H
+
+extern "C"
+{
+#include "f_evt.h"
+#include "s_filhe_swap.h"
+#include "s_bufhe_swap.h"
+}
+
+#include "TString.h"
+
+#include "FairMbsSource.h"
+
+class FairMbsStreamSource : public FairMbsSource
+{
+  public:
+    FairMbsStreamSource(TString tServerName);
+    FairMbsStreamSource(const FairMbsStreamSource& source);
+    virtual ~FairMbsStreamSource();
+
+    virtual Bool_t Init();
+    virtual Int_t ReadEvent(UInt_t=0);
+    virtual void Close();
+
+    const char* GetServerName() const {return fServerName.Data();};
+
+  private:
+    Bool_t ConnectToServer();
+
+    TString fServerName;
+
+    s_evt_channel* fxInputChannel;
+    s_ve10_1* fxEvent;
+    s_bufhe* fxBuffer;
+    Int_t* fxEventData;
+    s_ves10_1* fxSubEvent;
+
+    FairMbsStreamSource& operator=(const FairMbsStreamSource&);
+
+
+  public:
+    ClassDef(FairMbsStreamSource, 0)
+};
+
+
+#endif
diff --git a/base/source/FairMixedSource.cxx b/base/source/FairMixedSource.cxx
new file mode 100644
index 0000000..3be26fe
--- /dev/null
+++ b/base/source/FairMixedSource.cxx
@@ -0,0 +1,840 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+
+//
+//  FairMixedSource.cxx
+//  FAIRROOT
+//
+//  Created by Mohammad Al-Turany on 08/02/14.
+//
+//
+#include "FairMixedSource.h"
+#include "TString.h"
+#include "FairEventHeader.h"
+#include "FairFileHeader.h"
+#include "FairMCEventHeader.h"
+#include "FairLogger.h"
+#include "FairRootManager.h"
+#include "TObjArray.h"
+#include <map> 
+#include <set> 
+#include <algorithm>                    // for find
+#include "TChainElement.h"
+#include "TFolder.h"
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "TRandom.h"                    // for TRandom, gRandom
+#include "TROOT.h"
+#include <list>                         // for _List_iterator, list, etc
+using std::map;
+using std::set;
+
+
+FairMixedSource::FairMixedSource(TFile *f, const char* Title, UInt_t)
+  :FairSource(),
+   fRootManager(0),
+   fInputTitle(Title),
+   fRootFile(f),
+   fFriendFileList(),
+   fInputChainList(),
+   fFriendTypeList(),
+   fCheckInputBranches(),
+   fInputLevel(),
+   fRunIdInfoAll(),
+   fListFolder(new TObjArray(16)),
+   fRtdb(FairRuntimeDb::instance()),
+   fCbmout(0),
+   fCbmroot(0),
+   fSourceIdentifier(0),
+   fNoOfEntries(-1),
+   IsInitialized(kFALSE),
+    fMCHeader(0),
+    fEvtHeader(0),
+    fOutHeader(0),
+    fFileHeader(0),
+   fEventTimeInMCHeader(kTRUE),
+    fEvtHeaderIsNew(kFALSE),
+    fCurrentEntryNo(0),
+    fTimeforEntryNo(0),
+    fNoOfBGEntries(0),
+  fCurrentEntry(),
+    fEventTimeMin(0.),
+    fEventTimeMax(0.),
+    fEventTime(0.),
+  fBeamTime(-1.),
+  fGapTime(-1.),
+    fEventMeanTime(0.),
+    fTimeProb(0),
+   fSignalBGN(),
+   fSBRatiobyN(kFALSE),
+  fSBRatiobyT(kFALSE),
+   fActualSignalIdentifier(0),
+   fNoOfSignals(0),
+   fSignalChainList(NULL),
+   fBackgroundChain(NULL),
+   fSignalTypeList()
+{
+   if (fRootFile->IsZombie()) {
+     LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+   }
+   LOG(INFO) << "FairMixedSource created------------" << FairLogger::endl;
+  
+  fRootManager = FairRootManager::Instance();
+
+}
+FairMixedSource::FairMixedSource(const TString* RootFileName, const char* Title, UInt_t)
+:FairSource(),
+ fRootManager(0),
+ fInputTitle(Title),
+ fRootFile(0),
+   fFriendFileList(),
+   fInputChainList(),
+   fFriendTypeList(),
+   fCheckInputBranches(),
+   fInputLevel(),
+   fRunIdInfoAll(),
+ fListFolder(new TObjArray(16)),
+ fRtdb(FairRuntimeDb::instance()),
+ fCbmout(0),
+ fCbmroot(0),
+ fSourceIdentifier(0),
+ fNoOfEntries(-1),
+ IsInitialized(kFALSE),
+    fMCHeader(0),
+    fEvtHeader(0),
+    fOutHeader(0),
+    fFileHeader(0),
+   fEventTimeInMCHeader(kTRUE),
+    fEvtHeaderIsNew(kFALSE),
+    fCurrentEntryNo(0),
+    fTimeforEntryNo(0),
+    fNoOfBGEntries(0),
+  fCurrentEntry(),
+    fEventTimeMin(0.),
+    fEventTimeMax(0.),
+    fEventTime(0.),
+  fBeamTime(-1.),
+  fGapTime(-1.),
+    fEventMeanTime(0.),
+    fTimeProb(0),
+   fSignalBGN(),
+   fSBRatiobyN(kFALSE),
+  fSBRatiobyT(kFALSE),
+    fActualSignalIdentifier(0),
+    fNoOfSignals(0),
+    fSignalChainList(NULL),
+    fBackgroundChain(NULL),
+    fSignalTypeList()
+{
+  fRootFile = new TFile(RootFileName->Data());
+  if (fRootFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Input file" << FairLogger::endl;
+  }
+  fRootManager = FairRootManager::Instance();
+  LOG(INFO) << "FairMixedSource created------------" << FairLogger::endl;
+}
+
+FairMixedSource::FairMixedSource(const TString RootFileName, const Int_t signalId, const char* Title, UInt_t) 
+  :FairSource(), 
+   fRootManager(0),
+   fInputTitle(Title),
+   fRootFile(0),
+   fFriendFileList(),
+   fInputChainList(),
+   fFriendTypeList(),
+   fCheckInputBranches(),
+   fInputLevel(),
+   fRunIdInfoAll(),
+   fListFolder(new TObjArray(16)),
+   fRtdb(FairRuntimeDb::instance()),
+   fCbmout(0),
+   fCbmroot(0),
+   fSourceIdentifier(0),
+   fNoOfEntries(-1),
+   IsInitialized(kFALSE),
+    fMCHeader(0),
+    fEvtHeader(0),
+  fOutHeader(0),
+    fFileHeader(0),
+   fEventTimeInMCHeader(kTRUE),
+    fEvtHeaderIsNew(kFALSE),
+    fCurrentEntryNo(0),
+    fTimeforEntryNo(0),
+    fNoOfBGEntries(0),
+  fCurrentEntry(),
+    fEventTimeMin(0.),
+    fEventTimeMax(0.),
+    fEventTime(0.),
+  fBeamTime(-1.),
+  fGapTime(-1.),
+    fEventMeanTime(0.),
+    fTimeProb(0),
+   fSignalBGN(),
+   fSBRatiobyN(kFALSE),
+  fSBRatiobyT(kFALSE),
+   fActualSignalIdentifier(0),
+   fNoOfSignals(0),
+   fSignalChainList(NULL),
+   fBackgroundChain(NULL),
+  fSignalTypeList()
+{
+    fRootFile = new TFile(RootFileName.Data());
+
+  if ( signalId == 0 ) {
+    SetBackgroundFile(RootFileName);
+  }
+  else {
+    SetSignalFile(RootFileName,signalId);
+  }
+    fRootManager = FairRootManager::Instance();
+  // fBackgroundFile =  new TFile(name);
+  // if (fBackgroundFile->IsZombie()) {
+  // } else {
+  //   fBackgroundChain = new TChain(FairRootManager::GetTreeName(), "/cbmroot");
+  //   fBackgroundChain->AddFile(name.Data());
+  // }
+}
+
+FairMixedSource::~FairMixedSource()
+{
+}
+Bool_t FairMixedSource::Init()
+{
+  fOutHeader = new FairEventHeader();
+  LOG(INFO) << "fSBRatiobyN = " << (fSBRatiobyN?"true":"false") << " / fSBRatiobyT = " << (fSBRatiobyT?"true":"false") << FairLogger::endl;
+
+  //  LOG(INFO) << "*********** CHAIN HAS " << fBackgroundChain->GetEntries() << " entries" << FairLogger::endl;
+  if(IsInitialized){
+    LOG(INFO) << "FairMixedSource already initialized" << FairLogger::endl;
+    return kTRUE;
+  }
+  if (!fBackgroundChain ) {
+    fBackgroundChain = new TChain(FairRootManager::GetTreeName(), "/cbmroot");
+    LOG(INFO) << "FairMixedSource::Init() chain created" << FairLogger::endl;
+  }
+
+    fBackgroundChain->Add( fRootFile->GetName() );
+    LOG(INFO) << "*********** CHAIN HAS " << fBackgroundChain->GetEntries() << " entries" << FairLogger::endl;
+    
+// Get the folder structure from file which describes the input tree.
+    // There are two different names possible, so check both.
+    fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmroot"));
+    if(!fCbmroot) {
+      fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmout"));
+      if(!fCbmroot) {
+	fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
+      } else {
+	fCbmroot->SetName("cbmroot");
+      }
+    }
+    // Get The list of branches from the input file and add it to the
+    // actual list of existing branches.
+    // Add this list of branches also to the map of input trees, which
+    // stores the information which branches belong to which input tree.
+    // There is at least one primary input tree, but there can be many
+    // additional friend trees.
+    // This information is needed to add new files to the correct friend
+    // tree. With this information it is also possible to check if the
+    // input files which are added to the input chain all have the same
+    // branch structure. Without this check it is possible to add trees
+    // with a different branch structure but the same tree name. ROOT
+    // probably only checks if the name of the tree is the same.
+
+    TList* list= dynamic_cast <TList*> (fRootFile->Get("BranchList"));
+    if(list==0) LOG(FATAL) << "No Branch list in input file" << FairLogger::endl;
+    TString chainName = fInputTitle;
+    TString ObjName;
+    fInputLevel.push_back(chainName);
+    fCheckInputBranches[chainName] = new std::list<TString>;
+    if(list) {
+        TObjString* Obj=0;
+        LOG(INFO) << "Enteries in the list " << list->GetEntries() << FairLogger::endl;
+        for(Int_t i =0; i< list->GetEntries(); i++) {
+            Obj=dynamic_cast <TObjString*> (list->At(i));
+            if(Obj!=0){
+                ObjName=Obj->GetString();
+                LOG(INFO) << "Branch name " << ObjName.Data() << FairLogger::endl;
+                fCheckInputBranches[chainName]->push_back(ObjName.Data());
+                
+                FairRootManager::Instance()->AddBranchToList(ObjName.Data());
+            }
+        }
+    }
+    
+    gROOT->GetListOfBrowsables()->Add(fCbmroot);
+    fListFolder->Add( fCbmroot );
+
+    // Store the information about the unique runids in the input file
+    // together with the filename and the number of events for each runid
+    // this information is needed later to check if inconsitencies exist
+    // between the main input chain and any of the friend chains.
+    
+    //  GetRunIdInfo(fInFile->GetName(), chainName);
+    
+    // Add all additional input files to the input chain and do a
+    // consitency check
+    std::list<TString>::const_iterator iter;
+    for(iter = fInputChainList.begin(); iter != fInputChainList.end(); iter++) {
+        // Store global gFile pointer for safety reasons.
+        // Set gFile to old value at the end of the routine.R
+        TFile* temp = gFile;
+        
+        // Temporarily open the input file to extract information which
+        // is needed to bring the friend trees in the correct order
+        TFile* inputFile = new TFile((*iter));
+        if (inputFile->IsZombie()) {
+	  LOG(FATAL) << "Error opening the file " << (*iter).Data() << " which should be added to the input chain or as friend chain" << FairLogger::endl;
+        }
+        
+        // Check if the branchlist is the same as for the first input file.
+        Bool_t isOk = CompareBranchList(inputFile, chainName);
+        if ( !isOk ) {
+	  LOG(FATAL) << "Branch structure of the input file " << fRootFile->GetName() << " and the file to be added " << (*iter).Data() << FairLogger::endl;
+            return kFALSE;
+        }
+        
+        // Add the runid information for all files in the chain.
+        //GetRunIdInfo(inputFile->GetName(), chainName);
+        // Add the file to the input chain
+        fBackgroundChain->Add( (*iter) );
+        
+        // Close the temporarly file and restore the gFile pointer.
+        inputFile->Close();
+        gFile = temp;
+
+    }
+    fNoOfEntries = fBackgroundChain->GetEntries();
+    FairRootManager::Instance()->SetInChain(fBackgroundChain,0);
+
+    for(Int_t i=0; i<fListFolder->GetEntriesFast(); i++) {
+      TFolder* fold = static_cast<TFolder*>(fListFolder->At(i));
+      fEvtHeader = static_cast<FairEventHeader*>(fold->FindObjectAny("EventHeader."));
+      fMCHeader  = static_cast<FairMCEventHeader*>(fold->FindObjectAny("MCEventHeader."));
+      if ( fEvtHeader ) {
+	ActivateObject(reinterpret_cast<TObject**>(&fEvtHeader),"EventHeader.");
+      }
+      if ( fMCHeader  ) {
+	ActivateObject(reinterpret_cast<TObject**>(&fMCHeader),"MCEventHeader.");
+      }
+    }
+    FairRootManager::Instance()->SetListOfFolders(fListFolder);
+
+    fBackgroundChain->GetEntry(0);
+    if ( fEvtHeader ) {
+      fOutHeader->SetRunId      (fEvtHeader->GetRunId());
+    }
+    if ( fMCHeader ) {
+      fOutHeader->SetRunId      (fMCHeader->GetRunID());
+    }
+
+
+    LOG(INFO) << "Entries in this Source " << fNoOfEntries << " ------------" << FairLogger::endl;
+    return kTRUE;
+
+  
+}
+Int_t FairMixedSource::ReadEvent(UInt_t i)
+{
+  SetEventTime();
+
+  Double_t SBratio=gRandom->Uniform(0,1);
+  Bool_t GetASignal=kFALSE;
+
+  if(fSBRatiobyN || fSBRatiobyT ) {
+    std::map<UInt_t, Double_t>::const_iterator iterN;
+    Double_t ratio=0;
+    if(fCurrentEntryNo==0) {
+      for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
+        ratio+=iterN->second;
+        fSignalBGN[iterN->first]=ratio;
+        LOG(DEBUG) << "--------------Set signal no. " << iterN->first << " weight " << ratio << "." << FairLogger::endl;
+      }
+    }
+    ratio=0;
+    for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
+      ratio=iterN->second;
+      LOG(DEBUG) << "---Check signal no. " << iterN->first << " SBratio " << SBratio << " : ratio " << ratio << FairLogger::endl;
+      if(SBratio <=ratio) {
+        TChain* chain = fSignalTypeList[iterN->first];
+        UInt_t entry = fCurrentEntry[iterN->first];
+        chain->GetEntry(entry);
+        fOutHeader->SetMCEntryNumber(entry);
+        fOutHeader->SetInputFileId(iterN->first);
+        fOutHeader->SetEventTime(GetEventTime());
+        GetASignal=kTRUE;
+        fCurrentEntry[iterN->first]=entry+1;
+        LOG(DEBUG) << "---Get entry No. " << entry << " from signal chain number --- " << iterN->first << " --- " << FairLogger::endl;
+        break;
+      }
+    }
+    if(!GetASignal) {
+      UInt_t entry = fCurrentEntry[0];
+      fBackgroundChain->GetEntry(entry);
+      fOutHeader->SetMCEntryNumber(entry);
+      fOutHeader->SetInputFileId(0); //Background files has always 0 as Id
+      fOutHeader->SetEventTime(GetEventTime());
+      fCurrentEntry[0]=entry+1;
+      LOG(DEBUG) << "---Get entry from background chain  --- " << FairLogger::endl;
+    }
+    
+  }
+
+  fCurrentEntryNo=i;
+  fOutHeader->SetEventTime(GetEventTime());
+  LOG(DEBUG) << "--Event number --- " << fCurrentEntryNo << " with time ----" << GetEventTime() << FairLogger::endl;
+
+  return 0;
+}
+void FairMixedSource::Close()
+{
+}
+void FairMixedSource::Reset()
+{
+}
+
+//_____________________________________________________________________________
+void FairMixedSource::FillEventHeader(FairEventHeader* feh) 
+{
+  feh->SetEventTime    (fOutHeader->GetEventTime());
+  feh->SetMCEntryNumber(fOutHeader->GetMCEntryNumber());
+  feh->SetInputFileId  (fOutHeader->GetInputFileId());
+  feh->SetRunId        (fOutHeader->GetRunId());
+  LOG(DEBUG) << "FairMixedSource::FillEventHeader() Event " << fCurrentEntryNo << " at " << feh->GetEventTime() << " -> Run id = " << fOutHeader->GetRunId() << " event#" << feh->GetMCEntryNumber() << " from file#" << fOutHeader->GetInputFileId() << FairLogger::endl;
+  return;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairMixedSource::CompareBranchList(TFile* fileHandle, TString inputLevel)
+{
+  // fill a set with the original branch structure
+  // This allows to use functions find and erase
+  std::set<TString> branches;
+  std::list<TString>::const_iterator iter;
+  for(iter = fCheckInputBranches[inputLevel]->begin();
+      iter != fCheckInputBranches[inputLevel]->end(); iter++) {
+    branches.insert(*iter);
+  }
+
+  // To do so we have to loop over the branches in the file and to compare
+  // the branches in the file with the information stored in
+  // fCheckInputBranches["InputChain"]. If both lists are equal everything
+  // is okay
+
+  // Get The list of branches from the input file one by one and compare
+  // it to the reference list of branches which is defined for this tree.
+  // If a branch with the same name is found, this branch is removed from
+  // the list. If in the end no branch is left in the list everything is
+  // fine.
+  set<TString>::iterator iter1;
+  TList* list= dynamic_cast <TList*> (fileHandle->Get("BranchList"));
+  if(list) {
+    TObjString* Obj=0;
+    for(Int_t i =0; i< list->GetEntries(); i++) {
+      Obj=dynamic_cast <TObjString*> (list->At(i));
+      iter1=branches.find(Obj->GetString().Data());
+      if (iter1 != branches.end() ) {
+        branches.erase (iter1);
+      } else {
+        // Not found is an error because branch structure is
+        // different. It is impossible to add to tree with a
+        // different branch structure
+        return kFALSE;
+      }
+    }
+  }
+  // If the size of branches is !=0 after removing all branches also in the
+  // reference list, this is also a sign that both branch list are not the
+  // same
+  if (branches.size() != 0 ) {
+    return kFALSE;
+  }
+
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::SetSignalFile(TString name, UInt_t identifier )
+{
+  TFile* SignalInFile = new TFile(name.Data());
+  if (SignalInFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Signal file" << FairLogger::endl;
+  } else {
+    /** Set a signal file of certain type (identifier) if already exist add the file to the chain*/
+    if(fSignalTypeList[identifier]==0) {
+      TChain* chain = new TChain(FairRootManager::GetTreeName(), "/cbmroot");
+      fSignalTypeList[identifier]=chain;
+      FairRootManager::Instance()->SetInChain(chain,identifier);
+      fCurrentEntry[identifier]= 0;
+      fNoOfSignals++;
+      fActualSignalIdentifier= identifier;
+      chain->AddFile(name.Data());
+    } else {
+      TChain* CurrentChain=fSignalTypeList[identifier];
+      CurrentChain->AddFile(name.Data());
+//      TObjArray* fileElements=CurrentChain->GetListOfFiles();
+    }
+
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::AddSignalFile(TString name, UInt_t identifier )
+{
+  SetSignalFile(name, identifier);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TChain* FairMixedSource::GetSignalChainNo(UInt_t i)
+{
+  if(i<<fNoOfSignals) {
+    return fSignalTypeList[i];
+  } else {
+    LOG(INFO) << "Error signal identifier " << i << " does not exist " << FairLogger::endl;
+    return 0;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::SetBackgroundFile(TString name)
+{
+  fCurrentEntry[0]= 0;
+  if (name.IsNull() ) {
+    LOG(INFO) << "No background file defined." << FairLogger::endl;
+  }
+  fRootFile =  new TFile(name);
+  if (fRootFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Background file  " << name.Data() << FairLogger::endl;
+  }
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairMixedSource::AddBackgroundFile(TString name)
+{
+  if (name.IsNull() ) {
+    LOG(INFO) << "No background file defined." << FairLogger::endl;
+  }
+  TFile* BGFile =  new TFile(name);
+  if (BGFile->IsZombie()) {
+    LOG(FATAL) << "Error opening the Background file " << name.Data() << FairLogger::endl;
+  } else {
+    if(fBackgroundChain!=0) {
+      fBackgroundChain->AddFile(name.Data());
+//      TObjArray* fileElements=fBackgroundChain->GetListOfFiles();
+    } else {
+      LOG(FATAL) << "Use SetBackGroundFile first, then add files to background" << FairLogger::endl;
+    }
+
+  }
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairMixedSource::OpenBackgroundChain()
+{
+  // Get the folder structure from file which describes the input tree.
+  // There are two different names possible, so check both.
+  fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmroot"));
+  if(!fCbmroot) {
+    fCbmroot= dynamic_cast <TFolder*> (fRootFile->Get("cbmout"));
+    if(!fCbmroot) {
+      fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
+    } else {
+      fCbmroot->SetName("cbmroot");
+    }
+  }
+
+  // Get The list of branches from the input file and add it to the
+  // actual list of existing branches.
+  // Add this list of branches also to the map of input trees, which
+  // stores the information which branches belong to which input tree.
+  // There is at least one primary input tree, but there can be many
+  // additional friend trees.
+  // This information is needed to add new files to the correct friend
+  // tree. With this information it is also possible to check if the
+  // input files which are added to the input chain all have the same
+  // branch structure. Without this check it is possible to add trees
+  // with a different branch structure but the same tree name. ROOT
+  // probably only checks if the name of the tree is the same.
+
+  TList* list= dynamic_cast <TList*> (fRootFile->Get("BranchList"));
+  TString chainName = "BGInChain";
+  fInputLevel.push_back(chainName);
+  fCheckInputBranches[chainName] = new std::list<TString>;
+  if(list) {
+    TObjString* Obj=0;
+    for(Int_t i =0; i< list->GetEntries(); i++) {
+      Obj=dynamic_cast <TObjString*> (list->At(i));
+      fCheckInputBranches[chainName]->push_back(Obj->GetString().Data());
+     FairRootManager::Instance()->AddBranchToList(Obj->GetString().Data());
+    }
+  }
+
+  gROOT->GetListOfBrowsables()->Add(fCbmroot);
+  fListFolder->Add( fCbmroot );
+  return kTRUE;
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairMixedSource::OpenSignalChain()
+{
+  std::map<UInt_t, TChain*>::const_iterator iter;
+  for(iter = fSignalTypeList.begin(); iter != fSignalTypeList.end(); iter++) {
+    TChain* currentChain=iter->second;
+    // cout << "Signal chain is : " << currentChain->GetName()<< endl;
+    //   currentChain->Dump();
+    TFile* ChainFirstFile = currentChain->GetFile();
+    //cout << "First file in signal chain is : " << ChainFirstFile << endl;
+    // Check if the branchlist is the same as for the first input file.
+    Bool_t isOk = CompareBranchList(ChainFirstFile,"BGInChain");
+    if ( !isOk ) {
+      LOG(FATAL) << "Branch structure of the signal chain is different than the back ground one" << FairLogger::endl;
+    }
+  }
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t   FairMixedSource::ActivateObject(TObject** obj, const char* BrName) {
+  fBackgroundChain->SetBranchStatus(BrName,1);
+  fBackgroundChain->SetBranchAddress(BrName,obj);
+
+  std::map<UInt_t, TChain*>::const_iterator iter;
+  Int_t no=0;
+  for(iter = fSignalTypeList.begin(); iter != fSignalTypeList.end(); iter++) {
+    TChain* currentChain=iter->second;
+    LOG(DEBUG2) << "Set the Branch address for signal file number " << no++ << " and  branch " << BrName << FairLogger::endl;
+    currentChain->SetBranchStatus(BrName,1);
+    currentChain->SetBranchAddress(BrName,obj);
+  }
+
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairMixedSource::ReadBKEvent(UInt_t i)
+{
+  if(0==i) {
+    Int_t totEnt = fBackgroundChain->GetEntries();
+    LOG(INFO) << "The number of entries in background chain is " << totEnt << FairLogger::endl;
+  }
+  fBackgroundChain->GetEntry(i);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairMixedSource::BGWindowWidthNo(UInt_t background, UInt_t Signalid)
+{
+  fSBRatiobyN=kTRUE;
+  if(fSBRatiobyT) {
+    LOG(FATAL) << "Signal rate already set by TIME!!" << FairLogger::endl;
+  }
+  Double_t value=1.0/background;
+  if(background!=0) {
+    fSignalBGN[Signalid]=value;
+  } else {
+    LOG(FATAL) << "Background cannot be Zero when setting the signal rate!!" << FairLogger::endl;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairMixedSource::BGWindowWidthTime(Double_t background, UInt_t Signalid)
+{
+  fSBRatiobyT=kTRUE;
+  if(fSBRatiobyN) {
+    LOG(FATAL) << "Signal rate already set by NUMBER!!" << FairLogger::endl;
+  }
+  if(fEventTimeInMCHeader) {
+    LOG(FATAL) << "You have to Set the Event mean time before using SetSignalRateTime!" << FairLogger::endl;
+  }
+  if(fEventMeanTime==0) {
+    LOG(FATAL) << "Event mean time cannot be zero when using signal rate with time " << FairLogger::endl;
+  }
+  /**convert to number of event by dividing by the mean time */
+  Double_t value=fEventMeanTime/background;
+  if(background!=0) {
+    fSignalBGN[Signalid]=value;
+  } else {
+    LOG(FATAL) << "Background cannot be Zero when setting the signal rate!!" << FairLogger::endl;
+  }
+  
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t  FairMixedSource::CheckMaxEventNo(Int_t EvtEnd)
+{
+  Int_t MaxEventNo=0;
+  if(EvtEnd!=0) {
+    MaxEventNo=EvtEnd;
+  }
+  Int_t localMax=0;
+  Int_t MaxBG=fBackgroundChain->GetEntries();
+  Int_t MaxS=0;
+  Double_t ratio=0.;
+  std::map<UInt_t, Double_t>::const_iterator iterN;
+  for(iterN = fSignalBGN.begin(); iterN != fSignalBGN.end(); iterN++) {
+    TChain* chain = fSignalTypeList[iterN->first];
+    MaxS=chain->GetEntries();
+    LOG(INFO) << "Signal chain  No " << iterN->first << " has  : " << MaxS << " entries " << FairLogger::endl;
+    ratio=iterN->second;
+    if(floor(MaxS/ratio) > MaxBG) {
+      localMax=MaxBG+static_cast<Int_t>(floor(MaxBG*ratio));
+      LOG(WARNING) << "No of Event in Background chain is not enough for all signals in chain  " << iterN->first << FairLogger::endl;
+    } else {
+      localMax=static_cast<Int_t>(floor(MaxS/ratio));
+      LOG(WARNING) << "No of Event in signal chain " << iterN->first << " is not enough, the maximum event number will be reduced to : " << localMax  << FairLogger::endl;
+    }
+    if(MaxEventNo==0 || MaxEventNo > localMax) {
+      MaxEventNo=localMax;
+    }
+  }
+  LOG(INFO) << "Maximum No of Event will be set to : " << MaxEventNo << FairLogger::endl;
+  return MaxEventNo;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairMixedSource::SetEventMeanTime(Double_t mean)
+{
+  fEventMeanTime =mean;
+/*
+  TString form="(1/";
+  form+= mean;
+  form+=")*exp(-x/";
+  form+=mean;
+  form+=")";
+  fTimeProb= new TF1("TimeProb", form.Data(), 0., mean*10);
+*/
+  fTimeProb = new TF1("TimeProb","(1/[0])*exp(-x/[0])", 0., mean*10);
+  fTimeProb->SetParameter(0,mean);
+  fTimeProb->GetRandom();
+  fEventTimeInMCHeader=kFALSE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::SetEventTimeInterval(Double_t min, Double_t max)
+{
+  fEventTimeMin=min;
+  fEventTimeMax=max;
+  fEventMeanTime=(fEventTimeMin+fEventTimeMax)/2;
+  fEventTimeInMCHeader=kFALSE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::SetBeamTime(Double_t beamTime, Double_t gapTime)
+{
+  fBeamTime = beamTime;
+  fGapTime = gapTime;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMixedSource::SetEventTime()
+{
+  LOG(DEBUG) << "Set event time for Entry = "
+	     << fTimeforEntryNo << " , where the current entry is "
+	     << fCurrentEntryNo << " and eventTime is "
+	     << fEventTime << FairLogger::endl;
+  if (fBeamTime < 0){
+	  fEventTime += GetDeltaEventTime();
+  } else {
+	  do {
+		  fEventTime += GetDeltaEventTime();
+	  } while( fmod(fEventTime, fBeamTime + fGapTime) > fBeamTime );
+  }
+  LOG(DEBUG) << "New time = " << fEventTime << FairLogger::endl;
+  fTimeforEntryNo=fCurrentEntryNo;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Double_t FairMixedSource::GetDeltaEventTime()
+{
+  Double_t deltaTime = 0;
+  if (fTimeProb != 0) {
+    deltaTime = fTimeProb->GetRandom();
+    LOG(DEBUG) << "Time set via sampling method : " <<  deltaTime
+	       << FairLogger::endl;
+  } else {
+    deltaTime = gRandom->Uniform(fEventTimeMin, fEventTimeMax);
+    LOG(DEBUG) << "Time set via Uniform Random : "
+	       << deltaTime << FairLogger::endl;
+  }
+  return deltaTime;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Double_t FairMixedSource::GetEventTime()
+{
+ LOG(DEBUG) << "-- Get Event Time --" << FairLogger::endl;
+  if(!fEvtHeaderIsNew && fEvtHeader!=0) {
+    Double_t EvtTime=fEvtHeader->GetEventTime();
+    if( !(EvtTime<0)) {
+      return   EvtTime;
+    }
+  }
+
+  if (fEventTimeInMCHeader && !fMCHeader) {
+    LOG(DEBUG) << "No MCEventHeader, time is set to 0" << FairLogger::endl;
+    return 0;
+  } else if(fEventTimeInMCHeader && fMCHeader) {
+    fEventTime=fMCHeader->GetT();
+    LOG(DEBUG) << "Get event time from MCEventHeader : "
+	       << fEventTime << " ns" << FairLogger::endl;
+    return fEventTime;
+  } else {
+
+    if(fTimeforEntryNo!=fCurrentEntryNo) {
+      SetEventTime();
+    }
+    LOG(DEBUG) << "Calculate event time from user input : " 
+	       << fEventTime << " ns" << FairLogger::endl;
+    return fEventTime;
+  }
+}
+//_____________________________________________________________________________
+
+void FairMixedSource::ReadBranchEvent(const char* BrName)
+{
+    /**fill the object with content if the other branches in this tree entry were already read**/
+    if(fEvtHeader == 0) { return; } //No event header, Reading will start later
+    TChain* chain = fSignalTypeList[fEvtHeader->GetInputFileId()];
+    if(!chain) { return; }
+    chain->FindBranch(BrName)->GetEntry(fEvtHeader->GetMCEntryNumber());
+    return;
+}
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+
+void FairMixedSource::ReadBranchEvent(const char* BrName, Int_t Entry)
+{
+    /**fill the object with content if the other branches in this tree entry were already read**/
+    if(fEvtHeader == 0) { return; } //No event header, Reading will start later
+    TChain* chain = fSignalTypeList[fEvtHeader->GetInputFileId()];
+    if(!chain) { return; }
+    chain->FindBranch(BrName)->GetEntry(Entry);
+    return;
+}
+//_____________________________________________________________________________
+
+ClassImp(FairMixedSource)
diff --git a/base/source/FairMixedSource.h b/base/source/FairMixedSource.h
new file mode 100644
index 0000000..ef3407b
--- /dev/null
+++ b/base/source/FairMixedSource.h
@@ -0,0 +1,228 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//
+//  FairMixedSource.h
+//  FAIRROOT
+//
+//  Created by Mohammad Al-Turany on 08/02/14.
+//
+//
+
+#ifndef __FAIRROOT__FairMixedSource__
+#define __FAIRROOT__FairMixedSource__
+
+#include "FairSource.h"
+#include <list>    
+#include "TChain.h"
+#include "TFile.h"
+#include "TF1.h"
+
+class FairEventHeader;
+class FairFileHeader;
+class FairMCEventHeader;
+class TString;
+class FairLogger;
+class FairRuntimeDb;
+class TFolder;
+
+class FairRootManager;
+
+class FairMixedSource : public FairSource
+{
+public:
+    FairMixedSource(TFile *f, const char* Title="InputRootFile", UInt_t identifier=0);
+    FairMixedSource(const TString* RootFileName, const char* Title="InputRootFile", UInt_t identifier=0);
+    FairMixedSource(const TString RootFileName, const Int_t signalId, const char* Title="InputRootFile", UInt_t identifier=0);
+  //  FairMixedSource(const FairMixedSource& file);
+    virtual ~FairMixedSource();
+    
+    Bool_t              Init();
+    Int_t               ReadEvent(UInt_t i=0);
+    void                Close();
+    void                Reset();
+
+    virtual Source_Type GetSourceType() { return kFILE; }
+
+    virtual void SetParUnpackers() {}
+
+    virtual Bool_t InitUnpackers() { return kTRUE; }
+
+    virtual Bool_t ReInitUnpackers() { return kTRUE; }
+
+    /**Check the maximum event number we can run to*/
+    virtual Int_t  CheckMaxEventNo(Int_t EvtEnd=0);
+    /**Read the tree entry on one branch**/
+    void             ReadBranchEvent(const char* BrName);
+    /** Read specific tree entry on one branch**/
+    void             ReadBranchEvent(const char* BrName, Int_t Entry);
+
+    void                FillEventHeader(FairEventHeader* feh);
+
+    const TFile*        GetRootFile(){return fRootFile;}
+    /** Add a friend file (input) by name)*/
+
+    virtual Bool_t   ActivateObject(TObject** obj, const char* BrName);
+
+    void             ReadBKEvent(UInt_t i=0);
+
+    /**Set the input signal file
+     *@param name :        signal file name
+     *@param identifier :  Unsigned integer which identify the signal file
+     */
+    void                  SetSignalFile(TString name, UInt_t identifier );
+    /**Set the input background file by name*/
+    void                  SetBackgroundFile(TString name);
+    /**Add signal file to input
+     *@param name :        signal file name
+     *@param identifier :  Unsigned integer which identify the signal file to which this signal should be added
+     */
+    void                  AddSignalFile(TString name, UInt_t identifier );
+    void                  AddBackgroundFile(TString name);
+
+    TChain*             GetBGChain() { return  fBackgroundChain;}
+    TChain*             GetSignalChainNo(UInt_t i);
+
+    Bool_t            OpenBackgroundChain();
+    Bool_t            OpenSignalChain();
+
+    /**Set the signal to background ratio in event units
+    *@param background :  Number of background Events for one signal
+    *@param Signalid :    Signal file Id, used when adding (setting) the signal file
+    */
+    void BGWindowWidthNo(UInt_t background, UInt_t Signalid);
+    /**Set the signal to background rate in time units
+    *@param background :  Time of background Events before one signal
+    *@param Signalid :    Signal file Id, used when adding (setting) the signal file
+    */
+    void BGWindowWidthTime(Double_t background, UInt_t Signalid);
+
+    /** Set the min and max limit for event time in ns */
+    void                SetEventTimeInterval(Double_t min, Double_t max);
+    /** Set the mean time for the event in ns */
+    void                SetEventMeanTime(Double_t mean);
+    /** Set the repetition time of the beam when it can interact (beamTime) and when no interaction happen (gapTime). The total repetition time is beamTime + gapTime */
+    void                SetBeamTime(Double_t beamTime, Double_t gapTime);
+    void                SetEventTime();
+    Double_t		GetDeltaEventTime();
+    void                SetFileHeader(FairFileHeader* f) {fFileHeader =f;}
+    Double_t            GetEventTime();
+
+    /**Add ROOT file to input, the file will be chained to already added files*/
+    Bool_t              CompareBranchList(TFile* fileHandle, TString inputLevel);
+    /**Set the input tree when running on PROOF worker*/
+    TObjArray*          GetListOfFolders(){return fListFolder;}
+    TFolder*            GetBranchDescriptionFolder(){return fCbmroot;}
+    UInt_t              GetEntries(){return fNoOfEntries; }
+
+    /**Set the status of the EvtHeader
+     *@param Status:  True: The header was creatged in this session and has to be filled
+              FALSE: We use an existing header from previous data level
+     */
+    void                SetEvtHeaderNew(Bool_t Status) {fEvtHeaderIsNew = Status;}
+    Bool_t              IsEvtHeaderNew() {return fEvtHeaderIsNew;}
+
+private:
+    /**IO manager */
+    FairRootManager*         fRootManager;
+
+    /** Title of input source, could be input, background or signal*/
+    TString                           fInputTitle;
+    /**ROOT file*/
+    TFile*                            fRootFile;
+    /** List of all files added with AddFriend */
+    std::list<TString>                fFriendFileList; //!
+    std::list<TString>                fInputChainList;//!
+    std::map<TString, TChain*>          fFriendTypeList;//!
+    std::map<TString, std::list<TString>* > fCheckInputBranches; //!
+    std::list<TString>                      fInputLevel; //!
+    std::map<TString, std::multimap<TString, TArrayI> > fRunIdInfoAll; //!
+    /** list of folders from all input (and friends) files*/
+    TObjArray                           *fListFolder; //!
+    /** RuntimeDb*/
+    FairRuntimeDb*           fRtdb;
+    /**folder structure of output*/
+    TFolder*                            fCbmout;
+    /**folder structure of input*/
+    TFolder*                            fCbmroot;
+    /***/
+    UInt_t                              fSourceIdentifier;
+    /**No of Entries in this source*/
+    UInt_t                              fNoOfEntries;
+    /**Initialization flag, true if initialized*/
+    Bool_t                              IsInitialized;
+
+    /** MC Event header */
+    FairMCEventHeader*                      fMCHeader; //!
+
+    /**Event Header*/
+    FairEventHeader*                        fEvtHeader; //!
+
+    /**Output Event Header*/
+    FairEventHeader*                        fOutHeader; //!
+
+    /**File Header*/
+    FairFileHeader*                        fFileHeader; //!
+
+    /** This is true if the event time used, came from simulation*/
+    Bool_t                                  fEventTimeInMCHeader; //!
+    /**This flag is true if the event header was created in this session
+    * otherwise it is false which means the header was created in a previous data
+    * level and used here (e.g. in the digi)
+    */
+    Bool_t      fEvtHeaderIsNew; //!
+
+    /** for internal use, to return the same event time for the same entry*/
+    UInt_t                                  fCurrentEntryNo; //!
+    /** for internal use, to return the same event time for the same entry*/
+    UInt_t                                  fTimeforEntryNo; //!
+    /* /\**No of entries in BG Chain*\/ */
+    UInt_t                                  fNoOfBGEntries; //!
+    /* /\**Hold the current entry for each input chain*\/ */
+    std::map<UInt_t, UInt_t>                fCurrentEntry; //! 
+
+    /** min time for one event (ns) */
+    Double_t                                fEventTimeMin;  //!
+    /** max time for one Event (ns) */
+    Double_t                                fEventTimeMax;  //!
+    /** Time of event since th start (ns) */
+    Double_t                                fEventTime;     //!
+    /** Time of particles in beam (ns) */
+    Double_t                                fBeamTime; //!
+    /** Time without particles in beam (gap) (ns) */
+    Double_t                                fGapTime; //!
+    /** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
+    Double_t                                fEventMeanTime; //!
+    /** used to generate random numbers for event time; */
+    TF1*                                    fTimeProb;      //!
+
+    /**holds the SB ratio by number*/
+    std::map<UInt_t, Double_t>              fSignalBGN;//! 
+    /* /\**True for background window in entry units*\/ */
+    Bool_t                                  fSBRatiobyN;  //! 
+    /* /\**True for background window in time units (ns) *\/ */
+    Bool_t                                  fSBRatiobyT;  //!
+
+    /**Actual identifier of the added signals, this is used to identify how many signals are added*/
+    UInt_t                              fActualSignalIdentifier; //!
+    /** Total number of signals added (Types and not files!)*/
+    UInt_t                              fNoOfSignals; //!
+    /** list of chains which has to be created for the different signals*/
+    std::list<TString>*                  fSignalChainList; //!
+    /**Chain containing the background*/
+    TChain*                              fBackgroundChain; //!
+    std::map<UInt_t, TChain*>            fSignalTypeList;//!
+
+    FairMixedSource(const FairMixedSource&);
+    FairMixedSource& operator=(const FairMixedSource&);
+    
+public:
+    ClassDef(FairMixedSource, 0)
+};
+
+
+#endif /* defined(__FAIRROOT__FairMixedSource__) */
diff --git a/base/source/FairOnlineSource.cxx b/base/source/FairOnlineSource.cxx
new file mode 100644
index 0000000..23a00cc
--- /dev/null
+++ b/base/source/FairOnlineSource.cxx
@@ -0,0 +1,61 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairOnlineSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----              Copied from FairSource 01.11.2013 by F.Uhlig         -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#include <iostream>
+
+#include "FairOnlineSource.h"
+#include "FairLogger.h"
+
+FairOnlineSource::FairOnlineSource() : FairSource(), fUnpackers(new TObjArray()) {}
+
+FairOnlineSource::FairOnlineSource(const FairOnlineSource &source)
+    : FairSource(source), fUnpackers(new TObjArray(*(source.GetUnpackers()))) {}
+
+FairOnlineSource::~FairOnlineSource() {
+  fUnpackers->Delete();
+  delete fUnpackers;
+}
+
+Bool_t FairOnlineSource::InitUnpackers() {
+  for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
+    if (!((FairUnpack *)fUnpackers->At(i))->Init()) {
+      return kFALSE;
+    }
+  }
+  return kTRUE;
+}
+
+Bool_t FairOnlineSource::ReInitUnpackers() {
+  for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
+    if (!((FairUnpack *)fUnpackers->At(i))->ReInit()) {
+      return kFALSE;
+    }
+  }
+  return kTRUE;
+}
+
+void FairOnlineSource::SetParUnpackers() {
+    for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
+        ((FairUnpack *)fUnpackers->At(i))->SetParContainers();
+    }
+}
+
+void FairOnlineSource::Reset() {
+  for (Int_t i = 0; i < fUnpackers->GetEntriesFast(); i++) {
+    ((FairUnpack *)fUnpackers->At(i))->Reset();
+  }
+}
+
+ClassImp(FairOnlineSource)
diff --git a/base/source/FairOnlineSource.h b/base/source/FairOnlineSource.h
new file mode 100644
index 0000000..ec6eb7b
--- /dev/null
+++ b/base/source/FairOnlineSource.h
@@ -0,0 +1,57 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairMbsSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----              Copied from FairSource 01.11.2013 by F.Uhlig         -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRONLINESOURCE_H
+#define FAIRONLINESOURCE_H
+
+#include "FairSource.h"
+#include "TObjArray.h"
+
+#include "FairUnpack.h"
+
+
+class FairOnlineSource : public FairSource
+{
+  public:
+    FairOnlineSource();
+    FairOnlineSource(const FairOnlineSource& source);
+    virtual ~FairOnlineSource();
+
+    inline void AddUnpacker(FairUnpack* unpacker) { fUnpackers->Add(unpacker); }
+    inline const TObjArray* GetUnpackers() const { return fUnpackers; }
+
+    virtual Bool_t Init() = 0;
+    virtual Int_t ReadEvent(UInt_t=0) = 0;
+    virtual void Close() = 0;
+
+    virtual void SetParUnpackers();
+
+    virtual Bool_t InitUnpackers();
+
+    virtual Bool_t ReInitUnpackers();
+
+    void Reset();
+
+    virtual Source_Type GetSourceType() { return kONLINE; }
+
+  protected:
+    TObjArray* fUnpackers;
+
+  private:
+    ClassDef(FairOnlineSource, 0)
+};
+
+
+#endif
diff --git a/base/source/FairRemoteSource.cxx b/base/source/FairRemoteSource.cxx
new file mode 100644
index 0000000..c90899b
--- /dev/null
+++ b/base/source/FairRemoteSource.cxx
@@ -0,0 +1,101 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                          FairRemoteSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+#include <unistd.h>
+#include <iostream>
+using namespace std;
+
+#include "ptrevmbsdef.h"          // MBS data definitions
+
+#include "TSocket.h"
+
+#include "MRevBuffer.h"
+#include "FairRemoteSource.h"
+
+
+FairRemoteSource::FairRemoteSource(char* node)
+  : FairMbsSource(),
+    fNode(node),
+    fSocket(NULL),
+    fBuffer(new MRevBuffer(1)),
+    fREvent(NULL)
+{
+}
+
+
+FairRemoteSource::FairRemoteSource(const FairRemoteSource& source)
+  : FairMbsSource(source),
+    fNode(const_cast<char*>(source.GetNode())),
+    fSocket(NULL),
+    fBuffer(new MRevBuffer(1)),
+    fREvent(NULL)
+{
+}
+
+
+FairRemoteSource::~FairRemoteSource()
+{
+  delete fBuffer;
+}
+
+
+Bool_t FairRemoteSource::Init()
+{
+  fBuffer->RevStatus(0);
+  fSocket = fBuffer->RevOpen(fNode, 6003, 0);
+  fBuffer->RevStatus(0);
+  if(! fSocket) {
+    return kFALSE;
+  }
+  return kTRUE;
+}
+
+
+Int_t FairRemoteSource::ReadEvent(UInt_t)
+{
+  usleep(10000);
+  fREvent = fBuffer->RevGet(fSocket, 0, 0);
+  fBuffer->RevStatus(0);
+  if(! fREvent) {
+    return 1;
+  }
+
+  // Decode event header
+  Bool_t result = Unpack(fREvent->GetData(), sizeof(sMbsEv101), -2, -2, -2, -2, -2);
+
+  for(Int_t i = 0; i < fREvent->nSubEvt; i++) {
+    if(Unpack(fREvent->pSubEvt[i], fREvent->subEvtSize[i],
+              fREvent->subEvtType[i], fREvent->subEvtSubType[i],
+              fREvent->subEvtProcId[i], fREvent->subEvtSubCrate[i],
+              fREvent->subEvtControl[i])) {
+      result = kTRUE;
+    }
+  }
+
+  if(! result) {
+    return 2;
+  }
+
+  return 0;
+}
+
+
+void FairRemoteSource::Close()
+{
+  fBuffer->RevClose(fSocket);
+  fBuffer->RevStatus(0);
+}
+
+
+ClassImp(FairRemoteSource)
+
+
diff --git a/base/source/FairRemoteSource.h b/base/source/FairRemoteSource.h
new file mode 100644
index 0000000..067b3d8
--- /dev/null
+++ b/base/source/FairRemoteSource.h
@@ -0,0 +1,51 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                          FairRemoteSource                         -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRREMOTESOURCE_H
+#define FAIRREMOTESOURCE_H
+
+#include "FairMbsSource.h"
+
+
+class TSocket;
+class MRevBuffer;
+class REvent;
+
+
+class FairRemoteSource : public FairMbsSource
+{
+  public:
+    FairRemoteSource(char* node);
+    FairRemoteSource(const FairRemoteSource& source);
+    virtual ~FairRemoteSource();
+
+    virtual Bool_t Init();
+    virtual Int_t ReadEvent(UInt_t=0);
+    virtual void Close();
+
+    inline const char* GetNode() const { return fNode; }
+
+  private:
+    char* fNode;
+    TSocket* fSocket;
+    MRevBuffer* fBuffer;
+    REvent* fREvent;
+
+    FairRemoteSource& operator=(const FairRemoteSource&);
+    
+  public:
+    ClassDef(FairRemoteSource, 0)
+};
+
+
+#endif
diff --git a/base/source/FairSource.cxx b/base/source/FairSource.cxx
new file mode 100644
index 0000000..66fdb37
--- /dev/null
+++ b/base/source/FairSource.cxx
@@ -0,0 +1,47 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairSource                            -----
+// -----                    Created 01.11.2013 by F. Uhlig                 -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#include <iostream>
+
+#include "FairSource.h"
+#include "FairEventHeader.h"
+
+
+FairSource::FairSource()
+  : TObject()
+  , fRunId(0)
+{
+}
+
+
+FairSource::FairSource(const FairSource& source)
+  : TObject(source)
+  , fRunId(source.fRunId)
+{
+}
+
+
+FairSource::~FairSource()
+{
+}
+
+void FairSource::FillEventHeader(FairEventHeader* eh)
+{
+  if(eh)
+  {
+    eh->SetRunId(fRunId);
+  }
+}
+
+ClassImp(FairSource)
diff --git a/base/source/FairSource.h b/base/source/FairSource.h
new file mode 100644
index 0000000..37a2f05
--- /dev/null
+++ b/base/source/FairSource.h
@@ -0,0 +1,67 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairSource                            -----
+// -----                    Created 01.11.2013 by F. Uhlig                 -----
+// -----                                                                   -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRSOURCE_H
+#define FAIRSOURCE_H
+
+#include "TObject.h"
+
+#include <iostream>
+
+class FairEventHeader;
+
+enum Source_Type {kONLINE, kFILE, kBMNFILE};
+
+class FairSource : public TObject
+{
+  public:
+    FairSource();
+    FairSource(const FairSource& source);
+    virtual ~FairSource();
+
+    virtual Bool_t Init() = 0;
+    virtual Int_t ReadEvent(UInt_t=0) = 0;
+    virtual void Close() = 0;
+
+    virtual void Reset() = 0;
+
+    virtual Bool_t   ActivateObject(TObject**, const char*)  { return kFALSE; }
+
+    virtual Source_Type GetSourceType() = 0;
+
+    virtual void SetParUnpackers() = 0;
+
+    virtual Bool_t InitUnpackers() = 0;
+
+    virtual Bool_t ReInitUnpackers() = 0;
+
+    /**Check the maximum event number we can run to*/
+    virtual Int_t  CheckMaxEventNo(Int_t=0) {return -1;}
+    /**Read the tree entry on one branch**/
+    virtual void   ReadBranchEvent(const char*) {return;}
+    virtual void   ReadBranchEvent(const char*, Int_t) {return;}
+    virtual void FillEventHeader(FairEventHeader* feh);
+
+    void SetRunId(Int_t runId) { fRunId = runId; }
+    Int_t GetRunId() const     { return fRunId;  }
+
+  protected:
+    Int_t fRunId;
+
+  public:
+    ClassDef(FairSource, 2)
+};
+
+
+#endif
diff --git a/base/source/FairUnpack.cxx b/base/source/FairUnpack.cxx
new file mode 100644
index 0000000..78deb51
--- /dev/null
+++ b/base/source/FairUnpack.cxx
@@ -0,0 +1,34 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairUnpack                            -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+
+#include "FairUnpack.h"
+
+
+FairUnpack::FairUnpack(Short_t type, Short_t subType,
+                       Short_t procId, Short_t subCrate, Short_t control)
+  : TObject(),
+    fType(type),
+    fSubType(subType),
+    fProcId(procId),
+    fSubCrate(subCrate),
+    fControl(control)
+{
+}
+
+
+FairUnpack::~FairUnpack()
+{
+}
+
+
+ClassImp(FairUnpack)
diff --git a/base/source/FairUnpack.h b/base/source/FairUnpack.h
new file mode 100644
index 0000000..e4c14f4
--- /dev/null
+++ b/base/source/FairUnpack.h
@@ -0,0 +1,58 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -----------------------------------------------------------------------------
+// -----                                                                   -----
+// -----                             FairUnpack                            -----
+// -----                    Created 12.04.2013 by D.Kresan                 -----
+// -----------------------------------------------------------------------------
+
+#ifndef FAIRUNPACK_H
+#define FAIRUNPACK_H
+
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TObject.h"
+
+
+class FairUnpack : public TObject
+{
+  public:
+    FairUnpack(Short_t type, Short_t subType,
+               Short_t procId, Short_t subCrate, Short_t control);
+    virtual ~FairUnpack();
+
+    virtual Bool_t Init() = 0;
+    virtual Bool_t ReInit() { return kTRUE; }
+    virtual Bool_t DoUnpack(Int_t* data, Int_t size) = 0;
+    virtual void   Reset() = 0;
+    virtual void   SetParContainers() {  };
+
+    inline Short_t GetType()    const { return fType;     }
+    inline Short_t GetSubType() const { return fSubType;  }
+    inline Short_t GetProcId()  const { return fProcId;   }
+    inline Short_t GetSubCrate() const { return fSubCrate; }
+    inline Short_t GetControl()  const { return fControl;  }
+
+  private:
+    Short_t fType;
+    Short_t fSubType;
+    Short_t fProcId;
+    Short_t fSubCrate;
+    Short_t fControl;
+
+  protected:
+    virtual void Register() = 0;
+
+  public:
+    ClassDef(FairUnpack, 0)
+};
+
+
+#endif
+
+
+
diff --git a/base/source/MRevBuffer.cxx b/base/source/MRevBuffer.cxx
new file mode 100644
index 0000000..07ae532
--- /dev/null
+++ b/base/source/MRevBuffer.cxx
@@ -0,0 +1,975 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//////////////////////////////////////////////////////////////////////
+// Copyright:
+//   GSI, Gesellschaft fuer Schwerionenforschung mbH
+//   Planckstr. 1
+//   D-64291 Darmstadt
+//   Germany
+// created 16. 2.1999 by Horst Goeringer
+//////////////////////////////////////////////////////////////////////
+// MRevBuffer.cc
+//   ROOT client package for multithreaded remote event server (MBS)
+//////////////////////////////////////////////////////////////////////
+// 15. 3.1999, H.G.: RecvRaw replaced by original recv calls
+// 26. 7.1999, H.G.: accept dummy buffers (no events from DAQ)
+// 20. 8.1999, H.G.: MRevBuffer::RevGetI added
+//  3. 3.2000, H.G.: change default port no.: 6013 -> 6003
+//  6. 3.2000, H.G.: new member function RevStatus
+// 19.11.2001, H.G.: increase data buffer dynamically
+//////////////////////////////////////////////////////////////////////
+
+#include "MRevBuffer.h"            // class definition
+
+#include "Riosfwd.h"                    // for ostream
+#include "TSocket.h"                    // for TSocket, etc
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+#include <signal.h>                     // IWYU pragma: keep
+#include <unistd.h>                     // IWYU pragma: keep
+#include <time.h>                     // IWYU pragma: keep
+#include <netinet/in.h>                     // IWYU pragma: keep
+
+#ifdef Linux
+#include <socket.h>                     // IWYU pragma: keep
+#include <select.h>                     // IWYU pragma: keep
+#else                             // AIX
+#include <strings.h>                     // IWYU pragma: keep
+#include <sys/socket.h>                     // IWYU pragma: keep
+#include <sys/select.h>                     // IWYU pragma: keep
+#endif
+
+#include "ptrevcomm.h"            // communication structure
+#include "ptrevmbsdef.h"          // MBS data definitions
+
+// IWYU pragma: no_include <stdio.h>
+// IWYU pragma: no_include <sys/_endian.h>
+// IWYU pragma: no_include <sys/signal.h>
+
+#include "FairLogger.h"
+
+using namespace std;
+
+ClassImp(MRevBuffer)
+ClassImp(REvent)
+
+extern "C"
+{
+  long swaplw( int*, int, int);          // swap data
+  void exitCli(int);                     // handle CTL C
+  int rclose(int*, int);                 // close connection to server
+}
+
+#ifdef Linux
+struct timeval {
+  long tv_sec;
+  long tv_usec;
+};
+#endif
+
+int iTimeOut;        // needed in exitCli to handle CTL C
+int imySig = 0;      // needed in exitCli to handle CTL C
+int iOutMode = 0;    // needed in exitCli to handle CTL C
+
+MRevBuffer::MRevBuffer(Int_t iMode)
+  : TObject(),
+    pTSocket(NULL),
+    iSocket(0),
+    iBufNo1(0),
+    iBufNo2(0),
+    iDebug(iMode),
+    iSwap(0),
+    iStatus(1),
+    iBufSizeAlloc(512000),
+    iBufSize(0),
+    iBufNo(0),
+    iFragBegin(0),
+    iFragConc(0),
+    iFragBeginIgn(0),
+    iFragEndIgn(0),
+    iHeadPar(0),
+    iEvtMax(0),
+    iEvtNo(0),
+    iEvtRel(0),
+    iEvtBuf(0),
+    iEvtPar(0),
+    piBuf(new int [iBufSizeAlloc/sizeof(int)+1]),
+    piNextEvt(NULL),
+    pEvt(new REvent())
+{
+//  iStatus = 1;                         // server not yet connected
+  /*
+    iSwap = 0;
+    iSocket = 0;
+    iEvtRel = 0;
+    iEvtPar = 0;
+    iBufSize = 0;
+  */
+
+  signal(SIGINT, exitCli);                 // from now catch CTL C
+
+//  iDebug = iMode;
+  iOutMode = iMode;
+  if (iDebug == 1) {
+    LOG(DEBUG) <<  "-I- client runs in debug mode (1)" << FairLogger::endl;
+  } else if (iDebug == 2)
+    LOG(DEBUG) <<  "-I- client shows buffer numbers and select/receive (mode 2)"
+         << FairLogger::endl;
+  else if (iDebug == 3) {
+    LOG(DEBUG) <<  "-I- client shows buffer numbers (mode 3)" << FairLogger::endl;
+  } else if (iDebug == 5) {
+    LOG(DEBUG) <<  "-I- client shows event parameters (mode 5)" << FairLogger::endl;
+  }
+
+  if (iDebug == 1) {
+    LOG(DEBUG) <<  "    check ENDIAN, ";
+#ifdef _AIX
+    LOG(DEBUG) <<  " should be BIG_ENDIAN: ";
+#endif
+#ifdef Linux
+    LOG(DEBUG) <<  " should be LITTLE_ENDIAN: ";
+#endif
+
+#ifdef BIG__ENDIAN
+    LOG(DEBUG) <<  " BIG_ENDIAN" << FairLogger::endl;
+#else
+    LOG(DEBUG) <<  " LITTLE_ENDIAN" << FairLogger::endl;
+#endif
+  }
+
+  //  iBufSizeAlloc = 16384;
+  //  piBuf = new int [iBufSizeAlloc/sizeof(int)+1]; // 16k buffer + len
+  if (iDebug == 1)
+    LOG(DEBUG) <<  "-D- buffer allocated (" << iBufSizeAlloc+sizeof(int)
+         << " byte)" << FairLogger::endl;
+
+  //  REvent* pev = new REvent();    // create event (once)
+  //  pEvt = pev;                    // keep pointer in class MRevBuffer
+
+  // LOG(INFO) <<  "    MRevBuffer() executed" << FairLogger::endl;
+
+}  // constructor
+
+MRevBuffer::~MRevBuffer()
+{
+  // LOG(INFO) <<  "    ~MRevBuffer() ..." << FairLogger::endl;
+  delete [] piBuf;
+  piNextEvt = 0;
+  pEvt->~REvent();
+  // LOG(INFO) <<  "    ~MRevBuffer() executed" << FairLogger::endl;
+
+} // destructor
+
+TSocket* MRevBuffer::RevOpen ( char* pNode, Int_t iPort, Int_t iEvent)
+{
+  if (iEvent < 0) {
+    LOG(INFO) <<  "-E- number of requested events (" << iEvent
+         << ") invalid" << FairLogger::endl;
+    return(0);
+  }
+  if (iEvent == 0) {
+    iEvent = 2000000000;           // nearly unlimited
+    LOG(INFO) <<  "-I- unlimited no. of MBS events requested - break with 'CTL C'"
+         << FairLogger::endl;
+  }
+
+  if (iPort == 6001) {
+    LOG(INFO) <<  "-E- old event server (port no. 6001) running on DAQ frontend not yet supported"
+         << FairLogger::endl;
+    LOG(INFO) <<  "    use stream server (port no. 6002) and remote event server (port no. 6003)"
+         << FairLogger::endl;
+    return(0);
+  }
+  if (iPort == 0) { iPort = 6003; } // default MBS remote event server
+
+  iEvtMax = iEvent;
+  iEvtNo = 0;
+  iBufNo = 0;
+  iBufNo1 = 0;
+  iBufNo2 = 0;
+  iFragConc = 0;
+  iFragBegin = 0;
+  iFragBeginIgn = 0;
+  iFragEndIgn = 0;
+
+  if (!iSocket) {
+    iEvtNo = -1;            // initialization (info buffer) required
+    LOG(INFO) <<  "-I- open connection to server " << pNode
+         << ":" << iPort << FairLogger::endl;
+
+    pTSocket = new TSocket(pNode, iPort);
+    if ( !pTSocket->IsValid() ) {
+      LOG(INFO) <<  "-E- open connection to server " << pNode
+           << " failed" << FairLogger::endl;
+      return(0);
+    }
+    LOG(INFO) <<  "    connection to server " << pNode
+         << ":" << iPort << " okay" << FairLogger::endl;
+
+    iSocket = pTSocket->GetDescriptor();
+    imySig = iSocket;
+    if (iDebug == 1) {
+      LOG(DEBUG) <<  "    socket " << iSocket << FairLogger::endl;
+    }
+
+  } else if (iDebug == 1) {
+    LOG(DEBUG) <<  "-D- socket " << iSocket << FairLogger::endl;
+  }
+
+  iStatus = 2;                                   // server connected
+  return(pTSocket);
+
+} // RevOpen
+
+Int_t* MRevBuffer::RevGetI(TSocket* pSocket, Int_t iFlush)
+{
+  Int_t* piEvent;
+  REvent* pEvent;
+
+  pEvent = RevGet(pSocket, iFlush, 0);
+  if (pEvent) { piEvent = piNextEvt; }
+  else { piEvent = 0; }
+  return piEvent;
+
+} // RevGetI
+
+REvent* MRevBuffer::RevGet(TSocket* pSocket, Int_t iFlush, Int_t)
+{
+  Int_t iint = sizeof(int);
+  Int_t ii;
+  Int_t ilen, iselen, iselen1, ielen, inew = 0;
+
+  Short_t* pshort;
+
+  Char_t cMsg[128] = "";
+  Char_t* pcBuf;
+  Int_t iSize, iRC;
+
+  Int_t iError = 0;
+  Int_t iRetry;
+  Int_t iRetryMax = 1000;
+  Int_t iRetryFirst;
+  Int_t iRetryRecv = 0;         // count retries of recv call
+  Int_t iRetryRecvLim = 1;      // max. no. of succeeding retries
+
+  Int_t* piComm;
+  srevComm sComm;
+  Int_t iCommSize = sizeof(sComm);      // size comm. buffer (byte)
+
+  Int_t* piInfo;
+  //srevInfo sInfo = {.iSize=0, .iMode=1, .iHeadPar=0 , .iTimeOut=0 };
+  /** To support C++98  we have to put the initializers in the right order without the names*/
+  srevInfo sInfo = {0, 1, 0 ,0 };
+  Int_t iInfoSize = sizeof(sInfo);      // size info buffer (byte)
+
+//    Int_t iHeadPar = 12;         // no. of params in MBS buffer header
+  iHeadPar = 12;         // no. of params in MBS buffer header
+  Int_t iBufNoServ;                   // buffer no. sent from server
+  short* psNextEvt;
+  Int_t iHead[2];
+
+  sMbsEv101 sEvtHead, *pEvtHead;                // header event 10.1
+  pEvtHead = &sEvtHead;
+  sMbsSev101 sSEvtHead, *pSEvtHead;                // header event 10.1
+  pSEvtHead = &sSEvtHead;
+  sMbsBufFrag sFrag, *pFrag;                  // fragmented event flags
+  pFrag = &sFrag;
+
+  if (iEvtNo >= iEvtMax) { goto gEndGet; }
+
+  piComm = &(sComm.iSize);               // communication buffer
+  sComm.iSize = htonl(iCommSize-iint);   // size of data following
+  sComm.iMode = htonl(1);                // required: get events
+  sComm.iIdent = 1;                      // required: tell endian type
+  sComm.iBufRequ = htonl(1);             // send one buffer
+
+  // initialize communication with server
+  if (iEvtNo == -1) {        // initialize communication with server
+    if (iDebug == 1)
+      LOG(DEBUG) <<  "-D- commbuf (data size " << ntohl(sComm.iSize)
+           << " byte): mode(1) " << ntohl(sComm.iMode)
+           << ", request " <<  ntohl(sComm.iBufRequ)
+           << " event buffer(s)" << FairLogger::endl;
+
+    // request event buffer from server
+    ilen = pSocket->SendRaw(piComm, iCommSize, kDefault);
+    if (ilen < 0) {
+      LOG(INFO) <<  "-E- sending request for events to server, rc = "
+           << ilen << FairLogger::endl;
+      iError = 1;
+      goto gEndGet;
+    }
+
+    if (iDebug == 1)
+      LOG(DEBUG) <<  "    communication buffer sent (request info buffer) "
+           << FairLogger::endl;
+
+    // receive info buffer from server
+    piInfo = &(sInfo.iSize);
+    ilen = pSocket->RecvRaw(piInfo, iInfoSize, kDefault);
+    if (ilen < 0) {
+      LOG(INFO) <<  "-E- receiving info buffer from server, rc = "
+           << ilen << FairLogger::endl;
+      iError = 1;
+      goto gEndGet;
+    }
+
+    iHeadPar = ntohl(sInfo.iHeadPar);
+    iTimeOut = ntohl(sInfo.iTimeOut);
+    if (iDebug == 1) {
+      LOG(DEBUG) <<  "-D- info buffer received:" << FairLogger::endl;
+      LOG(DEBUG) <<  "    size data " << ntohl(sInfo.iSize)
+           << ", mode (1) " << ntohl(sInfo.iMode)
+           << ", header parms " << iHeadPar
+           << ", timeout " << iTimeOut << FairLogger::endl;
+    }
+
+    if ( (ntohl(sInfo.iMode) != 1) ||
+         ( static_cast<int>(ntohl(sInfo.iSize)) != iInfoSize-iint) ) {
+      LOG(INFO) <<  "-E- invalid info buffer received: " << FairLogger::endl;
+      LOG(INFO) <<  "    size data ( " << iInfoSize-iint
+           << ") "  << ntohl(sInfo.iSize)
+           << ", mode (1) " << ntohl(sInfo.iMode)
+           << ", header parms " << iHeadPar
+           << ", timeout " << iTimeOut << FairLogger::endl;
+      iError = 1;
+      goto gEndGet;
+    }
+
+    iEvtNo = 0;                                // initilization done
+    inew = 1;                                  // request new buffer
+
+  } // (iEvtNo == -1)
+  else {
+    if (iFlush) {
+      inew = 1;                            // request new buffer
+      if (iDebug == 1) {
+        LOG(DEBUG) <<  "-D- skip current buffer" << FairLogger::endl;
+      }
+    } else {
+      if (iEvtNo >= 0) {
+        // refresh some buffer infos not stored in class data
+        pFrag = reinterpret_cast<sMbsBufFrag*>(&piBuf[3]);
+
+        // check if new buffer needed
+        ii = 0;                          // count buffer header
+        if (pFrag->cBuf_fragBegin) { ii++; }
+        if (pFrag->cBuf_fragEnd) { ii++; }
+
+        if (iEvtRel+ii >= iEvtBuf) {
+          if (iDebug == 1) {
+            LOG(DEBUG) <<  "-D- request new buffer" << FairLogger::endl;
+          }
+          inew = 1;
+          if (iDebug == -1) {
+            piNextEvt += iEvtPar;         // skip previous event
+            LOG(DEBUG) <<  "-D- next 40 2byte-words of buffer:" << FairLogger::endl;
+            psNextEvt = reinterpret_cast<short*>(piNextEvt);
+            for (Int_t iii=0; iii<40; iii++) {
+              LOG(DEBUG) <<  "    " << iii+1 << ": " << psNextEvt[iii]
+                   << FairLogger::endl;
+            }
+          }
+        } else { inew = 0; }
+
+      } // (iEvtNo > 0)
+    } // (!iFlush)
+  } // (iEvtNo != -1)
+
+  // request new buffer
+  if (inew) {
+    iEvtRel = 0;
+    iRetry = 0;
+    iRetryFirst = 1;
+    if (imySig == -1) {
+      sComm.iBufRequ = htonl(0);  // signal finish to server
+    }
+
+    // request next buffer or finish
+    ilen = pSocket->SendRaw(piComm, iCommSize, kDefault);
+    if (ilen < 0) {
+      LOG(INFO) <<  "-E- sending request for buffer " << iBufNo+1
+           << " to server, rc = " << ilen << FairLogger::endl;
+      iError = 1;
+      goto gEndGet;
+    }
+
+    if (imySig == -1) { goto gEndGet; }
+
+    if (iDebug == 1)
+      LOG(DEBUG) <<  "-D- communication buffer sent (request next buffer) "
+           << FairLogger::endl;
+
+gRetryLen:
+    // get size of data following
+    piBuf[0] = -1;                         // enables receive check
+    iSize = iint;
+    pcBuf = reinterpret_cast<char*>(piBuf);
+    while(iSize > 0) {
+      if ( (imySig == -1) && (iDebug) ) {
+        LOG(DEBUG) <<  "    CTL C detected (before recv len)" << FairLogger::endl;
+      }
+gNextRecvL:
+      iRC = recv(iSocket, pcBuf, iSize, 0);
+      if (iRC < 0) {
+        if (imySig == -1) {
+          if (iDebug) {
+            sprintf(cMsg,
+                    "\n-E- receiving data length from server");
+            perror(cMsg);
+            LOG(DEBUG) <<  "    CTL C detected (during recv len)"
+                 << FairLogger::endl;
+          }
+          goto gNextRecvL;
+        } else {                                 // a real problem
+          sprintf(cMsg, "\n-E- receiving data length from server");
+          perror(cMsg);
+          if (iDebug) { LOG(DEBUG) <<  "    retry" << FairLogger::endl; }
+
+          iRetryRecv++;      // count no. of retries to limit them
+          if (iRetryRecv > iRetryRecvLim) { // avoid infinite loop
+            iError = 1;
+            goto gEndGet;
+          } else { goto gNextRecvL; }
+        }
+      }
+      if ( iRC == 0 ) {
+        if ( (iDebug == 2) || (iDebug == 3) ) {
+          LOG(DEBUG) <<  FairLogger::endl;
+        }
+        LOG(INFO) <<  "-E- receiving data length: connection closed by server"
+             << FairLogger::endl;
+        iError = 1;
+        goto gEndGet;
+      }
+
+      iRetryRecv = 0;
+      iSize -= iRC;
+      pcBuf += iRC;
+
+    } /* while(iSize > 0) */
+
+    if (iDebug == 2) {
+      printf("Rl:");
+      fflush(stdout);
+    }
+
+    if ( (imySig == -1) && (iDebug) ) {
+      LOG(DEBUG) <<  "    CTL C detected (after recv len)" << FairLogger::endl;
+    }
+
+    iBufSize = ntohl(piBuf[0]);
+    if (iDebug == 1) {
+      LOG(DEBUG) <<  "    data size received: " << iBufSize << FairLogger::endl;
+    }
+
+    if (iBufSize <= 0) {
+      if (iBufSize == 0) {
+        if (iDebug) {
+          LOG(DEBUG) <<  FairLogger::endl;
+        }
+        LOG(INFO) <<  "-W- server closed connection" << FairLogger::endl;
+        LOG(INFO) <<  "    " << iEvtNo << " of " << iEvtMax
+             << " events received" << FairLogger::endl;
+        iError = 1;
+        goto gEndGet;
+      }
+
+      if (iBufSize == -1) {
+        if (iRetryFirst) {
+          LOG(INFO) <<  FairLogger::endl << "-E- no data length received: ";
+          iRetryFirst = 0;
+        }
+        iRetry++;
+        if (iRetry > iRetryMax) {
+          LOG(INFO) <<  iRetryMax << "times" << FairLogger::endl;
+          iError = 1;
+          goto gEndGet;
+        }
+        goto gRetryLen;
+      } else {
+        LOG(INFO) <<  FairLogger::endl << "-E- invalid data length received: "
+             << iBufSize << FairLogger::endl;
+        iError = 1;
+      }
+
+      goto gEndGet;
+    }
+    if (iRetry) {
+      LOG(INFO) <<  iRetry << "times" << FairLogger::endl;
+    }
+
+    // increase data buffer, if necessary
+    if (iBufSize+iint > iBufSizeAlloc) {
+      delete [] piBuf;
+      iBufSizeAlloc = iBufSize+iint;
+      // new total buffer size (including length field)
+      piBuf = new int [iBufSizeAlloc/iint];
+      piBuf[0] = iBufSize;
+      // keep sent buffer size (without length field)
+      if (iDebug == 1)
+        LOG(DEBUG) <<  "-I- total buffer increased to "
+             << iBufSizeAlloc << " byte" << FairLogger::endl;
+    }
+
+    // get event buffer without length field
+    piBuf[1] = -1;                         // enables receive check
+    iSize = iBufSize;
+    pcBuf = reinterpret_cast<char*>(&(piBuf[1]));
+    while(iSize > 0) {
+      if ( (imySig == -1) && (iDebug) ) {
+        LOG(DEBUG) <<  "    CTL C detected (before recv data)" << FairLogger::endl;
+      }
+gNextRecvD:
+      iRC = recv(iSocket, pcBuf, iSize, 0);
+      if (iRC < 0) {
+        if (imySig == -1) {
+          if (iDebug) {
+            sprintf(cMsg, "\n-E- receiving data from server");
+            perror(cMsg);
+            LOG(DEBUG) <<  "    CTL C detected (during recv data)"
+                 << FairLogger::endl;
+          }
+          goto gNextRecvD;
+        } else {                                 // a real problem
+          sprintf(cMsg, "\n-E- receiving data from server");
+          perror(cMsg);
+
+          iRetryRecv++;      // count no. of retries to limit them
+          if (iRetryRecv > iRetryRecvLim) { // avoid infinite loop
+            iError = 1;
+            goto gEndGet;
+          } else { goto gNextRecvD; }
+        }
+      }
+      if ( iRC == 0 ) {
+        if ( (iDebug == 2) || (iDebug == 3) ) {
+          LOG(DEBUG) <<  FairLogger::endl;
+        }
+        LOG(INFO) <<  "-E- receiving data: connection closed by server"
+             << FairLogger::endl;
+        iError = 1;
+        goto gEndGet;
+      }
+
+      iRetryRecv = 0;
+      iSize -= iRC;
+      pcBuf += iRC;
+
+    } /* while(iSize > 0) */
+
+    if (iDebug == 2) {
+      printf("Rd:");
+      fflush(stdout);
+    }
+
+    if (imySig == -1) {
+      if (iDebug) {
+        LOG(DEBUG) <<  "    CTL C detected (after recv data)" << FairLogger::endl;
+      }
+      goto gEndGet;
+    }
+
+    // test for dummy buffer (no DAQ events available)
+    if ( iBufSize == (sizeof(sptrevDummy)-sizeof(int)) ) {
+      iBufNoServ = ntohl(piBuf[1]);
+      iEvtBuf = ntohl(piBuf[2]);
+      if (iEvtBuf == 0) {
+        if (iDebug == 1)
+          printf("    dummy buffer no. %d, %d events\n",
+                 iBufNoServ, iEvtBuf);
+        if (iDebug == 3) { LOG(INFO) <<  FairLogger::endl; }
+        LOG(DEBUG) <<  "*** connection to remote event server okay, but currently no DAQ events ("
+             << iBufNoServ << ")" << FairLogger::endl;
+        iStatus = 3;
+        goto gRetryLen;
+      } else {
+        LOG(INFO) <<  "-E- invalid event number in dummy buffer no. "
+             << iBufNoServ << ": "
+             << iEvtBuf << " (expected: 0)" << FairLogger::endl;
+        iError = 1;
+        goto gEndGet;
+      }
+    }
+
+    if (!iSwap) {
+      if (piBuf[9] != 1) { iSwap = 1; }
+    }
+
+//  Long_t lRC;
+
+    /* swap MBS buffer */
+    if (iSwap) {
+//      lRC  = swaplw( &piBuf[1], iBufSize/iint, 0);
+      swaplw( &piBuf[1], iBufSize/iint, 0);
+      if ( (iBufNo == 0) && (iDebug) ) {
+        LOG(DEBUG) <<  "    Event data swapped" << FairLogger::endl;
+      }
+    }
+
+    iBufNo++;
+    iBufNoServ = piBuf[4];
+    iEvtBuf = piBuf[5];           // no. of events in current buffer
+
+    if (iEvtNo == 0) {
+      iBufNo = 1;                          // restart counting
+      iBufNo1 = iBufNoServ;                // keep first buffer no.
+      iFragBegin = 0;
+      iFragBeginIgn = 0;
+      iFragEndIgn = 0;
+      iFragConc = 0;
+    }
+    iBufNo2 = iBufNoServ;                   // keep last buffer no.
+
+    if (iDebug >= 2) {
+      printf("%d:", iBufNoServ);
+      fflush(stdout);
+    }
+
+    pFrag = reinterpret_cast<sMbsBufFrag*>(&piBuf[3]);
+    if (iDebug == 1) {
+      LOG(DEBUG) <<  FairLogger::endl << "buffer " << iBufNo
+           << " (" << iBufNoServ << "): "
+           << " size "
+           << iBufSize << " byte" << FairLogger::endl;
+      if (pFrag->cBuf_fragBegin) {
+        LOG(DEBUG) <<  "    last event fragment" << FairLogger::endl;
+      }
+      if (pFrag->cBuf_fragEnd) {
+        LOG(DEBUG) <<  "    first event fragment" << FairLogger::endl;
+      }
+      LOG(DEBUG) <<  "    buffer contains " << iEvtBuf << " elements"
+           << FairLogger::endl;
+    }
+
+    if (pFrag->cBuf_fragEnd) {
+      iFragEndIgn++;
+      if ( (iEvtNo > 0) && (iFragBegin) ) {
+        iFragConc++;
+      }
+    }
+
+    if (pFrag->cBuf_fragBegin) {
+      iFragBegin = 1;                // keep info for next buffer
+      iFragBeginIgn++;
+    }
+
+    if (iDebug == -1) {
+      LOG(DEBUG) <<  "-D- first 50 2byte-words of buffer:" << FairLogger::endl;
+      psNextEvt = reinterpret_cast<short*>(&piBuf[1]);
+      for (Int_t iii=0; iii<50; iii++) {
+        LOG(DEBUG) <<  "    " << iii+1 << ": " << psNextEvt[iii] << FairLogger::endl;
+      }
+    }
+
+    iEvtRel = 1;                      // first event in buffer
+    piNextEvt = piBuf + iHeadPar+1;   // ptr first element in buffer
+    iEvtPar = piNextEvt[0]/2 + 2;     // no. of parameters new event
+
+    if (pFrag->cBuf_fragEnd) {
+      piNextEvt += iEvtPar;          // skip fragment end
+      iEvtPar = piNextEvt[0]/2 + 2;  // no. of parameters new event
+    }
+
+  } // new buffer
+  else {
+    iEvtRel++;                        // event no. in buffer
+    piNextEvt += iEvtPar;             // skip previous event
+    iEvtPar = piNextEvt[0]/2 + 2;     // no. of parameters new event
+
+    // also if starting with current buffer: keep first buffer no.
+    if (iEvtNo == 0) {
+      iBufNo = 1;                          // restart counting
+      iBufNoServ = piBuf[4];
+      iBufNo1 = iBufNoServ;
+
+      iFragBegin = 0;
+      iFragBeginIgn = 0;
+      iFragEndIgn = 0;
+      iFragConc = 0;
+      pFrag = reinterpret_cast<sMbsBufFrag*>(&piBuf[3]);
+      if (pFrag->cBuf_fragBegin) {
+        iFragBegin = 1;                // keep info for next buffer
+        iFragBeginIgn++;
+      }
+      if (pFrag->cBuf_fragEnd) { iFragEndIgn++; }
+
+    } // (iEvtNo == 0)
+  } // continue with current buffer
+
+  iEvtNo++;                            // total event no.
+  psNextEvt = reinterpret_cast<short*>(piNextEvt);
+  pEvtHead = reinterpret_cast<sMbsEv101*>(piNextEvt);
+  ielen = pEvtHead->iMbsEv101_dlen;
+  pSEvtHead = reinterpret_cast<sMbsSev101*>(&piNextEvt[4]);
+  pshort = reinterpret_cast<short*>(pSEvtHead);
+
+
+
+  pEvt->nSubEvt = 0;
+
+
+
+  if ( (iDebug == 1) || (iDebug == 5) ) {
+    iselen1 = pSEvtHead->iMbsSev101_dlen;
+
+
+    pEvt->nSubEvt += 1;
+    pEvt->subEvtSize[0] = pSEvtHead->iMbsSev101_dlen/2 - 1;
+    pEvt->subEvtType[0] = pSEvtHead->sMbsSev101_type;
+    pEvt->subEvtSubType[0] = pSEvtHead->sMbsSev101_subtype;
+    pEvt->subEvtProcId[0] = pSEvtHead->sMbsSev101_procid;
+    pEvt->subEvtSubCrate[0] = pSEvtHead->cMbsSev101_subcrate;
+    pEvt->subEvtControl[0] = pSEvtHead->cMbsSev101_control;
+    pEvt->pSubEvt[0] = reinterpret_cast<Int_t*>(&pshort[6]);
+
+/*
+    LOG(DEBUG) <<  "    evt " << iEvtNo << " (" << piNextEvt[3]
+         << "), len " << pEvtHead->iMbsEv101_dlen
+         << ", type " << pEvtHead->sMbsEv101_type
+         << "." << pEvtHead->sMbsEv101_subtype
+         << ", trigger " << pEvtHead->sMbsEv101_trigger;
+    LOG(DEBUG) <<  ", SE1 len " << iselen1
+         << " procid " << pSEvtHead->sMbsSev101_procid;
+*/
+    ielen -= (iselen1 + 8);
+
+    ii = 1;
+    iselen = iselen1;
+    while (ielen > 0) {
+      ii++;
+//          if (ii > 3) break;
+      pshort += iselen + 4;
+      pSEvtHead = reinterpret_cast<sMbsSev101*>(pshort);
+      iselen = pSEvtHead->iMbsSev101_dlen;
+//      LOG(DEBUG) <<  ", SE" << ii << " " << iselen
+//           << " " << pSEvtHead->sMbsSev101_procid;
+      ielen -= (iselen + 4);
+
+
+
+      pEvt->nSubEvt += 1;
+      pEvt->subEvtSize[ii-1] = pSEvtHead->iMbsSev101_dlen/2 - 1;
+      pEvt->subEvtType[ii-1] = pSEvtHead->sMbsSev101_type;
+      pEvt->subEvtSubType[ii-1] = pSEvtHead->sMbsSev101_subtype;
+      pEvt->subEvtProcId[ii-1] = pSEvtHead->sMbsSev101_procid;
+      pEvt->subEvtSubCrate[ii-1] = pSEvtHead->cMbsSev101_subcrate;
+      pEvt->subEvtControl[ii-1] = pSEvtHead->cMbsSev101_control;
+      pEvt->pSubEvt[ii-1] = reinterpret_cast<Int_t*>(&pshort[6]);
+
+
+    }
+//    LOG(DEBUG) <<  FairLogger::endl;
+  }
+
+  // fill event header
+  iHead[0] = piNextEvt[0];                      // event length
+  iHead[1] = piNextEvt[3];                      // event number
+  pEvt->ReFillHead(iHead);
+
+  // fill event data
+  pEvt->ReFillData(piNextEvt);
+
+  if (imySig == -1) {
+    LOG(INFO) <<  FairLogger::endl << "-D- CTL C specified";
+    if (iDebug) { LOG(DEBUG) <<  " (at end RevGet)" << FairLogger::endl; }
+    else { LOG(INFO) <<  FairLogger::endl; }
+    goto gEndGet;
+  }
+
+  if (iEvtNo == iEvtMax) {
+    LOG(INFO) <<  FairLogger::endl << "-I- all required events ("
+         << iEvtMax << ") received: " << iBufNo << " buffers ("
+         << iBufNo1 << " - " << iBufNo2 << ")" << FairLogger::endl;
+    LOG(INFO) <<  "    fragments found: " << iFragBeginIgn << " begin, "
+         << iFragEndIgn << " end" << FairLogger::endl;
+    if (iFragConc)
+      LOG(INFO) <<  "    " << iFragConc
+           << " events not concatenated from fragments" << FairLogger::endl;
+  }
+
+  iStatus = 0;                      // last event request successfull
+  return(pEvt);
+
+gEndGet:
+  if ( (iError) || (imySig == -1) ) {
+    if (iDebug) {
+      LOG(DEBUG) <<  "    RevGet: closing connection to server";
+    }
+    iRC = rclose(&iSocket, 2);
+    if ( (iDebug) && (iRC == 0) ) {
+      LOG(DEBUG) <<  " - done" << FairLogger::endl;
+    }
+
+    if (imySig == -1) { iStatus = 5; }          // user break (CTL C)
+    else { iStatus = 6; }                       // failure
+    imySig = 0;                             // notify CTL C handler
+  } else if (iDebug == 1) {
+    LOG(DEBUG) <<  "    RevGet: keeping connection to server" << FairLogger::endl;
+  }
+
+  return 0 ;
+
+} // RevGet
+
+Int_t MRevBuffer::RevBufsize()
+{
+  return iBufSize;
+} // RevBufsize
+
+void MRevBuffer::RevBufWait( Int_t iWait )
+{
+  if (iWait > 0) { sleep(iWait); }
+} // RevBufWait
+
+Int_t MRevBuffer::RevStatus( Int_t iOut )
+{
+  if (iOut) switch(iStatus) {
+    case 0:
+      LOG(INFO) <<  "-I- *** Last request for events was successfull"
+           << FairLogger::endl;
+      break;
+    case 1:
+      LOG(INFO) <<  "-I- *** Remote event server not yet connected"
+           << FairLogger::endl;
+      break;
+    case 2:
+      LOG(INFO) <<  "-I- *** Remote event server connected, but still no request for events"
+           << FairLogger::endl;
+      break;
+    case 3:
+      LOG(INFO) <<  "-I- *** Connection to remote event server okay, but currently no DAQ events"
+           << FairLogger::endl;
+      break;
+    case 4:
+      LOG(INFO) <<  "-I- *** Connection to remote event server closed"
+           << FairLogger::endl;
+      break;
+    case 5:
+      LOG(INFO) <<  "-I- *** Connection to remote event server closed after user break (CTL C)"
+           << FairLogger::endl;
+      break;
+    case 6:
+      LOG(INFO) <<  "-I- *** Connection to remote event server closed after failure"
+           << FairLogger::endl;
+      break;
+    default:
+      LOG(INFO) <<  "-E- Invalid status remote event server found: "
+           << iStatus << FairLogger::endl;
+    }
+  return iStatus;
+
+} // RevStatus
+
+void  MRevBuffer::RevClose( TSocket* pSocket )
+{
+  int iRC;
+  Int_t* piComm;
+  srevComm sComm;
+  Int_t iCommSize = sizeof(sComm);       // size comm. buffer (byte)
+
+  if (imySig < 0) { return; }        // CTL Y: connection closed elsewhere
+  if (iSocket == 0) { return; }
+
+  // tell server that no more events needed
+  piComm = &(sComm.iSize);               // communication buffer
+  sComm.iSize = htonl(iCommSize-sizeof(int));// size of data following
+  sComm.iMode = htonl(1);                // required: get events
+  sComm.iIdent = 1;                      // required: tell endian type
+  sComm.iBufRequ = htonl(0);             // no more event buffers
+
+  if (iDebug == 1)
+    LOG(DEBUG) <<  "-D- send close request (data size "
+         << ntohl(sComm.iSize) << " byte): "
+         << ntohl(sComm.iMode) << ", "
+         << ntohl(sComm.iBufRequ) << FairLogger::endl;
+
+  iRC = pSocket->SendRaw(piComm, iCommSize, kDefault);
+  if (iRC < 0)
+    LOG(INFO) <<  "-E- sending close request to server, rc = "
+         << iRC << FairLogger::endl;
+  else if (iDebug == 1) {
+    LOG(DEBUG) <<  "    close request sent" << FairLogger::endl;
+  }
+
+  if (iDebug) {
+    LOG(DEBUG) <<  "    RevClose: closing connection to server";
+  }
+  iRC = rclose(&iSocket, 2);
+  if ( (iDebug) && (iRC == 0) ) {
+    LOG(DEBUG) <<  " - done" << FairLogger::endl;
+  }
+
+  iStatus = 4;                        // connection to server closed
+  imySig = 0;                         // notify CTL C handler
+  LOG(INFO) <<  "-I- connection to server closed" << FairLogger::endl;
+
+} // RevClose
+
+/////////////////////////////////////////////////////////////////////
+
+REvent::REvent()
+  : TObject(),
+    iSize(0),
+    iNumb(0),
+    piData(NULL),
+    nSubEvt(0),
+    subEvtSize(),
+    subEvtType(),
+    subEvtSubType(),
+    pSubEvt()
+{
+  // LOG(INFO) <<  "    REvent() ..." << FairLogger::endl;
+//  iNumb = 0;
+//  piData = 0;
+}
+
+REvent::~REvent()
+{
+  // LOG(INFO) <<  "    ~REvent() ..." << FairLogger::endl;
+}
+
+void REvent::ReFillHead(Int_t* pHead)
+{
+  iSize = pHead[0];     // event size without header in 2-byte-words
+  iNumb = pHead[1];
+}
+
+void REvent::ReFillData(Int_t* pdata)
+{
+  piData = pdata;
+}
+
+Int_t REvent::ReGetNumb()
+{
+  return iNumb;
+}
+
+Int_t REvent::ReGetSize()
+{
+  return iSize;
+}
+
+Int_t REvent::ReGetData(Int_t iChan)
+{
+  Int_t iValue;
+  Int_t* pint;
+
+  //if ( (iChan < 1) || (iChan > iSize/( (signed) sizeof(int))) )
+  if ( (iChan < 1) || (iChan > (iSize+4)/( static_cast<signed>(sizeof(short)))) ) {
+    LOG(INFO) <<  "-E- event parameter number " << iChan
+         << " out of range (" << (iSize+4)/( static_cast<signed>(sizeof(short)))
+         << " long words)" << FairLogger::endl;
+    return(-1);
+  }
+  pint = piData;
+  iValue = pint[iChan-1];
+  //LOG(INFO) <<  "    param " <<  iChan << ": " << iValue << FairLogger::endl;
+  return iValue;
+}
diff --git a/base/source/MRevBuffer.h b/base/source/MRevBuffer.h
new file mode 100644
index 0000000..b8ee0b9
--- /dev/null
+++ b/base/source/MRevBuffer.h
@@ -0,0 +1,141 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+//////////////////////////////////////////////////////////////////////
+// Copyright:
+//   GSI, Gesellschaft fuer Schwerionenforschung mbH
+//   Planckstr. 1
+//   D-64291 Darmstadt
+//   Germany
+// created 16. 2.1999 by Horst Goeringer
+//////////////////////////////////////////////////////////////////////
+// MRevBuffer.h
+//   description of class MRevBuffer
+//   ROOT client package for multithreaded remote event server (MBS)
+//////////////////////////////////////////////////////////////////////
+// 20. 8.1999, H.G.: MRevBuffer::RevGetI added
+//  6. 3.2000, H.G.: new member function RevStatus
+//////////////////////////////////////////////////////////////////////
+
+#ifndef MRevBuffer_H
+#define MRevBuffer_H
+
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Int_t, ClassDef, etc
+
+class TSocket;
+
+class REvent : public TObject
+{
+  private:
+    Int_t  iSize;              // event size (byte)
+    Int_t  iNumb;              // event number
+    Int_t*  piData;            // event parameter
+
+    REvent(const REvent&);
+    REvent& operator=(const REvent&);
+
+  public:
+    REvent();                  // constructor
+    ~REvent();                 // destructor
+
+    void ReFillHead(Int_t* pHead);   // unpack and fill event header
+    void ReFillData(Int_t* pData);   // unpack and fill event data
+
+    Int_t ReGetNumb();               // get event number
+    Int_t ReGetSize();               // get event size
+    Int_t ReGetData(Int_t ichan);    // get event parameter ichan
+    Int_t* GetData() { return piData; }
+
+    Int_t nSubEvt;
+    Int_t subEvtSize[100];
+    Short_t subEvtType[100];
+    Short_t subEvtSubType[100];
+    Short_t subEvtProcId[100];
+    Short_t subEvtSubCrate[100];
+    Short_t subEvtControl[100];
+    Int_t* pSubEvt[100];
+
+    ClassDef(REvent, 0)           // prototype for event
+};
+
+//////////////////////////////////////////////////////////////////////
+
+class MRevBuffer : public TObject
+{
+  private:
+    TSocket* pTSocket;     // ptr socket of channel to event server
+    Int_t  iSocket;        // socket id of channel to event server
+    Int_t  iBufNo1;        // first buffer no. received (test)
+    Int_t  iBufNo2;        // last buffer no. received (test)
+    Int_t  iDebug;         // verbosity level (test)
+    Int_t  iSwap;          // > 0: swap event data
+    Int_t  iStatus;        // current status of server
+
+    Int_t  iBufSizeAlloc;  // allocated buffer size
+    Int_t  iBufSize;       // size current buffer
+    Int_t  iBufNo;         // current buffer no.
+    Int_t  iFragBegin;     // > 0: last buffer ended with fragment
+    Int_t  iFragConc;      // no. of concatenated fragments
+    Int_t  iFragBeginIgn;  // no. of ignored fragment begins
+    Int_t  iFragEndIgn;    // no. of ignored fragment ends
+
+    Int_t  iHeadPar;       // no. of (4 byte) parms buffer header
+    Int_t  iEvtMax;        // no. of events requested
+    Int_t  iEvtNo;         // last event no. handled
+    Int_t  iEvtRel;        // rel. event no. in buffer
+    Int_t  iEvtBuf;        // no. of events in current buffer
+    Int_t  iEvtPar;        // no. of parameters in event (incl. len)
+    Int_t*  piBuf;         // ptr event buffer
+    Int_t*  piNextEvt;     // ptr first element next event
+    REvent* pEvt;          // ptr event class
+
+    MRevBuffer(const MRevBuffer&);
+    MRevBuffer& operator=(const MRevBuffer&);
+
+  public:
+    MRevBuffer( Int_t iMode); // constructor
+    ~MRevBuffer();            // destructor
+
+    TSocket* RevOpen( char* pNode, Int_t iPort, Int_t iEvent);
+    // input: node name and port number server, req. no. of events
+    // returns Socket ptr of server connection
+
+    Int_t* RevGetI( TSocket* pSocket, Int_t iFlush);
+    // get next event (pointer) from buffer, input:
+    // Socket ptr,
+    // iFlush = 1: skip current buffer (not impl)
+
+    REvent* RevGet( TSocket* pSocket, Int_t iFlush, Int_t iSkip);
+    // get next event (pointer) from buffer, input:
+    // Socket ptr,
+    // iFlush = 1: skip current buffer (not impl)
+    // iSkip > 0: take only each iSkip event (not impl)
+
+    Int_t RevStatus(Int_t iOut);
+    // get status information (iOut = 1: also message to stdout)
+    // = 0: last event request successfull
+    // = 1: server not yet connected
+    // = 2: server connected, but still no request for events
+    // = 3: server connection okay, but currently no DAQ events
+    // = 4: connection to server closed
+    // = 5: connection to server closed after user break (CTL C)
+    // = 6: connection to server closed after failure
+
+    void RevBufWait(Int_t iWait);
+    // wait for iWait seconds
+
+    Int_t RevBufsize();
+    // get size of current buffer (byte)
+
+    void  RevClose( TSocket* pSocket );           // input Socket ptr
+
+    ClassDef(MRevBuffer, 0)        // prototype for remote event buffer
+};
+
+#endif     // !MRevBuffer_H 
diff --git a/base/source/README.md b/base/source/README.md
new file mode 100644
index 0000000..f58b370
--- /dev/null
+++ b/base/source/README.md
@@ -0,0 +1,11 @@
+source
+========
+
+The input to the `FairRunOnline` is deriving from `FairSource`.
+Several implementations are provided:
+* from LMD (GSI specific data storage file)
+* from MBS (GSI specific DAQ output, Multi Branch System)
+* from the ROOT file (with the `TTree` *cbmsim*)
+* from the remote DAQ server (derive from MbsSource)
+
+The abstract unpacker class to transform the data into ROOT compliant data.
\ No newline at end of file
diff --git a/base/source/exitCli.c b/base/source/exitCli.c
new file mode 100644
index 0000000..ba0b3ef
--- /dev/null
+++ b/base/source/exitCli.c
@@ -0,0 +1,54 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/********************************************************************
+ * Copyright:
+ *   GSI, Gesellschaft fuer Schwerionenforschung mbH
+ *   Planckstr. 1
+ *   D-64291 Darmstadt
+ *   Germany
+ ********************************************************************
+ * exitCli.c
+ * handles CTL C in ROOT clients of remote event server
+ * created 12. 3.1999 by Horst Goeringer
+ *
+ * 22. 4.1999, H.G.: close TCP connection in client, not here
+ * 10. 6.1999, H.G.: call sleep only if required
+ ********************************************************************
+ */
+#include <stdio.h>                      // for printf
+#include <unistd.h>                     // for sleep
+
+extern int imySig;
+extern int iTimeOut;
+extern int iOutMode;
+
+void exitCli()                                   /* handles Ctl C */
+{
+//   int iRC;
+   int iSleep;                                 /* sleep time here */
+   int iSocket;
+//   int iMode = 2;
+//   char cMsg[128] = "";
+
+   iSocket = imySig;
+   imySig = -1;
+   iSleep = iTimeOut;
+
+   printf("\n-I- user specified CTL C: ");
+   if (iSocket > 0)
+   {
+      if (iOutMode)
+         printf("close connection (socket %d), hold client for %d s\n",
+                 iSocket, iSleep);
+      else printf("close connection\n");
+
+      if (iSleep) sleep(iSleep);
+   }
+   else printf("\n");
+
+} /* exitCli */
diff --git a/base/source/ptrevcomm.h b/base/source/ptrevcomm.h
new file mode 100644
index 0000000..977a37a
--- /dev/null
+++ b/base/source/ptrevcomm.h
@@ -0,0 +1,48 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*********************************************************************
+ * Copyright:
+ *   GSI, Gesellschaft fuer Schwerionenforschung mbH
+ *   Planckstr. 1
+ *   D-64291 Darmstadt
+ *   Germany
+ *********************************************************************
+ * ptrevcomm.h
+ * communication structures
+ *    multi-threaded remote event server <-> ROOT clients
+ * created  2. 2.99, Horst Goeringer
+ *********************************************************************
+ * 23. 3.1999, H.G.: srevInfo added
+ * 26. 7.1999, H.G.: sptrevDummy added
+ * 10.11.1999, H.G.: iIdent in srevComm added
+ *********************************************************************
+ */
+
+/* client requests events from server */
+typedef struct {
+  int iSize; /* size of comm. buffer without this element (bytes) */
+  int iMode;                  /* must be 1: client requests data  */
+  int iIdent;/* =1: NOT IN NET REPR. to identify client endian type */
+  int iBufRequ;                    /* number of buffers requested */
+} srevComm;
+
+/* server sends info to client */
+typedef struct {
+  int iSize;   /* size of info buffer without this element (bytes) */
+  int iMode;                  /* must be 1: server sends info */
+  /* else: client tries swap */
+  int iHeadPar;               /* no. of header parms in buffer */
+  int iTimeOut;               /* wait time client after CTL C */
+} srevInfo;
+
+/* server sends dummy buffer to client, if no DAQ events available */
+typedef struct {
+  int iSize;                             /* size of data following */
+  int iBufNo;                             /* current buffer number */
+  int iEvtNo;                     /* no. of events in buffer (= 0) */
+} sptrevDummy;
diff --git a/base/source/ptrevmbsdef.h b/base/source/ptrevmbsdef.h
new file mode 100644
index 0000000..59ad05c
--- /dev/null
+++ b/base/source/ptrevmbsdef.h
@@ -0,0 +1,106 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*********************************************************************
+ * ptrevmbsdef.h
+ * contains declarations and definitions for GSI MBS 10.1 events
+ * used in ROOT clients for multithreaded remote event server
+ * created 18. 2.99, Horst Goeringer, GSI
+ *
+ * 27. 4.1999, H.G.: replace xxx_ENDIAN -> xxx__ENDIAN
+ *                   xxx_ENDIAN used by AIX (machine.h)
+ * 16. 9.1999, H.G.: add complete buffer header sMbsBufHead
+ *                   rename VMEx -> MbsX
+ * 23. 9.1999, H.G.: additional definitions old PAW clients
+ *********************************************************************
+ */
+
+#ifdef _AIX
+#define BIG__ENDIAN 1
+#endif
+#ifdef Linux
+#define LITTLE__ENDIAN 1
+#endif
+
+#define COMMSIZE 404  /* max size comm. buffer (old and new clients) */
+#define INFOALL  512
+/* max size info buffers (old and new clients) and header (old) */
+#define HEADOLD 344                     /* header size (old clients) */
+
+/************************* buffer header *****************************/
+
+typedef struct {               /* MBS buffer header */
+  long lBuf_dlen;     /* buffer length without header (2byte words) */
+#ifdef BIG__ENDIAN
+  short sBuf_subtype;                             /* buffer subtype */
+  short sBuf_type;                                   /* buffer type */
+  short sBuf_frag;                                /* fragment bytes */
+  short sBuf_ulen;                /* used data length (2byte words) */
+#else
+  short sBuf_type;                                   /* buffer type */
+  short sBuf_subtype;                             /* buffer subtype */
+  short sBuf_ulen;                /* used data length (2byte words) */
+  short sBuf_frag;                                /* fragment bytes */
+#endif
+  long lBuf_bufno;                         /* current buffer number */
+  long lBuf_ele;                    /* number of elements in buffer */
+  long lBuf_rem[7];            /* unused remainder of buffer header */
+} sMbsBufHead;
+
+/* */
+
+typedef struct {                   /* fragment word of buffer header */
+#ifdef BIG__ENDIAN
+  unsigned char cBuf_fragBegin;              /* fragment begin flag */
+  unsigned char cBuf_fragEnd;                  /* fragment end flag */
+  short sBuf_ulen;            /* used Data length in words (2 byte) */
+#else
+  short sBuf_ulen;            /* used Data length in words (2 byte) */
+  unsigned char cBuf_fragEnd;                  /* fragment end flag */
+  unsigned char cBuf_fragBegin;              /* fragment begin flag */
+#endif
+} sMbsBufFrag;
+
+/************************ event header *******************************/
+
+typedef struct {                                     /* event header */
+  int iMbsEv101_dlen;                      /*  Data length in words */
+#ifdef BIG__ENDIAN
+  short sMbsEv101_subtype;
+  short sMbsEv101_type;
+  short sMbsEv101_trigger;                       /*  Trigger number */
+  short sMbsEv101_dummy;                           /*  Not used yet */
+#else
+  short sMbsEv101_type;
+  short sMbsEv101_subtype;
+  short sMbsEv101_dummy;                           /*  Not used yet */
+  short sMbsEv101_trigger;                       /*  Trigger number */
+#endif
+  int iMbsEv101_count;                     /*  Current event number */
+} sMbsEv101;
+
+/************************* subevent header ***************************/
+
+typedef struct {                             /* subevent header 10.1 */
+#ifdef BIG__ENDIAN
+  int iMbsSev101_dlen;                     /*  Data length in words */
+  short sMbsSev101_subtype;
+  short sMbsSev101_type;
+  unsigned char  cMbsSev101_control;
+  unsigned char  cMbsSev101_subcrate;             /* Camac subcrate */
+  short sMbsSev101_procid;                         /* processor id. */
+#else
+  int iMbsSev101_dlen;                     /*  Data length in words */
+  short sMbsSev101_type;
+  short sMbsSev101_subtype;
+  short sMbsSev101_procid;                         /* processor id. */
+  unsigned char  cMbsSev101_subcrate;             /* Camac subcrate */
+  unsigned char  cMbsSev101_control;
+#endif
+} sMbsSev101;
+
+/* end ptrevmbsdef.h */
diff --git a/base/source/rclose.c b/base/source/rclose.c
new file mode 100644
index 0000000..cd3ba5f
--- /dev/null
+++ b/base/source/rclose.c
@@ -0,0 +1,93 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/********************************************************************
+ * Copyright:
+ *   GSI, Gesellschaft fuer Schwerionenforschung mbH
+ *   Planckstr. 1
+ *   D-64291 Darmstadt
+ *   Germany
+ ********************************************************************
+ * rclose.c
+ * shutdown and close of socket
+ * created 23. 4.1999 by Horst Goeringer
+ ********************************************************************
+ */
+// IWYU pragma: no_include <secure/_stdio.h>              
+#include <stdio.h>                      // for printf, perror
+#include <unistd.h>                     // for close
+#include <sys/socket.h>                 // for shutdown
+
+int rclose(int *piSocket, int iMode)
+{
+   int iSocket;
+   int iRC;
+//   int iDebug = 0;
+   int iError = 0;
+   int iClose = 1;
+   char cModule[32] = "rclose";
+   char cMsg[128] = "";
+
+   if (iMode < 0)
+   {
+      iMode = -iMode;
+      iClose = 0;                      /* no shutdown, only close */
+   }
+   if ( (iMode < 0) || (iMode > 3) )
+   {
+      if (iClose == 0) iMode = -iMode;
+      printf("-E- %s: invalid shutdown mode: %d\n", cModule, iMode);
+      iError = 2;
+   }
+
+   iSocket = *piSocket;
+   if (iSocket > 0)
+   {
+      if (iMode < 3)
+      {
+         iRC = shutdown(iSocket, iMode);
+         if (iRC)
+         {
+            sprintf(cMsg, "-E- %s: shutdown(%d) rc = %d", 
+                    cModule, iMode, iRC);
+            perror(cMsg);
+            iError = -1;
+         }
+/*
+         else if (iDebug)
+            printf("    %s: shutdown(%d) successfull\n",
+                   cModule, iMode);    
+*/
+      }
+
+      if (iClose)
+      {
+         iRC = close(iSocket);
+         if (iRC)   
+         {
+            sprintf(cMsg, "-E- %s: close rc = %d", cModule, iRC);
+            perror(cMsg);
+            iError = -2;
+         }
+/*
+         else if (iDebug)
+            printf("    %s: connection closed\n", cModule);
+
+*/
+      } /* (iClose) */
+
+   } /* (iSocket > 0) */
+   else
+   {
+      printf("-E- %s: invalid socket: %d\n", cModule, iSocket);
+      iError = 1;
+   }
+
+   *piSocket = 0;
+   return(iError);
+
+} /* rclose */
diff --git a/base/source/swaplw.c b/base/source/swaplw.c
new file mode 100644
index 0000000..fb7938f
--- /dev/null
+++ b/base/source/swaplw.c
@@ -0,0 +1,67 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/********************************************************************
+ * Copyright:
+ *   GSI, Gesellschaft fuer Schwerionenforschung mbH
+ *   Planckstr. 1
+ *   D-64291 Darmstadt
+ *   Germany
+ * created  6.12.1995 by Ralph S. Mayer
+ ****************************+***************************************
+ * makes 4byte swap
+ ****************************+***************************************
+ */
+
+long  swaplw(pp_source, l_len, pp_dest)
+long         *pp_source, *pp_dest;
+long         l_len;
+{
+
+   char unsigned     *p_source, *p_dest, *p_s, *p_d;
+//   char              c_modnam[] = "f_swaplw";
+   long unsigned     lu_save;
+
+   /* +++ action +++ */
+   p_source = (unsigned char *) pp_source;
+   p_dest   = (unsigned char *) pp_dest;
+
+   if(p_dest)
+   {
+      /* source != destination */
+      for (p_s = (unsigned char *) p_source,
+           p_d = (unsigned char *) p_dest;
+           p_s < p_source + (l_len * 4);
+           p_s += 4)
+      {
+        p_s     += 4;                /* increment source      */
+        *(p_d++) = *(--p_s);
+        *(p_d++) = *(--p_s);
+        *(p_d++) = *(--p_s);
+        *(p_d++) = *(--p_s);
+      }
+    }
+    else
+    {
+       /* source == destination */
+       for (p_d = (unsigned char *) p_source,
+            p_s = (unsigned char *) &lu_save;
+            p_d < p_source + (l_len * 4);
+            )
+       {
+         lu_save = *( (long *) p_d);
+         p_s    += 4;                 /* increment source      */
+           *(p_d++) = *(--p_s);
+           *(p_d++) = *(--p_s);
+           *(p_d++) = *(--p_s);
+           *(p_d++) = *(--p_s);
+       }
+    }
+
+   return(1);
+
+} /* swaplw */
diff --git a/base/steer/FairAnaSelector.cxx b/base/steer/FairAnaSelector.cxx
new file mode 100644
index 0000000..33a49c6
--- /dev/null
+++ b/base/steer/FairAnaSelector.cxx
@@ -0,0 +1,306 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----            FairAnaSelector source file                        -----
+// -----            Created 14/10/11  by R. Karabowicz                 -----
+// -----            Updated 01/02/12  by R. Karabowicz                 -----
+// -------------------------------------------------------------------------
+
+#include "FairAnaSelector.h"
+
+#include "FairFileSource.h"             // for FairFileSource
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairParAsciiFileIo.h"         // for FairParAsciiFileIo
+#include "FairParRootFileIo.h"          // for FairParRootFileIo
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRunAnaProof.h"            // for FairRunAnaProof
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairTask.h"                   // for FairTask
+
+#include "Riosfwd.h"                    // for ostream
+#include "TFile.h"                      // for TFile
+#include "TList.h"                      // for TList
+#include "TNamed.h"                     // for TNamed
+#include "TObject.h"                    // for TObject
+#include "TProofOutputFile.h"           // for TProofOutputFile
+#include "TProofServ.h"                 // for TProofServ
+#include "TSystem.h"                    // for TSystem, gSystem
+
+//_____________________________________________________________________________
+void FairAnaSelector::Init(TTree* tree)
+{
+  // The Init() function is called when the selector needs to initialize
+  // a new tree or chain. Typically here the branch addresses and branch
+  // pointers of the tree will be set.
+  // It is normally not necessary to make changes to the generated
+  // code, but the routine can be extended by the user if needed.
+  // Init() will be called many times when running on PROOF
+  // (once per file to be processed).
+  if (!tree) {
+    LOG(WARNING) << "FairAnaSelector::Init(): There is no tree." << FairLogger::endl;
+    return;
+  } else {
+    LOG(INFO) << "FairAnaSelector::Init(): Got tree     : \"" << tree << "\"" << FairLogger::endl;
+    LOG(INFO) << "FairAnaSelector::Init(): Tree name    : \"" << tree->GetName() << "\"" << FairLogger::endl;
+    LOG(INFO) << "FairAnaSelector::Init(): Tree title   : \"" << tree->GetTitle() << "\"" << FairLogger::endl;
+    LOG(INFO) << "FairAnaSelector::Init(): Tree filename: \"" << tree->GetCurrentFile()->GetName() << "\"" << FairLogger::endl;
+  }
+
+  if ( fRunAna ) {
+    LOG(INFO) << "FairAnaSelector::Init(): Already have fRunAna." << FairLogger::endl;
+
+    LOG(INFO) << "FairAnaSelector::Init(): SetInTree(" << tree << ")" << FairLogger::endl;
+    fProofSource->SetInTree(tree);
+    LOG(INFO) << "FairAnaSelector::Init(): SetInTree done" << FairLogger::endl;
+
+    LOG(INFO) << "FairAnaSelector::Init(): Containers static? " << (fRunAna->GetContainerStatic()?"YES":"NO") << FairLogger::endl;
+
+    if ( !fRunAna->GetContainerStatic() ) {
+      fRunAna->InitContainers();
+    }
+    FairRootManager::Instance()->UpdateBranches();
+  } else {
+    LOG(INFO) << "FairAnaSelector::Init(): Have to create fRunAna." << FairLogger::endl;
+
+    TString vmcPath = gSystem->Getenv("VMCWORKDIR");
+
+    TNamed* contStat    = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fContainerStatic") );
+    TNamed* outStat     = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fProofOutputStatus") );
+    TNamed* outFile     = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fOutputFileName") );
+    TNamed* outDir      = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fOutputDirectory") );
+    TNamed* par1Name    = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fParInput1FName") );
+    TNamed* par2Name    = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fParInput2FName") );
+    TString containerS  = contStat->GetTitle();
+    TString outputStat  = outStat->GetTitle();
+    TString par1Str     = par1Name->GetTitle();
+    TString par2Str     = par2Name->GetTitle();
+    TString outFileName = outFile->GetTitle();
+    TString outDirName  = outDir->GetTitle();
+
+    LOG(INFO) << "FairAnaSelector::Init(): out status   : \"" << outputStat.Data() << "\"" << FairLogger::endl;
+    LOG(INFO) << "FairAnaSelector::Init(): par1 file    : \"" << par1Str.Data() << "\"" << FairLogger::endl;
+    LOG(INFO) << "FairAnaSelector::Init(): par2 file    : \"" << par2Str.Data() << "\"" << FairLogger::endl;
+
+    LOG(INFO) << "FairAnaSelector::Init(): OutputFile option \"" << outputStat.Data() << "\" RECOGNIZED" << FairLogger::endl;
+
+    if ( outputStat.Contains("copy") ) {
+      TString outputFileName = outFile->GetTitle();
+      if ( outputFileName[0] != '/' ) {
+	outputFileName = Form("%s/%s",outDir->GetTitle(),outFile->GetTitle());
+      }
+      outputFileName.Remove(outputFileName.Length()-5);
+      outputFileName = Form("%s_worker_%s.root",outputFileName.Data(),gProofServ->GetOrdinal());
+      //      outputFileName = outputFileName(outputFileName.Last('/')+1,outputFileName.Length());
+      LOG(INFO) << "the file name = \"" << outputFileName.Data() << "\"" << FairLogger::endl;
+      fFile = TFile::Open(outputFileName.Data(),"RECREATE");
+    }
+    else if ( outputStat.Contains("merge") ) {
+      TString outputFileName = outFile->GetTitle();
+      if ( outputFileName[0] != '/' ) {
+	outputFileName = Form("%s/%s",outDir->GetTitle(),outFile->GetTitle());
+      }
+      outputFileName = outputFileName(outputFileName.Last('/')+1,outputFileName.Length());
+      fProofFile = new TProofOutputFile(outputFileName.Data());
+      if (!(fFile = fProofFile->OpenFile("RECREATE"))) {
+	Warning("SlaveBegin", "problems opening file: %s/%s",
+		fProofFile->GetDir(), fProofFile->GetFileName());
+      }
+    }
+
+    fRunAna = new FairRunAnaProof("RunOnProofWorker");
+
+    LOG(INFO) << "FairAnaSelector::Init(): SetInTree(" << tree << ")" << FairLogger::endl;
+    fProofSource = new FairFileSource(tree->GetCurrentFile());
+    fRunAna->SetSource(fProofSource);
+    LOG(INFO) << "FairAnaSelector::Init(): SetInTree done" << FairLogger::endl;
+
+    fRunAna->SetOutputFile(fFile);
+    if ( containerS == "kTRUE" ) {
+      fRunAna->SetContainerStatic(kTRUE);
+    } else {
+      fRunAna->SetContainerStatic(kFALSE);
+    }
+
+    // -----  Parameter database   --------------------------------------------
+    FairRuntimeDb* rtdb = fRunAna->GetRuntimeDb();
+
+    if ( par1Str.Contains(".root") ) {
+      FairParRootFileIo* parInput1 = new FairParRootFileIo();
+      parInput1->open(par1Str.Data());
+      rtdb->setFirstInput (parInput1);
+    }
+    if ( par1Str.Contains(".par") ) {
+      FairParAsciiFileIo* parInput1 = new FairParAsciiFileIo();
+      parInput1->open(par1Str.Data(),"in");
+      rtdb->setFirstInput (parInput1);
+    }
+
+    if ( par2Str.Contains(".root") ) {
+      FairParRootFileIo* parInput2 = new FairParRootFileIo();
+      parInput2->open(par2Str.Data());
+      rtdb->setSecondInput(parInput2);
+    }
+    if ( par2Str.Contains(".par") ) {
+      FairParAsciiFileIo* parInput2 = new FairParAsciiFileIo();
+      parInput2->open(par2Str.Data(),"in");
+      rtdb->setSecondInput(parInput2);
+    }
+
+    // ------------------------------------------------------------------------
+
+    FairTask* fairTaskList = dynamic_cast<FairTask*>(fInput->FindObject("FairTaskList"));
+
+    if ( fairTaskList != 0 ) {
+      LOG(INFO) << "FairAnaSelector::Init(): FairTask = \"" << fairTaskList << "\"" << FairLogger::endl;
+      fRunAna->SetTask(fairTaskList);
+    }
+
+    LOG(INFO) << "FairAnaSelector::Init(): vvvvv fRunAna->Init() vvvvv" << FairLogger::endl;
+    fRunAna->Init();
+    LOG(INFO) << "FairAnaSelector::Init(): ^^^^^ fRunAna->Init() ^^^^^" << FairLogger::endl;
+  }
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairAnaSelector::Notify()
+{
+  // The Notify() function is called when a new file is opened. This
+  // can be either for a new TTree in a TChain or when when a new TTree
+  // is started when using PROOF. It is normally not necessary to make changes
+  // to the generated code, but the routine can be extended by the
+  // user if needed. The return value is currently not used.
+  LOG(INFO) << "FairAnaSelector::Notify()" << FairLogger::endl;
+
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairAnaSelector::Begin(TTree* /*tree*/)
+{
+  // The Begin() function is called at the start of the query.
+  // When running with PROOF Begin() is only called on the client.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+  LOG(INFO) << "FairAnaSelector::Begin()" << FairLogger::endl;
+
+  fCurrentDirectory = gSystem->pwd();
+  TNamed* outFile     = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fOutputFileName") );
+  TNamed* outDir      = static_cast<TNamed*>( fInput->FindObject("FAIRRUNANA_fOutputDirectory") );
+
+  TString outputFileName = outFile->GetTitle();
+  if ( outputFileName[0] != '/' ) {
+    outputFileName = Form("%s/%s",outDir->GetTitle(),outFile->GetTitle());
+  }
+  TString outputDir = outputFileName(0,outputFileName.Last('/')+1);
+  fCurrentDirectory = gSystem->pwd();
+  gSystem->cd(outputDir.Data());
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairAnaSelector::SlaveBegin(TTree* tree)
+{
+  // The SlaveBegin() function is called after the Begin() function.
+  // When running with PROOF SlaveBegin() is called on each slave server.
+  // The tree argument is deprecated (on PROOF 0 is passed).
+  LOG(INFO) << "FairAnaSelector::SlaveBegin(): Tree address   : \"" << tree << "\"" << FairLogger::endl;
+
+  // useless, because have no tree anyways in slavebegin, init will be anyways called whenever a new tree comes
+  //  Init(tree);
+
+  LOG(INFO) << "FairAnaSelector::SlaveBegin(): finishing" << FairLogger::endl;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairAnaSelector::Process(Long64_t entry)
+{
+  // The Process() function is called for each entry in the tree (or possibly
+  // keyed object in the case of PROOF) to be processed. The entry argument
+  // specifies which entry in the currently loaded tree is to be processed.
+  // It can be passed to either FairAnaSelector::GetEntry() or TBranch::GetEntry()
+  // to read either all or the required parts of the data. When processing
+  // keyed objects with PROOF, the object is already loaded and is available
+  // via the fObject pointer.
+  //
+  // This function should contain the "body" of the analysis. It can contain
+  // simple or elaborate selection criteria, run algorithms on the data
+  // of the event and typically fill histograms.
+  //
+  // The processing can be stopped by calling Abort().
+  //
+  // Use fStatus to set the return value of TTree::Process().
+  //
+  // The return value is currently not used.
+  //  LOG(INFO) << "FairAnaSelector::Process(): Proceeding to analyze event " << entry << "." << FairLogger::endl;
+
+  fRunAna->RunOneEvent(entry);
+
+  //  LOG(INFO) << "FairAnaSelector::Process(): Event " << entry << " analyzed." << FairLogger::endl;
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairAnaSelector::SlaveTerminate()
+{
+  // The SlaveTerminate() function is called after all entries or objects
+  // have been processed. When running with PROOF SlaveTerminate() is called
+  // on each slave server.
+  if ( !fRunAna ) {
+    return;
+  }
+
+  if ( !fProofFile ) {
+    LOG(INFO) << "FairAnaSelector::SlaveTerminate(): Calling fRunAna->TerminateRun()" << FairLogger::endl;
+    fRunAna->TerminateRun();
+  }
+
+  LOG(INFO) << "FairAnaSelector::SlaveTerminate(): fProofFile = \"" << fProofFile << "\"" << FairLogger::endl;
+  if ( fProofFile )
+    LOG(INFO) << "FairAnaSelector::SlaveTerminate(): fProofFile = \"" << fProofFile->GetName() << "\"" << FairLogger::endl;
+  LOG(INFO) << "FairAnaSelector::SlaveTerminate():      fFile = \"" << fFile << "\"" << FairLogger::endl;
+  if ( fFile )
+    LOG(INFO) << "FairAnaSelector::SlaveTerminate():      fFile = \"" << fFile->GetName() << "\"" << FairLogger::endl;
+
+  LOG(INFO) << "FairAnaSelector::SlaveTerminate(): WorkingDirectory = \"" << gSystem->WorkingDirectory() << "\"" << FairLogger::endl;
+
+  if ( fProofFile ) {
+    // fOutput->ls();
+    // fOutput->Print();
+    // fProofFile->Print();
+
+    LOG(INFO) << "FairAnaSelector::SlaveTerminate(): fOutput->Add(fProofFile);" << FairLogger::endl;
+    fOutput->Add(fProofFile);
+
+    //    fProofFile->Print();
+
+    LOG(INFO) << "FairAnaSelector::SlaveTerminate(): fFile->Close();" << FairLogger::endl;
+    fRunAna->TerminateRun();
+
+    //    fFile->Close();
+  }
+
+  LOG(INFO) << "FairAnaSelector::SlaveTerminate(): Finishing..." << FairLogger::endl;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairAnaSelector::Terminate()
+{
+  // The Terminate() function is the last function to be called during
+  // a query. It always runs on the client, it can be used to present
+  // the results graphically or save the results to file.
+  LOG(INFO) << "FairAnaSelector::Terminate(): fOutput->ls()" << FairLogger::endl;
+  gSystem->cd(fCurrentDirectory.Data());
+  LOG(INFO) << "FairAnaSelector::Terminate(): -------------" << FairLogger::endl;
+}
+//_____________________________________________________________________________
diff --git a/base/steer/FairAnaSelector.h b/base/steer/FairAnaSelector.h
new file mode 100644
index 0000000..030e4e6
--- /dev/null
+++ b/base/steer/FairAnaSelector.h
@@ -0,0 +1,94 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----            FairAnaSelector header file                        -----
+// -----            Created 14/10/11  by R. Karabowicz                 -----
+// -----            Updated 01/02/12  by R. Karabowicz                 -----
+// -------------------------------------------------------------------------
+
+#ifndef FAIRANASELECTOR_H
+#define FAIRANASELECTOR_H
+
+#include "TSelector.h"                  // for TSelector
+
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TSelectorList.h"              // for TSelectorList
+#include "TString.h"                    // for TString
+#include "TTree.h"                      // for TTree
+
+#include <stddef.h>                     // for NULL
+
+class FairFileSource;
+class FairRunAnaProof;
+
+class TFile;
+class TList;
+class TObject;
+class TProofOutputFile;
+class TString;
+
+class FairAnaSelector : public TSelector
+{
+  public :
+    TProofOutputFile*     fProofFile;
+    TFile*                fFile;
+    TTree*                fChain;   //!pointer to the analyzed TTree or TChain
+    FairRunAnaProof*      fRunAna;
+
+    FairAnaSelector(TTree* /*tree*/ =0) : fProofFile(0), fFile(0), fChain(0), fRunAna(NULL), fLogger(FairLogger::GetLogger()), fProofSource(0), fCurrentDirectory("") { }
+
+    virtual ~FairAnaSelector() { }
+    virtual Int_t   Version() const {
+      return 1;
+    }
+    virtual void    Begin(TTree* tree);
+    virtual void    SlaveBegin(TTree* tree);
+    virtual void    Init(TTree* tree);
+    virtual Bool_t  Notify();
+    virtual Bool_t  Process(Long64_t entry);
+    virtual Int_t   GetEntry(Long64_t entry, Int_t getall = 0) {
+      return fChain ? fChain->GetTree()->GetEntry(entry, getall) : 0;
+    }
+    virtual void    SetOption(const char* option) {
+      fOption = option;
+    }
+    virtual void    SetObject(TObject* obj) {
+      fObject = obj;
+    }
+    virtual void    SetInputList(TList* input) {
+      fInput = input;
+    }
+    virtual TList*  GetOutputList() const {
+      return fOutput;
+    }
+    virtual void    SlaveTerminate();
+    virtual void    Terminate();
+
+    void SetFairRunAnaProof(FairRunAnaProof* runAna) {
+      fRunAna = runAna;
+    }
+
+  protected:
+    /** Fair Logger */
+    FairLogger*             fLogger;//!
+
+  private:
+
+    FairAnaSelector(const FairAnaSelector&);
+    FairAnaSelector operator=(const FairAnaSelector&);
+
+    FairFileSource* fProofSource;
+
+    TString fCurrentDirectory;
+
+    ClassDef(FairAnaSelector,0);
+};
+
+#endif //FAIRANASELECTOR_H
diff --git a/base/steer/FairLinkManager.cxx b/base/steer/FairLinkManager.cxx
new file mode 100644
index 0000000..ed31d55
--- /dev/null
+++ b/base/steer/FairLinkManager.cxx
@@ -0,0 +1,85 @@
+// -------------------------------------------------------------------------
+// -----                   FairLinkManager source file                 -----
+// -----            Created 05/06/14  by T.Stockmanns                  -----
+// -------------------------------------------------------------------------
+
+
+#include "FairLinkManager.h"
+
+#include "FairLogger.h"
+#include "FairRun.h"
+
+using std::set;
+
+#include <iostream>
+
+TMCThreadLocal FairLinkManager* FairLinkManager::fgInstance = 0;
+//_____________________________________________________________________________
+FairLinkManager* FairLinkManager::Instance()
+{
+// Returns singleton instance.
+// ---
+  return fgInstance;
+}
+//_____________________________________________________________________________
+
+FairLinkManager::FairLinkManager()
+  : TObject(),
+    fIgnoreTypes(),
+    fIgnoreSetting(kTRUE),
+    fLogger(0)
+{
+  if (fgInstance) {
+    Fatal("FairLinkManager", "Singleton instance already exists.");
+    return;
+  }
+//  std::cout << "-I- FairLinkManager::FairLinkManager created!" << std::endl;
+  fgInstance = this;
+
+  // Logger only on master - TO DO
+  if ( FairRun::Instance()->GetIsMaster() ) {
+    fLogger = FairLogger::GetLogger();
+  }
+}
+//_____________________________________________________________________________
+FairLinkManager::~FairLinkManager()
+{
+//
+  fLogger->Debug(MESSAGE_ORIGIN,"Enter Destructor of FairLinkManager");
+  fgInstance = 0;
+  fLogger->Debug(MESSAGE_ORIGIN, "Leave Destructor of FairLinkManager");
+}
+//_____________________________________________________________________________
+
+void FairLinkManager::AddIgnoreType(Int_t type)
+{
+	if (fIgnoreSetting == kFALSE){
+		fLogger->Debug(MESSAGE_ORIGIN, "AddIgnoreType ignored because of IncludeType setting");
+		return;
+	}
+	fLogger->Debug(MESSAGE_ORIGIN, "AddIgnoreType");
+	fIgnoreTypes.insert(type);
+}
+
+void FairLinkManager::AddIncludeType(Int_t type)
+{
+	fLogger->Debug(MESSAGE_ORIGIN, "AddIgnoreType");
+//	std::cout << "-I- FairLinkManager::AddIgnoreType: " << type << std::endl;
+	if (fIgnoreSetting == kTRUE){
+		fIgnoreSetting=kFALSE;
+		fIgnoreTypes.clear();
+	}
+	fIgnoreTypes.insert(type);
+}
+
+
+Bool_t FairLinkManager::IsIgnoreType(Int_t type) const
+{
+	if (fIgnoreSetting)
+		return fIgnoreTypes.count(type);
+	else
+		return !fIgnoreTypes.count(type);
+
+}
+
+ClassImp(FairLinkManager)
diff --git a/base/steer/FairLinkManager.h b/base/steer/FairLinkManager.h
new file mode 100644
index 0000000..01bdcaa
--- /dev/null
+++ b/base/steer/FairLinkManager.h
@@ -0,0 +1,60 @@
+#ifndef FAIR_LINK_MANAGER_H
+#define FAIR_LINK_MANAGER_H
+
+#include "TObject.h"                    // for TObject
+#include "TMCtls.h"                     // for multi-threading
+
+#include "Rtypes.h"                     // for Bool_t, Int_t, UInt_t, etc
+#include <set>							// for set of branch types to ignore
+
+
+class FairLogger;
+
+//_____________________________________________________________________
+
+class FairLinkManager : public TObject
+{
+  public:
+    /**ctor*/
+    FairLinkManager();
+    /**dtor*/
+    virtual ~FairLinkManager();
+
+
+    /** static access method */
+    static FairLinkManager* Instance();
+    virtual void AddIgnoreType(Int_t type);		///< Adds a BranchId (Type) to which links are not included in the link list. Either ignore types or include types can be given.
+    virtual Bool_t IsIgnoreType(Int_t type) const;
+
+    virtual void AddIncludeType(Int_t type);	///< Adds a BranchId (Type) to which links are included in the link list. Either ignore types or include types can be given (XOR).
+
+    std::set<Int_t> GetIgnoreTypes() const {return fIgnoreTypes;}
+
+
+  private:
+    /**private methods*/
+    FairLinkManager(const FairLinkManager&);
+    FairLinkManager& operator=(const FairLinkManager&);
+    /**  Set the branch address for a given branch name and return
+        a TObject pointer, the user have to cast this pointer to the right type.*/
+
+//_____________________________________________________________________
+    /**private Members*/
+
+    std::set<Int_t> fIgnoreTypes; //!
+    Bool_t fIgnoreSetting;
+
+    /**Singleton instance*/
+#if !defined(__CINT__)
+    static TMCThreadLocal FairLinkManager* fgInstance;
+#else
+    static                FairLinkManager* fgInstance;
+#endif
+
+    FairLogger*                         fLogger;//!
+
+
+    ClassDef(FairLinkManager,1) // Root IO manager
+};
+
+#endif //FAIR_ROOT_MANAGER_H
diff --git a/base/FairRadGridManager.cxx b/base/steer/FairRadGridManager.cxx
similarity index 75%
rename from base/FairRadGridManager.cxx
rename to base/steer/FairRadGridManager.cxx
index 06983dc..542bf6b 100644
--- a/base/FairRadGridManager.cxx
+++ b/base/steer/FairRadGridManager.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----               FairRadLenManager source file                   -----
 // -----          original author                  D.Bertini           -----
@@ -74,26 +81,26 @@ void FairRadGridManager::FillMeshList()
 {
 
   /**Add a point to the collection*/
-  TParticle* part = gMC->GetStack()->GetCurrentTrack();
-  fTrackID = gMC->GetStack()->GetCurrentTrackNumber();
-  gMC->TrackPosition(fPosIn);
-  gMC->TrackMomentum(fMomIn);
+  TParticle* part = TVirtualMC::GetMC()->GetStack()->GetCurrentTrack();
+  fTrackID = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
+  TVirtualMC::GetMC()->TrackPosition(fPosIn);
+  TVirtualMC::GetMC()->TrackMomentum(fMomIn);
   fELoss = 0.;
-//  Int_t MatId=  gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
+//  Int_t MatId=  TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
 
   /** Sum energy loss for all steps in the mesh*/
   for (Int_t i=0; i<fMeshList->GetEntriesFast(); i++ ) {
-    FairMesh* aMesh = (FairMesh*) fMeshList->At(i);
+    FairMesh* aMesh = static_cast<FairMesh*>(fMeshList->At(i));
     Double_t fBinVolume = aMesh->GetBinVolume();
     Double_t fDiag = aMesh->GetDiag();
 
     // Geometry bound test
     if ( IsTrackInside(fPosIn,aMesh) ) {
-      fELoss = gMC->Edep();
+      fELoss = TVirtualMC::GetMC()->Edep();
       //cout << "-I- track (" << fTrackID << ")  is inside " << endl;
       //cout << " E deposited is " << fELoss << endl;
-      gMC->TrackPosition(fPosOut);
-      gMC->TrackMomentum(fMomOut);
+      TVirtualMC::GetMC()->TrackPosition(fPosOut);
+      TVirtualMC::GetMC()->TrackMomentum(fMomOut);
 
       // Now cumulate fEloss (Gev/cm3)
       // and normalize it to the mesh volume
@@ -101,7 +108,7 @@ void FairRadGridManager::FillMeshList()
       // 1 estimator Edep
       fELoss = fELoss/fBinVolume;
       // 2 estimator TrackLengh
-      fLength = gMC->TrackStep();
+      fLength = TVirtualMC::GetMC()->TrackStep();
       // fill TID
 
       aMesh->fillTID(fPosOut.X(),fPosOut.Y(),fELoss);
@@ -122,8 +129,8 @@ void FairRadGridManager::FillMeshList()
   }
 }
 
-Bool_t FairRadGridManager::IsTrackEntering(TLorentzVector& pos ,
-    TLorentzVector& mom )
+Bool_t FairRadGridManager::IsTrackEntering(TLorentzVector&,
+    TLorentzVector&)
 {
   // assume for the moment vertical scoring planes
   //    cout << " is entering diagnosis " << endl;
@@ -138,6 +145,8 @@ Bool_t FairRadGridManager::IsTrackEntering(TLorentzVector& pos ,
   //      ) return kTRUE;
   //   else
   //     return kFALSE;
+
+  return kFALSE;
 }
 
 Bool_t FairRadGridManager::IsTrackInside(TLorentzVector& pos , FairMesh* aMesh)
diff --git a/base/FairRadGridManager.h b/base/steer/FairRadGridManager.h
similarity index 73%
rename from base/FairRadGridManager.h
rename to base/steer/FairRadGridManager.h
index 90816a8..5f7c8da 100644
--- a/base/FairRadGridManager.h
+++ b/base/steer/FairRadGridManager.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                    FairRadGridManager source file             -----
 // -----          original author                  D.Bertini           -----
@@ -7,15 +14,17 @@
 #define FAIRRADGRIDMANAGER_H 1
 
 
-#include "Rtypes.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TObjArray.h"
-#include <iostream>
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Float_t, Double_t, Int_t, etc
+#include "TLorentzVector.h"             // for TLorentzVector
+#include "TObjArray.h"                  // for TObjArray
 
-using namespace std;
+#include <iostream>                     // for basic_ostream::operator<<, etc
 
 class FairMesh;
+class TClonesArray;
+
+
 /**
  * @class FairRadGridManager
  */
@@ -91,7 +100,7 @@ class FairRadGridManager
 
     TObjArray* GetMeshList() { return fMeshList; }
     void AddMeshList ( TObjArray* list ) {
-      cout << " grid manag " << list->GetEntriesFast() << endl;
+      std::cout << " grid manag " << list->GetEntriesFast() << std::endl;
       fMeshList = list;
     }
     Bool_t  IsTrackInside(TLorentzVector& vec, FairMesh* aMesh);
diff --git a/base/FairRadLenManager.cxx b/base/steer/FairRadLenManager.cxx
similarity index 53%
rename from base/FairRadLenManager.cxx
rename to base/steer/FairRadLenManager.cxx
index d207591..cbdb593 100644
--- a/base/FairRadLenManager.cxx
+++ b/base/steer/FairRadLenManager.cxx
@@ -1,16 +1,27 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadLenManager source file                   -----
 // -----                  Created 14/01/08  by M. Al-Turany            -----
 // -------------------------------------------------------------------------
 
-
-#include <iostream>
-#include "FairRadLenPoint.h"
 #include "FairRadLenManager.h"
-#include "FairRootManager.h"
-#include "TLorentzVector.h"
-#include "TParticle.h"
-#include "TVirtualMC.h"
+
+#include "FairRadLenPoint.h"            // for FairRadLenPoint
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "TClonesArray.h"               // for TClonesArray
+#include "TLorentzVector.h"             // for TLorentzVector
+#include "TVector3.h"                   // for TVector3
+#include "TVirtualMC.h"                 // for TVirtualMC
+#include "TVirtualMCStack.h"            // for TVirtualMCStack
+
+#include <stddef.h>                     // for NULL
 
 using namespace std;
 
@@ -71,30 +82,31 @@ void FairRadLenManager::Reset()
 void FairRadLenManager::AddPoint(Int_t& ModuleId)
 {
   /**Add a point to the collection*/
-  if ( gMC->IsTrackEntering() ) {
+  if ( TVirtualMC::GetMC()->IsTrackEntering() ) {
     fELoss  = 0.;
     Int_t copyNo;
-    fVolumeID = gMC->CurrentVolID(copyNo);
-    fTime   = gMC->TrackTime() * 1.0e09;
-    fLength = gMC->TrackLength();
-    gMC->TrackPosition(fPosIn);
-    gMC->TrackMomentum(fMomIn);
-    //    Int_t MatId=  gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
-    gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
+    fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo);
+    fTime   = TVirtualMC::GetMC()->TrackTime() * 1.0e09;
+    fLength = TVirtualMC::GetMC()->TrackLength();
+    TVirtualMC::GetMC()->TrackPosition(fPosIn);
+    TVirtualMC::GetMC()->TrackMomentum(fMomIn);
+    //    Int_t MatId=  TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
+    TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
   }
   /** Sum energy loss for all steps in the active volume */
-  fELoss += gMC->Edep();
+  fELoss += TVirtualMC::GetMC()->Edep();
   /**  Create a point at exit of the volume */
-  if ( gMC->IsTrackExiting()    ||
-       gMC->IsTrackStop()       ||
-       gMC->IsTrackDisappeared()   ) {
-    FairRadLenPoint* p=0;
-    fTrackID  = gMC->GetStack()->GetCurrentTrackNumber();
-    gMC->TrackPosition(fPosOut);
-    gMC->TrackMomentum(fMomOut);
+  if ( TVirtualMC::GetMC()->IsTrackExiting()    ||
+       TVirtualMC::GetMC()->IsTrackStop()       ||
+       TVirtualMC::GetMC()->IsTrackDisappeared()   ) {
+//    FairRadLenPoint* p=0;
+    fTrackID  = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
+    TVirtualMC::GetMC()->TrackPosition(fPosOut);
+    TVirtualMC::GetMC()->TrackMomentum(fMomOut);
     TClonesArray& clref = *fPointCollection;
     Int_t tsize = clref.GetEntriesFast();
-    p=new(clref[tsize]) FairRadLenPoint(fTrackID, ModuleId,
+//    p=new(clref[tsize]) FairRadLenPoint(fTrackID, ModuleId,
+    new(clref[tsize]) FairRadLenPoint(fTrackID, ModuleId,
                                         TVector3(fPosIn.X(),fPosIn.Y(),fPosIn.Z()),
                                         TVector3(fMomIn.X(),fMomIn.Y(),fMomIn.Z()),
                                         fTime,  fLength, fELoss,
diff --git a/base/FairRadLenManager.h b/base/steer/FairRadLenManager.h
similarity index 76%
rename from base/FairRadLenManager.h
rename to base/steer/FairRadLenManager.h
index 245188f..708bd94 100644
--- a/base/FairRadLenManager.h
+++ b/base/steer/FairRadLenManager.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadLenManager source file             -----
 // -----                  Created 14/01/08  by M. Al-Turany            -----
@@ -6,11 +13,10 @@
 #define FAIRRADLENMANAGER_H 1
 
 
-#include "Rtypes.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-
+#include "Rtypes.h"                     // for Float_t, Double_t, Int_t, etc
+#include "TLorentzVector.h"             // for TLorentzVector
 
+class TClonesArray;
 
 /**
  * @class FairRadLenManager
diff --git a/base/FairRadMapManager.cxx b/base/steer/FairRadMapManager.cxx
similarity index 59%
rename from base/FairRadMapManager.cxx
rename to base/steer/FairRadMapManager.cxx
index df966e8..b26ab50 100644
--- a/base/FairRadMapManager.cxx
+++ b/base/steer/FairRadMapManager.cxx
@@ -1,18 +1,35 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----               FairRadMapManager source file                   -----
 // -------------------------------------------------------------------------
 
-#include <iostream>
-#include "FairRadMapPoint.h"
 #include "FairRadMapManager.h"
-#include "FairRootManager.h"
-#include "TLorentzVector.h"
-#include "TParticle.h"
-#include "TVirtualMC.h"
-#include "TROOT.h"
-#include "TGeoManager.h"
-#include "TGeoVolume.h"
-#include "TVectorD.h"
+
+#include "FairRadMapPoint.h"            // for FairRadMapPoint
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+#include "TClonesArray.h"               // for TClonesArray
+#include "TGeoManager.h"                // for TGeoManager, gGeoManager
+#include "TGeoVolume.h"                 // for TGeoVolume
+#include "TLorentzVector.h"             // for TLorentzVector
+#include "TMap.h"                       // for TMap
+#include "TObjArray.h"                  // for TObjArray
+#include "TObject.h"                    // for TObject
+#include "TVector3.h"                   // for TVector3
+#include "TVectorDfwd.h"                // for TVectorD
+#include "TVectorT.h"                   // for TVectorT
+#include "TVirtualMC.h"                 // for TVirtualMC
+#include "TVirtualMCStack.h"            // for TVirtualMCStack
+
+#include <stdio.h>                      // for NULL, printf
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using namespace std;
 
@@ -114,10 +131,10 @@ void FairRadMapManager::Reset()
   printf(" FairRadMapManager::Reset() ------------------------------------------------\n");
 }
 
-void FairRadMapManager::AddPoint(Int_t& ModuleId)
+void FairRadMapManager::AddPoint(Int_t&)
 {
   /**Add a point to the collection*/
-  if ( gMC->IsTrackEntering() ) {
+  if ( TVirtualMC::GetMC()->IsTrackEntering() ) {
     fELoss  = 0.;
     fStep = 0.;
     fDose = 0.;
@@ -126,19 +143,19 @@ void FairRadMapManager::AddPoint(Int_t& ModuleId)
     fActVol = 0.;
     fActMass = 0.;
     Int_t copyNo;
-    fVolumeID = gMC->CurrentVolID(copyNo);
-    fTime   = gMC->TrackTime() * 1.0e09;
-    fLength = gMC->TrackLength();
-    gMC->TrackPosition(fPosIn);
-    gMC->TrackMomentum(fMomIn);
-    //    Int_t MatId=  gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
-    gMC->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
+    fVolumeID = TVirtualMC::GetMC()->CurrentVolID(copyNo);
+    fTime   = TVirtualMC::GetMC()->TrackTime() * 1.0e09;
+    fLength = TVirtualMC::GetMC()->TrackLength();
+    TVirtualMC::GetMC()->TrackPosition(fPosIn);
+    TVirtualMC::GetMC()->TrackMomentum(fMomIn);
+    //    Int_t MatId=  TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
+    TVirtualMC::GetMC()->CurrentMaterial(fA, fZmat, fDensity, fRadl, fAbsl);
 
     //    if (!gGeoManager) { GetGeoManager(); }
     //    TGeoVolume* actVolume = gGeoManager->GetCurrentVolume();
     TGeoVolume* actVolume = gGeoManager->GetVolume(fVolumeID);
 
-    TVectorD* ActMass = (TVectorD*)fMassMap->GetValue(actVolume);
+    TVectorD* ActMass = static_cast<TVectorD*>(fMassMap->GetValue(actVolume));
 
     fActMass = ActMass->Min(); // read from TVectorD
 
@@ -146,10 +163,10 @@ void FairRadMapManager::AddPoint(Int_t& ModuleId)
 
   }
   /** Sum energy loss for all steps in the active volume */
-  fELoss += gMC->Edep();
-  fStep  += gMC->TrackStep();
+  fELoss += TVirtualMC::GetMC()->Edep();
+  fStep  += TVirtualMC::GetMC()->TrackStep();
 
-  fPdg = gMC->TrackPid();
+  fPdg = TVirtualMC::GetMC()->TrackPid();
 
   // calculate the energy dose
   // exclude fragments with PDG code >= 10000
@@ -167,21 +184,22 @@ void FairRadMapManager::AddPoint(Int_t& ModuleId)
   }
 
   /**  Create a point at exit of the volume */
-  if ( gMC->IsTrackExiting()    ||
-       gMC->IsTrackStop()       ||
-       gMC->IsTrackDisappeared()   ) {
+  if ( TVirtualMC::GetMC()->IsTrackExiting()    ||
+       TVirtualMC::GetMC()->IsTrackStop()       ||
+       TVirtualMC::GetMC()->IsTrackDisappeared()   ) {
 
-    FairRadMapPoint* p=0;
-    fTrackID  = gMC->GetStack()->GetCurrentTrackNumber();
+//    FairRadMapPoint* p=0;
+    fTrackID  = TVirtualMC::GetMC()->GetStack()->GetCurrentTrackNumber();
     Int_t copyNo;
-    Int_t fVolID = gMC->CurrentVolID(copyNo); // CAVEAT: fVolID is NOT an unique identifier!!
-    gMC->TrackPosition(fPosOut);
-    gMC->TrackMomentum(fMomOut);
+    Int_t fVolID = TVirtualMC::GetMC()->CurrentVolID(copyNo); // CAVEAT: fVolID is NOT an unique identifier!!
+    TVirtualMC::GetMC()->TrackPosition(fPosOut);
+    TVirtualMC::GetMC()->TrackMomentum(fMomOut);
 
     TClonesArray& clref = *fPointCollection;
     Int_t tsize = clref.GetEntriesFast();
 
-    p=new(clref[tsize]) FairRadMapPoint(fTrackID, fVolID,
+//    p=new(clref[tsize]) FairRadMapPoint(fTrackID, fVolID,
+    new(clref[tsize]) FairRadMapPoint(fTrackID, fVolID,
                                         TVector3(fPosIn.X(),fPosIn.Y(),fPosIn.Z()),
                                         TVector3(fMomIn.X(),fMomIn.Y(),fMomIn.Z()),
                                         fTime, fLength, fELoss,
diff --git a/base/FairRadMapManager.h b/base/steer/FairRadMapManager.h
similarity index 77%
rename from base/FairRadMapManager.h
rename to base/steer/FairRadMapManager.h
index d8957a8..632cd05 100644
--- a/base/FairRadMapManager.h
+++ b/base/steer/FairRadMapManager.h
@@ -1,14 +1,21 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairRadMapManager source file            -----
 // -------------------------------------------------------------------------
 #ifndef FAIRRADMAPMANAGER_H
 #define FAIRRADMAPMANAGER_H 1
 
-#include "Rtypes.h"
-#include "TClonesArray.h"
-#include "TLorentzVector.h"
-#include "TGeoManager.h"
+#include "Rtypes.h"                     // for Double_t, Float_t, Int_t, etc
+#include "TLorentzVector.h"             // for TLorentzVector
 
+class TClonesArray;
+class TMap;
 
 /**
  * @class FairRadMapManager
diff --git a/base/FairRingSorter.cxx b/base/steer/FairRingSorter.cxx
similarity index 71%
rename from base/FairRingSorter.cxx
rename to base/steer/FairRingSorter.cxx
index ee571b8..2e6973c 100644
--- a/base/FairRingSorter.cxx
+++ b/base/steer/FairRingSorter.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 //  FairRingSorter.cxx
 //   Created on: Jul 30, 2010
@@ -6,7 +13,12 @@
 
 #include "FairRingSorter.h"
 
+#include "FairTimeStamp.h"              // for FairTimeStamp
 
+FairTimeStamp* FairRingSorter::CreateElement(FairTimeStamp* data)
+{
+	return static_cast<FairTimeStamp*>(data->Clone());
+}
 
 void FairRingSorter::AddElement(FairTimeStamp* digi, double timestamp)
 {
@@ -41,7 +53,7 @@ void FairRingSorter::SetLowerBound(double timestampOfHitToWrite)
 {
   int index = CalcIndex(timestampOfHitToWrite + fCellWidth);
 
-  int cellValue = (int)(timestampOfHitToWrite / fCellWidth);
+  int cellValue = static_cast<int>(timestampOfHitToWrite / fCellWidth);
 
   fLowerBoundPointer.second = ((cellValue + 1) * fCellWidth) - GetBufferSize();
   fLowerBoundPointer.first = index;
@@ -51,7 +63,7 @@ void FairRingSorter::SetLowerBound(double timestampOfHitToWrite)
 void FairRingSorter::WriteOutElements(int index)
 {
   if (fLowerBoundPointer.first >= index) {
-    for (int i = fLowerBoundPointer.first; i < fRingBuffer.size(); i++) {
+    for (unsigned int i = fLowerBoundPointer.first; i < fRingBuffer.size(); i++) {
       WriteOutElement(i);
     }
     for (int i = 0; i < index; i++) {
@@ -64,7 +76,7 @@ void FairRingSorter::WriteOutElements(int index)
   }
   if (fVerbose > 1) {
     std::cout << "-I- FairRingSorter::WriteOutElements: Size of Output-Array: " << fOutputData.size() << std::endl;
-    for (int i = 0; i < fOutputData.size(); i++) {
+    for (unsigned int i = 0; i < fOutputData.size(); i++) {
       fOutputData[i]->Print();
       std::cout << " | ";
     }
@@ -77,10 +89,11 @@ void FairRingSorter::WriteOutElement(int index)
   std::multimap<double, FairTimeStamp*>* myDataField = &fRingBuffer.at(index);
   std::multimap<double, FairTimeStamp*>::iterator it;
   if (!myDataField->empty()) {
-    if (fVerbose > 1) { ; }
-    std::cout << "-I- FairRingSorterT:WriteOutElement ";
-    myDataField->begin()->second->Print();
-    std::cout << std::endl;
+    if (fVerbose > 1) {
+		std::cout << "-I- FairRingSorter:WriteOutElement ";
+		myDataField->begin()->second->Print();
+		std::cout << std::endl;
+    }
     for (it = myDataField->begin(); it != myDataField->end(); it++) {
       fOutputData.push_back(it->second);
     }
@@ -90,7 +103,7 @@ void FairRingSorter::WriteOutElement(int index)
 
 int FairRingSorter::CalcIndex(double val)
 {
-  int index = (int)(val / fCellWidth);
+  unsigned int index = static_cast<unsigned int>(val / fCellWidth);
   while (index >= fRingBuffer.size()) {
     index -= fRingBuffer.size();
   }
diff --git a/base/FairRingSorter.h b/base/steer/FairRingSorter.h
similarity index 58%
rename from base/FairRingSorter.h
rename to base/steer/FairRingSorter.h
index 7cbd4af..5650036 100644
--- a/base/FairRingSorter.h
+++ b/base/steer/FairRingSorter.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * FairRingSorter.h
  *
@@ -8,14 +15,18 @@
 #ifndef FairRingSorter_H_
 #define FairRingSorter_H_
 
-#include "TObject.h"
-#include "FairTimeStamp.h"
 
-#include <vector>
-#include <stack>
-#include <map>
+#include "TObject.h"                    // for TObject
 
-#include <iostream>
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for FairRingSorter::Class, etc
+
+#include <iostream>                     // for operator<<, ostream, etc
+#include <map>                          // for multimap
+#include <utility>                      // for pair
+#include <vector>                       // for vector
+
+class FairTimeStamp;
 
 class FairRingSorter : public TObject
 {
@@ -27,7 +38,7 @@ class FairRingSorter : public TObject
 
     virtual ~FairRingSorter() {};
 
-    virtual FairTimeStamp* CreateElement(FairTimeStamp* data) = 0;
+    virtual FairTimeStamp* CreateElement(FairTimeStamp* data);
 
     virtual void AddElement(FairTimeStamp* digi, double timestamp);
     virtual void WriteOutElements(int index);       ///< writes out the entries from LowerBoundPointer up to index
@@ -43,11 +54,11 @@ class FairRingSorter : public TObject
     virtual void DeleteOutputData() {fOutputData.clear(); }
     virtual void SetLowerBound(double timestampOfHitToWrite);
 
-    virtual void Print(std::ostream& out = std::cout) {
+    virtual void print(std::ostream& out = std::cout) {
       out << "RingSorter: Size " << fRingBuffer.size() << " CellWidth: " << fCellWidth << std::endl;
       out << "LowerBoundPointer at index: " << fLowerBoundPointer.first << " Time: " << fLowerBoundPointer.second << std::endl;
       out << "| ";
-      for (int i = 0; i < fRingBuffer.size(); i++) {
+      for (unsigned int i = 0; i < fRingBuffer.size(); i++) {
         out << fRingBuffer[i].size() << " |";
       }
       out << std::endl;
diff --git a/base/FairRingSorterTask.cxx b/base/steer/FairRingSorterTask.cxx
similarity index 62%
rename from base/FairRingSorterTask.cxx
rename to base/steer/FairRingSorterTask.cxx
index 8853adf..a9543bc 100644
--- a/base/FairRingSorterTask.cxx
+++ b/base/steer/FairRingSorterTask.cxx
@@ -1,18 +1,37 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairRingSorterTaskT source file             -----
 // -------------------------------------------------------------------------
 
 #include "FairRingSorterTask.h"
-#include "FairRootManager.h"
 
+#include "FairLink.h"                   // for FairLink
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairTimeStamp.h"              // for FairTimeStamp
 
+#include "Riosfwd.h"                    // for ostream
+#include "TClass.h"                     // for TClass
+#include "TClonesArray.h"               // for TClonesArray
 
+#include <iostream>                     // for operator<<, cout, ostream, etc
+#include <vector>                       // for vector
 
 InitStatus FairRingSorterTask::ReInit()
 {
   return kSUCCESS;
 }
 
+FairRingSorter* FairRingSorterTask::InitSorter(Int_t numberOfCells, Double_t widthOfCells) const
+{
+	return new FairRingSorter(numberOfCells, widthOfCells);
+}
+
 // -----   Public method Init   --------------------------------------------
 InitStatus FairRingSorterTask::Init()
 {
@@ -38,7 +57,7 @@ InitStatus FairRingSorterTask::Init()
 // -------------------------------------------------------------------------
 
 // -----   Public method Exec   --------------------------------------------
-void FairRingSorterTask::Exec(Option_t* opt)
+void FairRingSorterTask::Exec(Option_t*)
 {
 
 
@@ -48,7 +67,7 @@ void FairRingSorterTask::Exec(Option_t* opt)
     std::cout << "-I- FairRingSorterTask: Size PixelArray: " << fInputArray->GetEntriesFast() << std::endl;
   }
   for (int i = 0; i < fInputArray->GetEntriesFast(); i++) {
-    FairTimeStamp* myData = (FairTimeStamp*)fInputArray->At(i);
+    FairTimeStamp* myData = static_cast<FairTimeStamp*>(fInputArray->At(i));
     myData->SetEntryNr(FairLink(0, fEntryNr, fInputBranch, i));
     if (fVerbose > 1) {
       std::cout << "Sorter filled with: ";
@@ -63,13 +82,21 @@ void FairRingSorterTask::Exec(Option_t* opt)
 
 
   fOutputArray = FairRootManager::Instance()->GetEmptyTClonesArray(fOutputBranch);
-  for (int i = 0; i < sortedData.size(); i++) {
+  for (unsigned int i = 0; i < sortedData.size(); i++) {
     AddNewDataToTClonesArray(sortedData[i]);
   }
   fSorter->DeleteOutputData();
   fEntryNr++;
 }
 
+
+void FairRingSorterTask::AddNewDataToTClonesArray(FairTimeStamp* data)
+{
+	FairRootManager* ioman = FairRootManager::Instance();
+	TClonesArray* myArray = ioman->GetTClonesArray(fOutputBranch);
+	(*myArray)[myArray->GetEntries()] = data;
+}
+
 // -------------------------------------------------------------------------
 
 void FairRingSorterTask::FinishEvent()
@@ -82,8 +109,8 @@ void FairRingSorterTask::FinishTask()
   fInputArray = FairRootManager::Instance()->GetTClonesArray(fInputBranch);
   if (fVerbose > 2) { std::cout << "-I- FairRingSorterTaskT::FinishTask Size InputArray: " << fInputArray->GetEntriesFast() << std::endl; }
   for (int i = 0; i < fInputArray->GetEntriesFast(); i++) {
-    FairTimeStamp* myDigi = (FairTimeStamp*) fInputArray->At(i);
-    fSorter->AddElement(myDigi, ((FairTimeStamp*)myDigi)->GetTimeStamp());
+    FairTimeStamp* myDigi = static_cast<FairTimeStamp*>( fInputArray->At(i));
+    fSorter->AddElement(myDigi, (static_cast<FairTimeStamp*>(myDigi))->GetTimeStamp());
   }
   fSorter->Print();
   fSorter->WriteOutAll();
@@ -91,7 +118,7 @@ void FairRingSorterTask::FinishTask()
 
   FairRootManager* ioman = FairRootManager::Instance();
   fOutputArray = ioman->GetEmptyTClonesArray(fOutputBranch);
-  for (int i = 0; i < sortedData.size(); i++) {
+  for (unsigned int i = 0; i < sortedData.size(); i++) {
     if (fVerbose > 2) {
       std::cout << i << " FinishTask : ";
       sortedData[i]->Print();
diff --git a/base/FairRingSorterTask.h b/base/steer/FairRingSorterTask.h
similarity index 73%
rename from base/FairRingSorterTask.h
rename to base/steer/FairRingSorterTask.h
index f3f36d5..8b28d13 100644
--- a/base/FairRingSorterTask.h
+++ b/base/steer/FairRingSorterTask.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 
 /** FairRingSorterTask.h
  **
@@ -6,13 +13,14 @@
 #ifndef FairRingSorterTask_H
 #define FairRingSorterTask_H
 
-#include "FairTask.h"
+#include "FairTask.h"                   // for FairTask, InitStatus
 
-#include "TClonesArray.h"
-
-#include "FairRingSorter.h"
+#include "FairRingSorter.h"             // for FairRingSorter
 
+#include "Rtypes.h"                     // for Bool_t, Int_t, kTRUE, etc
+#include "TString.h"                    // for TString
 
+class FairTimeStamp;
 class TClonesArray;
 
 class FairRingSorterTask : public FairTask
@@ -88,8 +96,8 @@ class FairRingSorterTask : public FairTask
     void SetPersistance(Bool_t p = kTRUE) {fPersistance=p;};
     Bool_t GetPersistance() {return fPersistance;};
 
-    virtual void AddNewDataToTClonesArray(FairTimeStamp* data) = 0;
-    virtual FairRingSorter* InitSorter(Int_t numberOfCells, Double_t widthOfCells) const  = 0;
+    virtual void AddNewDataToTClonesArray(FairTimeStamp* data);
+    virtual FairRingSorter* InitSorter(Int_t numberOfCells, Double_t widthOfCells) const;
 
   protected:
 
diff --git a/base/steer/FairRootManager.cxx b/base/steer/FairRootManager.cxx
new file mode 100644
index 0000000..2575404
--- /dev/null
+++ b/base/steer/FairRootManager.cxx
@@ -0,0 +1,1311 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                   FairRootManager source file                 -----
+// -----            Created 06/01/04  by M. Al-Turany/D. Bertini       -----
+// -------------------------------------------------------------------------
+
+// Class FairRootManager
+// ------------------
+// Class that takes care of Root IO.
+#include "FairRootManager.h"
+
+#include "FairEventHeader.h"            // for FairEventHeader
+#include "FairFileHeader.h"             // for FairFileHeader
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairLink.h"                   // for FairLink
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairMonitor.h"                // for FairMonitor
+#include "FairMCEventHeader.h"          // for FairMCEventHeader
+#include "FairRun.h"                    // for FairRun
+#include "FairTSBufferFunctional.h"     // for FairTSBufferFunctional, etc
+#include "FairWriteoutBuffer.h"         // for FairWriteoutBuffer
+#include "FairLinkManager.h"            // for FairLinkManager
+#include "Riosfwd.h"                    // for ostream
+#include "TArrayI.h"                    // for TArrayI
+#include "TBranch.h"                    // for TBranch
+#include "TChainElement.h"              // for TChainElement
+#include "TClass.h"                     // for TClass
+#include "TClonesArray.h"               // for TClonesArray
+#include "TCollection.h"                // for TCollection, TIter
+#include "TF1.h"                        // for TF1
+#include "TFolder.h"                    // for TFolder
+#include "TGeoManager.h"                // for TGeoManager, gGeoManager
+#include "TIterator.h"                  // for TIterator
+#include "TList.h"                      // for TList
+#include "TMath.h"                      // for floor
+#include "TNamed.h"                     // for TNamed
+#include "TObjArray.h"                  // for TObjArray
+#include "TObjString.h"                 // for TObjString
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TRandom.h"                    // for TRandom, gRandom
+#include "TTree.h"                      // for TTree
+#include "TRefArray.h"                  // for TRefArray
+
+#include <stdlib.h>                     // for exit
+#include <string.h>                     // for NULL, strcmp
+#include <algorithm>                    // for find
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <list>                         // for _List_iterator, list, etc
+#include <map>                          // for map, _Rb_tree_iterator, etc
+#include <set>                          // for set, set<>::iterator
+#include <utility>                      // for pair
+#include <vector>                       // for vector
+
+using std::flush;
+using std::cout;
+using std::endl;
+using std::map;
+using std::list;
+using std::pair;
+using std::set;
+
+TMCThreadLocal FairRootManager* FairRootManager::fgInstance = 0;
+//_____________________________________________________________________________
+FairRootManager* FairRootManager::Instance()
+{
+// Returns singleton instance.
+// ---
+  return fgInstance;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRootManager::FairRootManager()
+  : TObject(),
+    fOldEntryNr(-1),
+    fCbmout(0),
+    fCbmroot(0),
+    fCurrentTime(0),
+    fOutFile(NULL),
+    fOutTree(NULL),
+    fObj2(new TObject*[1000]),
+    fNObj(-1),
+    fMap(),
+    fBranchSeqId(0),
+    fBranchNameList(new TList()),
+    fTimeBasedBranchNameList(new TList()),
+    fActiveContainer(),
+    fTSBufferMap(),
+    fWriteoutBufferMap(),
+    fInputBranchMap(),
+    fTimeStamps(kFALSE),
+    fBranchPerMap(kFALSE),
+    fBrPerMap(),
+    fBrPerMapIter(),
+    fCurrentEntryNo(0),
+    fTimeforEntryNo(0),
+    fFillLastData(kFALSE),
+    fEntryNr(0),
+    fListFolder(0),
+    fSource(0),
+    fSourceChain(new TChain(GetTreeName(), "/cbmroot")),
+    fSignalChainList(),
+    fEventHeader(new FairEventHeader()),
+    fUseFairLinks(kFALSE),
+    fFinishRun(kFALSE),
+    fListOfBranchesFromInput(0),
+    fListOfBranchesFromInputIter(0),
+    fListOfNonTimebasedBranches(new TRefArray()),
+    fListOfNonTimebasedBranchesIter(0)
+  {
+  if (fgInstance) {
+    LOG(FATAL) << "Singleton instance already exists." << FairLogger::endl;
+  }
+  fgInstance = this;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRootManager::~FairRootManager()
+{
+//
+  LOG(DEBUG) << "Enter Destructor of FairRootManager" << FairLogger::endl;
+  if(fOutTree) {
+    delete fOutTree;
+  }
+  if(fOutFile) {
+    fOutFile->cd();
+    delete fOutFile;
+  }
+  delete fObj2;
+  fBranchNameList->Delete();
+  delete fBranchNameList;
+  fgInstance = 0;
+  LOG(DEBUG) << "Leave Destructor of FairRootManager" << FairLogger::endl;
+
+  if (fEventHeader)
+	  delete fEventHeader;
+  if (fSourceChain)
+	  delete fSourceChain;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairRootManager::InitSource() {
+  
+  LOG(DEBUG) << "Call the initialiazer for the FairSource in FairRootManager " << FairLogger::endl;
+  if ( fSource ) {
+    Bool_t sourceInitBool = fSource->Init();
+    fListOfBranchesFromInput=fSourceChain->GetListOfBranches();
+    TObject *obj;
+    if(fListOfBranchesFromInput){
+      fListOfBranchesFromInputIter=fListOfBranchesFromInput->MakeIterator();
+      while((obj=fListOfBranchesFromInputIter->Next())) {
+         if((fTimeBasedBranchNameList->FindObject(obj->GetName()))==0)
+         fListOfNonTimebasedBranches->Add(obj);
+      }
+    }
+    LOG(DEBUG) << "Source is intialized and the list of branches is created in FairRootManager " << FairLogger::endl;
+    fListOfNonTimebasedBranchesIter=fListOfNonTimebasedBranches->MakeIterator();
+    return sourceInitBool;
+  }
+  return kFALSE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TFile* FairRootManager::OpenOutFile(TFile* f)
+{
+
+  LOG(DEBUG) << "Check the output file" << FairLogger::endl;
+  fOutFile=f;
+  /**Check the output file, if anything wronge with it exit!*/
+  if (fOutFile->IsZombie()) {
+    LOG(FATAL) << "FairRootManager: Error opening output file " 
+	       << FairLogger::endl;
+    exit(-1);
+  }
+  FairRun* fRun = FairRun::Instance();
+  /**Check if a simulation run!*/
+  if(!fRun->IsAna()) {
+    fCbmroot= gROOT->GetRootFolder()->AddFolder("cbmroot", "Main Folder");
+    gROOT->GetListOfBrowsables()->Add(fCbmroot);
+  } else {
+    fCbmout= gROOT->GetRootFolder()->AddFolder("cbmout", "Main Output Folder");
+    gROOT->GetListOfBrowsables()->Add(fCbmout);
+  }
+  return fOutFile;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TFile* FairRootManager::OpenOutFile(const char* fname)
+{
+  LOG(DEBUG) << "Opening output file, " << fname << FairLogger::endl;
+  if(fOutFile) {
+    CloseOutFile();
+  }
+  LOG(INFO) << "FairRootManager::OpenOutFile(\"" << fname << "\")" << FairLogger::endl;
+  fOutFile = new TFile(fname, "recreate");
+  return OpenOutFile(fOutFile);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairRootManager::Register(const char* name, const char* folderName , TNamed* obj, Bool_t toFile)
+{
+  FairMonitor::GetMonitor()->RecordRegister(name,folderName,toFile);
+
+  // Security check. If the the name is equal the folder name there are problems with reading
+  // back the data. Instead of the object inside the folder the RootManger will return a pointer
+  // to the folder. To avoid such problems we check here if both strings are equal and stop the
+  // execution with some error message if this is the case.
+  if (strcmp (name, folderName) == 0 ) {
+    LOG(FATAL) << "The names for the object name "
+	       << name << " and the folder name "
+	       << folderName <<" are equal. This isn't allowed. So we stop the execution at this point. Pleae change either the name or the folder name."
+	       << FairLogger::endl;
+  }
+
+  if(toFile) { /**Write the Object to the Tree*/
+    TFolder* folder=0;
+    TFolder* f=0;
+    if(fCbmout==0) {
+      f=static_cast<TFolder*>(fCbmroot->FindObjectAny(folderName));
+      if(f==0) {
+        folder= fCbmroot->AddFolder(folderName,folderName);
+      } else {
+        folder=f;
+      }
+    } else {
+      f=static_cast<TFolder*>(fCbmout->FindObjectAny(folderName));
+      if(f==0) {
+        folder= fCbmout->AddFolder(folderName,folderName);
+      } else {
+        folder=f;
+      }
+    }
+    obj->SetName(name);
+    folder->Add(obj);
+  }
+  AddMemoryBranch(name, obj );
+  //cout << " FairRootManager::Register Adding branch:(Obj) " << name << " In folder : " << folderName << endl;
+ 
+  AddBranchToList(name);
+    
+  if (toFile == kFALSE) {
+          FairLinkManager::Instance()->AddIgnoreType(GetBranchId(name));
+   }
+}
+//_____________________________________________________________________________
+
+Int_t  FairRootManager::AddBranchToList(const char* name)
+{
+    if(fBranchNameList->FindObject(name)==0) {
+        fBranchNameList->AddLast(new TObjString(name));
+        fBranchSeqId++;
+    }
+    return fBranchSeqId;
+}
+
+
+//_____________________________________________________________________________
+void  FairRootManager::Register(const char* name,const char* Foldername ,TCollection* obj, Bool_t toFile)
+{
+  FairMonitor::GetMonitor()->RecordRegister(name,Foldername,toFile);
+
+  /**
+  * This method do exactly the same as the one before but for TCollection which is a TObject and not a TNamed (MT)
+  */
+  // Security check. If the the name is equal the folder name there are problems with reading
+  // back the data. Instead of the object inside the folder the RootManger will return a pointer
+  // to the folder. To avoid such problems we check here if both strings are equal and stop the
+  // execution with some error message if this is the case.
+  if (strcmp (name, Foldername) == 0 ) {
+    LOG(FATAL) << "The names for the object name "
+	       << name << " and the folder name "
+	       << Foldername << " are equal. This isn't allowed. So we stop the execution at this point. Pleae change either the name or the folder name."
+
+	       <<FairLogger::endl;
+  }
+
+  if(toFile) { /**Write the Object to the Tree*/
+    TFolder* folder=0;
+    TFolder* f=0;
+    if(fCbmout==0) {
+      f=static_cast<TFolder*>(fCbmroot->FindObjectAny(Foldername));
+      if(f==0) {
+        folder= fCbmroot->AddFolder(Foldername,Foldername);
+      } else {
+        folder=f;
+      }
+    } else {
+      f=static_cast<TFolder*>(fCbmout->FindObjectAny(Foldername));
+      if(f==0) {
+        folder= fCbmout->AddFolder(Foldername,Foldername);
+      } else {
+        folder=f;
+      }
+    }
+    obj->SetName(name);
+    folder->Add(obj);
+  }
+  /**Keep the Object in Memory, and do not write it to the tree*/
+  AddMemoryBranch(name, obj );
+  AddBranchToList(name);
+  
+  if (toFile == kFALSE) {
+	  FairLinkManager::Instance()->AddIgnoreType(GetBranchId(name));
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::RegisterInputObject(const char* name, TObject* obj)
+{
+    AddMemoryBranch(name, obj);
+    AddBranchToList(name);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TClonesArray* FairRootManager::Register(TString branchName, TString className, TString folderName, Bool_t toFile)
+{
+  FairMonitor::GetMonitor()->RecordRegister(branchName,folderName,toFile);
+
+  TClonesArray* outputArray;
+  if (fActiveContainer.find(branchName) == fActiveContainer.end()) {
+    fActiveContainer[branchName] = new TClonesArray(className);
+    outputArray = fActiveContainer[branchName];
+    Register(branchName, folderName, outputArray, toFile);
+  }
+  return fActiveContainer[branchName];
+}
+//_____________________________________________________________________________
+TClonesArray* FairRootManager::GetEmptyTClonesArray(TString branchName)
+{
+  if (fActiveContainer.find(branchName) != fActiveContainer.end()) {          //if a TClonesArray is registered in the active container
+    if (fActiveContainer[branchName] == 0) {                      //the address of the TClonesArray is still valid
+      std::cout << "-E- FairRootManager::GetEmptyTClonesArray: Container deleted outside FairRootManager!" << std::endl;
+    } else {
+      fActiveContainer[branchName]->Delete();
+    }
+    return fActiveContainer[branchName];                        // return the container
+  } else {
+    std::cout << "-E- Branch: " << branchName << " not registered!" << std::endl;  // error if the branch is not registered
+  }
+  return 0;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TClonesArray* FairRootManager::GetTClonesArray(TString branchName)
+{
+  if (fActiveContainer.find(branchName) != fActiveContainer.end()) {
+    return fActiveContainer[branchName]; // return the container
+  } else {
+    LOG(INFO) << "Branch: " << branchName.Data()
+	      << " not registered!" << FairLogger::endl ;
+  }
+  // error if the branch is not registered
+  return 0;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TString FairRootManager::GetBranchName(Int_t id)
+{
+  /**Return the branch name from the id*/
+  if(id < fBranchSeqId) {
+    TObjString* ObjStr= static_cast<TObjString*>(fBranchNameList->At(id));
+    return ObjStr->GetString();
+  } else {
+    TString NotFound("Branch not found");
+    return NotFound;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t FairRootManager::GetBranchId(TString BrName)
+{
+  /**Return the branch id from the name*/
+  TObjString* ObjStr;
+  Int_t Id=-1;
+  for(Int_t t=0; t<fBranchNameList->GetEntries(); t++) {
+    ObjStr= static_cast<TObjString*>(fBranchNameList->At(t));
+    if(BrName==ObjStr->GetString()) {
+      Id=t;
+      break;
+    }
+  }
+  return Id;
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::InitTSBuffer(TString branchName, BinaryFunctor* function)
+{
+	fTSBufferMap[branchName] = new FairTSBufferFunctional(branchName, GetInTree(), function);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TClonesArray*    FairRootManager::GetData(TString branchName, BinaryFunctor* function, Double_t parameter)
+{
+  if (fTSBufferMap[branchName] == 0) {
+    fTSBufferMap[branchName] = new FairTSBufferFunctional(branchName, GetInTree(), function);
+  }
+  fTSBufferMap[branchName]->SetStopFunction(function);
+  return fTSBufferMap[branchName]->GetData(parameter);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TClonesArray* FairRootManager::GetData(TString branchName, BinaryFunctor* startFunction, Double_t startParameter, BinaryFunctor* stopFunction, Double_t stopParameter)
+{
+  if (fTSBufferMap[branchName] == 0) {
+    fTSBufferMap[branchName] = new FairTSBufferFunctional(branchName, GetInTree(), stopFunction, startFunction);
+  }
+  fTSBufferMap[branchName]->SetStopFunction(stopFunction);
+  fTSBufferMap[branchName]->SetStartFunction(startFunction);
+  return fTSBufferMap[branchName]->GetData(startParameter, stopParameter);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::TerminateTSBuffer(TString branchName)
+{
+	if (fTSBufferMap.count(branchName) > 0){
+		fTSBufferMap[branchName]->Terminate();
+	}
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+
+void FairRootManager::TerminateAllTSBuffer()
+{
+	for (std::map<TString, FairTSBufferFunctional*>::iterator iter = fTSBufferMap.begin(); iter != fTSBufferMap.end(); iter++)
+	{
+		iter->second->Terminate();
+	}
+}
+
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairRootManager::AllDataProcessed()
+{
+  for(std::map<TString, FairTSBufferFunctional*>::iterator it = fTSBufferMap.begin(); it != fTSBufferMap.end(); it++) {
+    if (it->second->AllDataProcessed() == kFALSE && it->second->TimeOut() == kFALSE) {
+      return kFALSE;
+    }
+  }
+  return kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::Fill()
+{
+  if (fOutTree != 0) {
+    fOutTree->Fill();
+  } else {
+    LOG(INFO) << " No Output Tree" << FairLogger::endl;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::LastFill()
+{
+  FairMonitor::GetMonitor()->StoreHistograms(fOutFile);
+  if (fFillLastData) {
+    Fill();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t FairRootManager::Write(const char*, Int_t, Int_t)
+{
+  /** Writes the tree in the file.*/
+
+  if(fOutTree!=0) {
+    /** Get the file handle to the current output file from the tree.
+      * If ROOT splits the file (due to the size of the file) the file
+      * handle fOutFile is lost and the program crash while writing the
+      * last part of the last file.
+    */
+    fOutFile = fOutTree->GetCurrentFile();
+    fOutFile->cd();
+    fOutTree->Write();
+  } else {
+    LOG(INFO) << "No Output Tree" << FairLogger::endl;
+  }
+  return 0;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager:: WriteGeometry()
+{
+  /** Writes the geometry in the current output file.*/
+
+  if(fOutTree!=0) {
+    fOutFile = fOutTree->GetCurrentFile();
+    fOutFile->cd();
+    gGeoManager->Write();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::CreateGeometryFile(const char* geofile)
+{
+  /** Writes the geometry in a separate file.
+   *  This is only to have a file which can be read without the
+   *  framework. The geomanager used by the framework is still
+   *  stored in the parameter file or database
+  */
+  TFile* oldfile=gFile;
+  TFile* file=new TFile(geofile,"RECREATE");
+  file->cd();
+  gGeoManager->Write();
+  file->Close();
+  file->Delete();
+  gFile=oldfile;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager:: WriteFolder()
+{
+  fOutFile->cd();
+  if(fCbmroot!=0 && fSource==0) {
+    fCbmroot->Write();
+  }
+  if(fCbmout!=0) {
+    fCbmout->Write();
+  }
+  fBranchNameList->Write("BranchList", TObject::kSingleKey);
+  fTimeBasedBranchNameList->Write("TimeBasedBranchList", TObject::kSingleKey);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t  FairRootManager::ReadEvent(Int_t i)
+{
+  if ( !fSource ) return 0;
+  
+  fSource->Reset();
+
+  SetEntryNr(i);
+
+  if ( !fSource ) {
+    LOG(FATAL) << "No Source available" << FairLogger::endl;
+    return -1;
+  }
+
+  fCurrentEntryNo=i;
+
+  Int_t readEventResult = fSource->ReadEvent(i);
+
+  fSource->FillEventHeader(fEventHeader);
+  fCurrentTime = fEventHeader->GetEventTime();
+
+  LOG(DEBUG) << "--Event number --- "
+	     << fCurrentEntryNo << " with time ---- " 
+	     << fCurrentTime << FairLogger::endl;
+
+  return readEventResult;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t FairRootManager::GetRunId() 
+{
+  if ( fSource ) {
+    fSource->FillEventHeader(fEventHeader);
+    return fEventHeader->GetRunId();
+  }
+  return -1;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::ReadBranchEvent(const char* BrName)
+{
+    if ( fSource )
+    fSource->ReadBranchEvent(BrName);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+Int_t FairRootManager::ReadNonTimeBasedEventFromBranches(Int_t Entry)
+{
+    if ( fSource ){
+        TObject *Obj;
+        fListOfNonTimebasedBranchesIter->Reset();
+        while ( (Obj=fListOfNonTimebasedBranchesIter->Next())) {
+            fSource->ReadBranchEvent(Obj->GetName(),Entry);
+        }
+    }else{
+      return 0;
+    }
+    return 1;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Bool_t FairRootManager::ReadNextEvent(Double_t)
+{
+  Bool_t readentry=kFALSE;
+  ///TODO
+  return readentry;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TObject* FairRootManager::GetObject(const char* BrName)
+{
+  /**Get Data object by name*/
+  TObject* Obj =NULL;
+  LOG(DEBUG2) << " Try to find if the object "
+	      << BrName << " is already activated by another task or call"
+	      << FairLogger::endl;
+  /**Try to find the object in the folder structure, object already activated by other task or call*/
+  if(fCbmout) {
+    Obj = fCbmout->FindObjectAny(BrName);
+    if (Obj) {
+      LOG(DEBUG2) <<"Object "  
+		  << BrName << " was already activated by another task"
+		  << FairLogger::endl;
+    }
+  }
+  /**if the object does not exist then it could be a memory branch */
+  if(!Obj) {
+    LOG(DEBUG2) << "Try to find if the object "
+		<< BrName << " is a memory branch" << FairLogger::endl;
+    Obj=GetMemoryBranch(BrName);
+    if (Obj) {
+      LOG(DEBUG2) << "Object "
+		  << BrName << " is a memory branch" << FairLogger::endl;
+    }
+  }
+  /**if the object does not exist then look in the input tree */
+  if(fCbmroot && !Obj) {
+    /** there is an input tree and the object was not in memory */
+    LOG(DEBUG2) << "Object "
+		<< BrName << " is not a memory branch and not yet activated, try the Input Tree (Chain)" << FairLogger::endl;
+    Obj=fCbmroot->FindObjectAny(BrName);
+    Obj=ActivateBranch(BrName);
+  }
+  if(!Obj) {
+    Obj=ActivateBranch(BrName);
+  } 
+  if ( Obj!=NULL ) 
+    FairMonitor::GetMonitor()->RecordGetting(BrName);
+  return Obj;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TObject* FairRootManager::GetCloneOfLinkData(const FairLink link)
+{
+  TObject* result = 0;
+
+//  std::cout << "GetCloneOfLinkData: Link " << link << std::endl;
+  Int_t fileId = link.GetFile();
+  Int_t entryNr = link.GetEntry();
+  Int_t type = link.GetType();
+  Int_t index = link.GetIndex();
+
+  Int_t oldEntryNr = GetEntryNr();
+
+//  std::cout << "OldEntryNr: " << GetEntryNr();
+
+//  std::cout << "GetLinkData: " << link << std::endl;
+
+  TTree* dataTree;          //get the correct Tree
+  if (fileId < 0) {
+    dataTree = GetInTree();
+  } else if (fileId == 0) {
+    dataTree = GetInChain();
+  } else {
+    dataTree = GetSignalChainNo(fileId);
+  }
+
+  if (dataTree == 0) {
+    dataTree = GetInTree();
+  }
+
+  if (type < 0) {
+    return 0;
+  }
+
+  TBranch* dataBranch = 0;
+
+//  std::cout << "DataType: " << GetBranchName(type) << std::endl;
+
+  if (fileId < 0 && fInputBranchMap[type] != 0) {
+    dataBranch = fInputBranchMap[type];
+  } else if (fileId < 0) {
+    fInputBranchMap[type] = dataTree->GetBranch(GetBranchName(type));
+    dataBranch = fInputBranchMap[type];
+  } else {
+    dataBranch = dataTree->GetBranch(GetBranchName(type));
+  }
+
+  if (dataBranch == 0) {
+    return 0;
+  }
+
+  if (entryNr > -1) {         //get the right entry (if entryNr < 0 then the current entry is taken
+    if (entryNr < dataBranch->GetEntries()) {
+      dataBranch->GetEntry(entryNr);
+    } else {
+      return 0;
+    }
+  } else {        //the link entry nr is negative --> take the actual one
+
+//    std::cout << "EntryNr: " << GetEntryNr() << std::endl;
+//    dataBranch->GetEntry(GetEntryNr());
+  }
+
+  if (index < 0) {                //if index is -1 then this is not a TClonesArray so only the Object is returned
+    result = GetObject(GetBranchName(type))->Clone();
+  } else {
+    TClonesArray* dataArray = static_cast<TClonesArray*>(GetObject(GetBranchName(type)));
+
+//    std::cout << "dataArray size: " << dataArray->GetEntriesFast() << std::endl;
+    if (index < dataArray->GetEntriesFast()) {
+//      std::cout << "DataArray at index " << index << " has Link: " << ((FairMultiLinkedData*)dataArray->At(index))->GetNLinks() << std::cout;
+      result = dataArray->At(index)->Clone();
+//      std::cout << "Result: " << *((FairMultiLinkedData*)result) << std::endl;
+    }
+  }
+  if (entryNr > -1) {
+    dataBranch->GetEntry(oldEntryNr);  //reset the dataBranch to the original entry
+  }
+  return result;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TClonesArray* FairRootManager::GetCloneOfTClonesArray(const FairLink link)
+{
+  TClonesArray* result = 0;
+
+  //  std::cout << "GetCloneOfLinkData: Link " << link << std::endl;
+  Int_t fileId = link.GetFile();
+  Int_t entryNr = link.GetEntry();
+  Int_t type = link.GetType();
+  Int_t index = link.GetIndex();
+
+  Int_t oldEntryNr = GetEntryNr();
+
+  //  std::cout << "OldEntryNr: " << GetEntryNr();
+
+  //  std::cout << "GetLinkData: " << link << std::endl;
+
+  TTree* dataTree;          //get the correct Tree
+  if (fileId < 0) {
+    dataTree = GetInTree();
+  } else if (fileId == 0) {
+    dataTree = GetInChain();
+  } else {
+    dataTree = GetSignalChainNo(fileId);
+  }
+
+  if (dataTree == 0) {
+    dataTree = GetInTree();
+  }
+
+  if (type < 0) {
+    return 0;
+  }
+
+  TBranch* dataBranch = 0;
+
+  //  std::cout << "DataType: " << GetBranchName(type) << std::endl;
+
+  if (fileId < 0 && fInputBranchMap[type] != 0) {
+    dataBranch = fInputBranchMap[type];
+  } else if (fileId < 0) {
+    fInputBranchMap[type] = dataTree->GetBranch(GetBranchName(type));
+    dataBranch = fInputBranchMap[type];
+  } else {
+    dataBranch = dataTree->GetBranch(GetBranchName(type));
+  }
+
+  if (dataBranch == 0) {
+    return 0;
+  }
+
+  if (entryNr > -1) { //get the right entry (if entryNr < 0 then the current entry is taken
+    if (entryNr < dataBranch->GetEntries()) {
+      dataBranch->GetEntry(entryNr);
+    } else {
+      return 0;
+    }
+  } else {        //the link entry nr is negative --> take the actual one
+
+    //    std::cout << "EntryNr: " << GetEntryNr() << std::endl;
+    //    dataBranch->GetEntry(GetEntryNr());
+  }
+
+  if (index < 0) { //if index is -1 then this is not a TClonesArray so only the Object is returned
+    result = 0;
+  } else {
+    result = static_cast<TClonesArray*>( GetObject(GetBranchName(type))->Clone() );
+  }
+  if (entryNr > -1) {
+    dataBranch->GetEntry(oldEntryNr); //reset the dataBranch to the original entry
+  }
+  return result;
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::TruncateBranchNames(TTree* fTree, const char* folderName)
+{
+  /** If a object is created in a folder the corresponding branch
+  * in the tree is crated with a wrong name.
+  * The name of the branch is created as follows
+  * mainFolder.subFolder.nameOfStoredObject
+  * e.g. cbmroot.Event.ExampleClass.
+  * The name which is wanted is only nameOfStoredObject
+  * e.g. ExampleClass.
+  * This is corrected in this function
+  * If the folder does not exist don't do anything
+  */
+  TFolder* cbm=static_cast<TFolder*>(gROOT->FindObjectAny(folderName));
+  if(cbm) {
+    TCollection* lf=cbm->GetListOfFolders();
+    TIterator* iter= lf->MakeIterator();
+    TObjArray* Br= fTree->GetListOfBranches();
+    TIterator* BrIter= Br->MakeIterator();
+    TObject* obj;
+    TObject* BrObj;
+
+    /** correct branch names in all folders below the main output folder*/
+    while((obj=iter->Next())) {
+
+      /** Create TString with the part of the branch name which should be
+      * removed. This is mainFolderName.folderName. e.g. cbmroot.Event.
+      * This part of the branch name is obsolete, so it is removed from
+      * the branch name.
+      */
+      TString ffn=cbm->GetName();
+      ffn=ffn+".";
+      ffn=ffn+obj->GetName();
+      ffn=ffn+".";
+
+      /** Correct name of all branches and leaves which correspond to
+      * the subfolder. To do so loop over all branches and check
+      * if the branch corresponds with the folder. If it corresponds
+      * correct the branch names of all sub branches.
+      * Only correct branch names for up to now uncorrected branches.
+      */
+      BrIter->Reset();
+
+      while((BrObj=BrIter->Next())) {
+        TBranch* b=static_cast<TBranch*>(BrObj);
+        TruncateBranchNames(b, ffn);
+      }
+    }
+
+    // Remove all occurence of FairMCEventHeader and   from
+    // all branches containing that string.
+    // This is not the correct way to do it, but up tonow we don't understand
+    // why this part comes in when storing a derrived class from
+    // FairMCEventHeader or FairEventHeader.
+
+    iter->Reset();
+    while((obj=iter->Next())) {
+
+      TString ffn=".FairMCEventHeader";
+      BrIter->Reset();
+
+      while((BrObj=BrIter->Next())) {
+        TBranch* b=static_cast<TBranch*>(BrObj);
+        TruncateBranchNames(b, ffn);
+      }
+    }
+
+    iter->Reset();
+    while((obj=iter->Next())) {
+
+      TString ffn=".FairEventHeader";
+      BrIter->Reset();
+
+      while((BrObj=BrIter->Next())) {
+        TBranch* b=static_cast<TBranch*>(BrObj);
+        TruncateBranchNames(b, ffn);
+      }
+    }
+
+    delete  iter;
+    delete  BrIter;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::TruncateBranchNames(TBranch* b, TString ffn)
+{
+  /** Get the branch name from the branch object, remove common
+  *  and wrong part of the name and and set branch name to
+  *  the new corrected name. This has to be done recursivly for
+  *  all subbranches/leaves
+  *  Remove wrong part of branch name
+  */
+  TObject* BrObj;
+  TString nn= b->GetName();
+  //  cout<<"nn.Data before: "<<nn.Data()<<endl;
+  nn.ReplaceAll(ffn.Data(),"");
+  //  cout<<"nn.Data after: "<<nn.Data()<<endl;
+  //  cout <<"##################"<<endl;
+  b->SetName(nn.Data());
+  TObjArray* Br= b->GetListOfBranches();
+  TIterator* BrIter= Br->MakeIterator();
+  BrIter->Reset();
+
+  while((BrObj=BrIter->Next())) {
+    TBranch* bb=static_cast<TBranch*>(BrObj);
+    TruncateBranchNames(bb, ffn);
+  }
+  delete  BrIter;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t FairRootManager::CheckBranch(const char* BrName)
+{
+  /**The first time this method is called the map is generated and then used*/
+  if(!fBranchPerMap) {
+    CreatePerMap();
+    return CheckBranchSt(BrName);
+  } else {
+    fBrPerMapIter=fBrPerMap.find(BrName);
+    if(fBrPerMapIter!=fBrPerMap.end()) {
+      return fBrPerMapIter->second;
+    } else {
+      return 0;
+    }
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairRootManager::SetBranchNameList(TList* list)
+{
+  if ( list == NULL ) return;
+  for(Int_t t=0; t<list->GetEntries(); t++) {
+    fBranchNameList->AddAt(list->At(t),t);
+    fBranchSeqId++;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::SetInChain(TChain* tempChain, Int_t ident)
+{ 
+  if ( ident <= 0 ) 
+    fSourceChain = tempChain;
+  else
+    fSignalChainList[ident] = tempChain;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Double_t FairRootManager::GetEventTime() {
+  return fCurrentTime;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::UpdateBranches() { 
+  for ( Int_t iobj = 0 ; iobj <= fNObj ; iobj++ ) {
+    if ( fObj2[iobj] ) {
+      LOG(INFO) << "FairRootManager::UpdateBranches \"" << fObj2[iobj]->GetName()
+		<< "\" (\"" << fObj2[iobj]->GetTitle() << "\")" << FairLogger::endl;
+      TString tempBranchName = fObj2[iobj]->GetName();
+      fSource->ActivateObject(&fObj2[fNObj],tempBranchName.Data());
+    }
+  }
+
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+/** Private functions*/
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TObject* FairRootManager::ActivateBranch(const char* BrName)
+{
+  /** Set the branch address for a given branch name and return a TObject pointer,
+   the user have to cast this pointer to the right type.
+   The function has been revisited ! Now it test if in the task init() mutilple
+   calls to activate branch is done , and then just forward the pointer.
+   <DB>
+   **/
+  fNObj++;
+  fObj2[fNObj]  =  GetMemoryBranch ( BrName );
+  if ( fObj2[fNObj]   ) {
+    return  fObj2[fNObj];
+  }
+  /**try to find the object decribing the branch in the folder structure in file*/
+  LOG(DEBUG) << "Try to find an object "
+	      << BrName << " describing the branch in the folder structure in file"
+	      << FairLogger::endl;
+  if ( fListFolder ) {
+    for(Int_t i=0; i<fListFolder->GetEntriesFast(); i++) {
+      TFolder* fold = static_cast<TFolder*>(fListFolder->At(i));
+      fObj2[fNObj] = fold->FindObjectAny(BrName);
+      if (fObj2[fNObj] ) {
+	LOG(INFO) << "Object "
+		  << BrName << " describing the branch in the folder structure was found" << FairLogger::endl;
+	break;
+      }
+    }
+  }
+
+  if(!fObj2[fNObj]) {
+    /** if we do not find an object corresponding to the branch in the folder structure
+    *  then we have no idea about what type of object is this and we cannot set the branch address
+    */
+    LOG(INFO) << " Branch: " << BrName << " not found in Tree."
+	      << FairLogger::endl;
+    //Fatal(" No Branch in the tree", BrName );
+    return 0;
+  } else {
+    if ( fSource ) 
+      fSource->ActivateObject(&fObj2[fNObj],BrName);
+  }
+  
+  AddMemoryBranch( BrName , fObj2[fNObj] );
+  return  fObj2[fNObj];
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairRootManager::AddMemoryBranch( const char* fName, TObject* pObj )
+{
+  /**branch will be available ionly in Memory, will not be written to disk */
+  map < TString, TObject*>::iterator p;
+  TString BrName=fName;
+  p=fMap.find(BrName);
+  if(p!=fMap.end()) {
+  } else {
+    fMap.insert(pair<TString, TObject*> (BrName, pObj));
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+
+Int_t FairRootManager::CheckBranchSt(const char* BrName)
+{
+ // cout <<"FairRootManager::CheckBranchSt  :  " << BrName << endl;
+  Int_t returnvalue=0;
+  TObject* Obj1 =NULL;
+    
+  if(fListFolder==0){
+    fListFolder = new TObjArray(16);
+  }
+  
+  //cout <<"FairRootManager::CheckBranchSt  :  " <<fCbmroot << endl;
+  if (fCbmroot) {
+    fListFolder->Add(fCbmroot);
+    Obj1 = fCbmroot->FindObjectAny(BrName);
+  }
+  if(fCbmout && !Obj1) {
+    fListFolder->Add(fCbmout);
+    Obj1 = fCbmout->FindObjectAny(BrName);  //Branch in output folder
+  }
+  if(!Obj1) {
+    for(Int_t i=0; i<fListFolder->GetEntriesFast(); i++) {
+     // cout << "Search in Folder: " << i << "  " <<  fListFolder->At(i) << endl;
+      TFolder* fold = dynamic_cast<TFolder*>(fListFolder->At(i));
+      if(fold!=0) {
+        Obj1= fold->FindObjectAny(BrName);
+      }
+      if (Obj1) {
+        break;
+      }
+    }
+  }
+  TObject* Obj2 =NULL;
+  Obj2=GetMemoryBranch(BrName);  // Branch in Memory
+  if (Obj1!=0) {
+    returnvalue=1;
+  } else if(Obj2!=0) {
+    returnvalue=2;
+  } else {
+    returnvalue= 0;
+  }
+
+  /**  1 : Branch is Persistance
+       2 : Memory Branch
+       0 : Branch does not exist
+  */
+  return returnvalue;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairRootManager::CreatePerMap()
+{
+//   cout << " FairRootManager::CreatePerMap() " << endl;
+  fBranchPerMap=kTRUE;
+  for (Int_t i=0; i<fBranchSeqId; i++) {
+    TObjString* name= static_cast<TObjString*>(fBranchNameList->At(i));
+//    cout << " FairRootManager::CreatePerMap() Obj At " << i << "  is "  << name->GetString() << endl;
+    TString BrName=name->GetString();
+    fBrPerMap.insert(pair<TString, Int_t> (BrName, CheckBranchSt(BrName.Data())));
+  }
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+TObject*  FairRootManager::GetMemoryBranch( const char* fName )
+{
+
+//return fMap[BrName];
+  TString BrName=fName;
+  map < TString, TObject*>::iterator p;
+  p=fMap.find(BrName);
+
+  if(p!=fMap.end()) {
+    return p->second;
+  } else {
+    return 0;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::WriteFileHeader(FairFileHeader* f)
+{
+  fOutFile->cd();
+  f->SetName(fOutFile->GetName());
+  f->Write("FileHeader", TObject::kSingleKey);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+Int_t  FairRootManager::CheckMaxEventNo(Int_t EvtEnd)
+{
+  if ( fSource ) 
+    return fSource->CheckMaxEventNo(EvtEnd);
+  return 0;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairWriteoutBuffer* FairRootManager::RegisterWriteoutBuffer(TString branchName, FairWriteoutBuffer* buffer)
+{
+  if (fWriteoutBufferMap[branchName] == 0) {
+    fWriteoutBufferMap[branchName] = buffer;
+  } else {
+    LOG(WARNING) << "Branch "
+		 << branchName.Data() 
+		 << " is already registered in WriteoutBufferMap"
+		 << FairLogger::endl;
+    delete buffer;
+  }
+  return fWriteoutBufferMap[branchName];
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::UpdateListOfTimebasedBranches()
+{
+  /**
+   * Add branches that are time based to the proper list
+   */
+  
+  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
+    
+    if(iter->second->IsBufferingActivated()) fTimeBasedBranchNameList->AddLast(new TObjString(iter->first.Data()));
+    
+  }
+  
+}
+
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::SetTimeBasedBranchNameList(TList *list)
+{
+  /**
+   * Replace the list
+   */
+  
+  if(list!=0){
+    fTimeBasedBranchNameList->Delete();
+    delete fTimeBasedBranchNameList;
+    fTimeBasedBranchNameList=list;
+  }
+  
+  
+  
+}
+
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairWriteoutBuffer* FairRootManager::GetWriteoutBuffer(TString branchName)
+{
+  if (fWriteoutBufferMap.count(branchName) > 0) {
+    return fWriteoutBufferMap[branchName];
+  } else {
+    return 0;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::StoreWriteoutBufferData(Double_t eventTime)
+{
+  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
+    iter->second->WriteOutData(eventTime);
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::StoreAllWriteoutBufferData()
+{
+  Bool_t dataInBuffer = kFALSE;
+  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
+    if (iter->second->GetNData() > 0) {
+      dataInBuffer = kTRUE;
+    }
+    iter->second->WriteOutAllData();
+  }
+  fFillLastData = dataInBuffer;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRootManager::DeleteOldWriteoutBufferData()
+{
+  for(std::map<TString, FairWriteoutBuffer*>::const_iterator iter = fWriteoutBufferMap.begin(); iter != fWriteoutBufferMap.end(); iter++) {
+    iter->second->DeleteOldData();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+char* FairRootManager::GetTreeName()
+{
+    char* default_name = (char*)"cbmsim";
+    char* workdir = getenv("VMCWORKDIR");
+    if(NULL == workdir)
+    {
+        return default_name;
+    }
+
+    // Open file with output tree name
+    FILE* file = fopen(Form("%s/config/rootmanager.dat",workdir), "r");
+    // If file does not exist -> default
+    if(NULL == file)
+    {
+        return default_name;
+    }
+    // If file is empty -> default
+    char str[100];
+    if(NULL == fgets(str, 100, file))
+    {
+        fclose(file);
+        return default_name;
+    }
+    // If file does not contain treename key -> default
+    char* treename = new char[100];
+    if(1 != sscanf(str, "treename=%s", treename))
+    {
+        fclose(file);
+        delete[] treename;
+        return default_name;
+    }
+    // Close file and return read value
+    fclose(file);
+    return treename;
+}
+//_____________________________________________________________________________
+
+ClassImp(FairRootManager)
+
+
+
+
+
+
+
+
diff --git a/base/FairRootManager.h b/base/steer/FairRootManager.h
similarity index 50%
rename from base/FairRootManager.h
rename to base/steer/FairRootManager.h
index a1ba026..346af45 100644
--- a/base/FairRootManager.h
+++ b/base/steer/FairRootManager.h
@@ -1,35 +1,46 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIR_ROOT_MANAGER_H
 #define FAIR_ROOT_MANAGER_H
 
-#include "TObject.h"
-#include "TString.h"
-#include "TArrayI.h"
-#include "TObjArray.h"
-#include "TFile.h"
-#include "TChain.h"
-#include <map>
-#include <list>
-#include <queue>
+#include "TObject.h"                    // for TObject
 
-class FairGeoNode;
-class FairFileHeader;
-class FairMCEventHeader;
+#include "Rtypes.h"                     // for Bool_t, Int_t, UInt_t, etc
+#include "TChain.h"                     // for TChain
+#include "TFile.h"                      // for TFile
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString, operator<
+#include "TMCtls.h"                     // for multi-threading
+
+#include <stddef.h>                     // for NULL
+#include <list>                         // for list
+#include <map>                          // for map, multimap, etc
+#include <queue>                        // for queue
+#include "FairSource.h"
+class BinaryFunctor;
 class FairEventHeader;
 class FairFileHeader;
+class FairGeoNode;
+class FairLink;
 class FairLogger;
 class FairTSBufferFunctional;
-class BinaryFunctor;
 class FairWriteoutBuffer;
-class FairLink;
+class TArrayI;
+class TBranch;
+class TClonesArray;
 class TCollection;
-class TClonesarray;
+class TF1;
 class TFolder;
-class TTree;
-class TNamed;
-class TBranch;
 class TList;
-class TF1;
-
+class TNamed;
+class TTree;
+class TRefArray;
+class TIterator;
 
 /**
  * I/O Manager class
@@ -47,15 +58,9 @@ class FairRootManager : public TObject
     FairRootManager();
     /**dtor*/
     virtual ~FairRootManager();
-    void                AddSignalFile(TString name, UInt_t identifier );
-    /**Add input background file by name*/
-    void                AddBackgroundFile(TString name);
-    void                AddFile(TString name);
-    void                AddFriend(TString Name);
-    void                AddFriendsToChain();
-
-    Bool_t             AllDataProcessed();
-
+     Bool_t             AllDataProcessed();
+    /** Add a branch name to the Branchlist and give it an id*/
+    Int_t AddBranchToList(const char* name);
     /**
     Check if Branch persistence or not (Memory branch)
     return value:
@@ -64,72 +69,69 @@ class FairRootManager : public TObject
     0 : Branch does not exist   */
     Int_t               CheckBranch(const char* BrName);
 
-    void                CloseInFile() { if(fInFile) { fInFile->Close(); }}
-
+    
     void                CloseOutFile() { if(fOutFile) { fOutFile->Close(); }}
     /**Create a new file and save the current TGeoManager object to it*/
     void                CreateGeometryFile(const char* geofile);
-    Bool_t              DataContainersEmpty();
-    Bool_t              DataContainersFilled();
     void                Fill();
-    void                ForceFill();
     void                LastFill();
-    TClonesArray*       ForceGetDataContainer(TString branchName);
     TClonesArray*       GetEmptyTClonesArray(TString branchName);
     TClonesArray*       GetTClonesArray(TString branchName);
-    TClonesArray*       GetDataContainer(TString branchName);
+    /**Update the list of Memory branches from the source used*/
+    void                UpdateBranches();
+
     /**Return branch name by Id*/
     TString             GetBranchName(Int_t id);
     /**Return Id of a branch named */
     Int_t               GetBranchId(TString BrName);
-    /**Return a TList of TObjString of branch names */
+    /**Return a TList of TObjString of branch names available in this session*/
     TList*              GetBranchNameList() {return fBranchNameList;}
-
-    TTree*              GetInTree() {return fInChain->GetTree();}
-    TChain*             GetInChain() {return fInChain;}
-    TChain*             GetBGChain() { return  fBackgroundChain;}
-    TChain*             GetSignalChainNo(UInt_t i);
+    /** Return a pointer to the output Tree of type TTree */
     TTree*              GetOutTree() {return fOutTree;}
-    TFile*              GetInFile() {return  fInFile;}
+    /** Return a pointer to the output File of type TFile */
     TFile*              GetOutFile() {return  fOutFile;}
     /**  Get the Object (container) for the given branch name,
          this method can be used to access the data of
          a branch that was created from a different
          analysis task, and not written in the tree yet.
-         the user have to cast this pointer to the right type.*/
-    FairGeoNode*        GetGeoParameter(const char* detname, const char* gname);
-    /** Return a pointer to the object (collection) saved in the fInChain branch named BrName*/
+         the user have to cast this pointer to the right type.
+         Return a pointer to the object (collection) saved in the fInChain branch named BrName*/
     TObject*            GetObject(const char* BrName);
     /** Return a pointer to the object (collection) saved in the fInTree branch named BrName*/
-    TObject*            GetObjectFromInTree(const char* BrName);
     Double_t            GetEventTime();
-    TObject*      GetLinkData(const FairLink link);
+    /** Returns a clone of the data object the link is pointing to. The clone has to be deleted in the calling code! */
+    TObject*      GetCloneOfLinkData(const FairLink link);
     /** Get the data of the given branch name,
      *  this method runs over multiple entries
      *  of the tree and selects the data according
      *  to the function and the parameter given.
      */
+
+    TClonesArray* GetCloneOfTClonesArray(const FairLink link);
+
+    void InitTSBuffer(TString branchName, BinaryFunctor* function);
     TClonesArray*     GetData(TString branchName, BinaryFunctor* function, Double_t parameter);
     TClonesArray*     GetData(TString branchName, BinaryFunctor* startFunction, Double_t startParameter, BinaryFunctor* stopFunction, Double_t stopParameter);
     void RegisterTSBuffer(TString branchName, FairTSBufferFunctional* functionalBuffer) {fTSBufferMap[branchName] = functionalBuffer;}
+    void TerminateTSBuffer(TString branchName);
+    void TerminateAllTSBuffer();
     FairTSBufferFunctional*   GetTSBuffer(TString branchName) {return fTSBufferMap[branchName];}
 
     /** static access method */
     static FairRootManager* Instance();
 
-    Bool_t            OpenInChain();
-
-    /** Open and prepare the input tree when running on PROOF worker*/
-    Bool_t            OpenInTree();
-
-    Bool_t            OpenBackgroundChain();
-    Bool_t            OpenSignalChain();
     TFile*            OpenOutFile(const char* fname="cbmsim.root");
     TFile*            OpenOutFile(TFile* f);
     /**Read a single entry from background chain*/
-    void                ReadBKEvent(Int_t i);
-    void              ReadEvent(Int_t i);
+    Int_t             ReadEvent(Int_t i=0);
+    /** Read a single entry from each branch that is not read via TSBuffers*/
+    Int_t             ReadNonTimeBasedEventFromBranches(Int_t i=0);
+    /**Read the tree entry on one branch**/
+    void              ReadBranchEvent(const char* BrName);
     /**Read all entries from input tree(s) with time stamp from current time to dt (time in ns)*/
+
+    Int_t             GetRunId();
+
     Bool_t            ReadNextEvent(Double_t dt);
     /**create a new branch in the output tree
      *@param name            Name of the branch to create
@@ -144,40 +146,23 @@ class FairRootManager : public TObject
     *@param toFile          if kTRUE, branch will be saved to the tree*/
     void                Register(const char* name,const char* Foldername ,TCollection* obj, Bool_t toFile);
 
+    void                RegisterInputObject(const char* name, TObject* obj);
+
     TClonesArray*       Register(TString branchName, TString className, TString folderName, Bool_t toFile);
-    /** Register a new PndWriteoutBuffer to the map. If a Buffer with the same map key already exists the given buffer will be deleted and the old will be returned!*/
+    /** Register a new FairWriteoutBuffer to the map. If a Buffer with the same map key already exists the given buffer will be deleted and the old will be returned!*/
     FairWriteoutBuffer* RegisterWriteoutBuffer(TString branchName, FairWriteoutBuffer* buffer);
+    /**Update the list of time based branches in the output file*/
+    void                UpdateListOfTimebasedBranches();
     /**Use time stamps to read data and not tree entries*/
     void                RunWithTimeStamps() {fTimeStamps = kTRUE;}
 
-    /**Set the input signal file
-     *@param name :        signal file name
-     *@param identifier :  Unsigned integer which identify the signal file
-     */
-    void                  SetSignalFile(TString name, UInt_t identifier );
-    /**Set the input background file by name*/
-    void                  SetBackgroundFile(TString name);
-    /**Add signal file to input
-     *@param name :        signal file name
-     *@param identifier :  Unsigned integer which identify the signal file to which this signal should be added
-     */
-
-    /**Set the status of the EvtHeader
-     *@param Status:  True: The header was creatged in this session and has to be filled
-              FALSE: We use an existing header from previous data level
-     */
-    void                SetEvtHeaderNew(Bool_t Status) {fEvtHeaderIsNew = Status;}
-    Bool_t              IsEvtHeaderNew() {return fEvtHeaderIsNew;}
-
     /**Set the branch name list*/
     void                SetBranchNameList(TList* list);
-    void                SetCompressData(Bool_t val) {fCompressData = val;}
-    /**Set the name of the input file*/
-    void                SetInputFile(TString name);
-
-    /**Set the input tree when running on PROOF worker*/
-    void                SetInTree (TTree*  tempTree)  {fInTree = NULL; fInTree  = tempTree;}
-
+    /** Replace the time based branch name list*/
+    void SetTimeBasedBranchNameList(TList *list);
+  
+    void                FillEventHeader(FairEventHeader* feh) { if ( fSource ) fSource->FillEventHeader(feh); } 
+   
     /**Set the output tree pointer*/
     void                SetOutTree(TTree* fTree) { fOutTree=fTree;}
 
@@ -192,30 +177,13 @@ class FairRootManager : public TObject
     */
     void                TruncateBranchNames(TTree* fTree, const char* folderName);
 
-    void                Write();
+    Int_t               Write(const char* name=0, Int_t option=0, Int_t bufsize=0);
     /** Write the current TGeoManager to file*/
     void                WriteGeometry();
     /**Write the file header object to the output file*/
     void                WriteFileHeader(FairFileHeader* f);
     /**Write the folder structure used to create the tree to the output file */
     void                WriteFolder() ;
-    /** Set the min and max limit for event time in ns */
-    void                SetEventTimeInterval(Double_t min, Double_t max);
-    /** Set the mean time for the event in ns */
-    void                SetEventMeanTime(Double_t mean);
-    void                SetEventTime();
-    void                SetFileHeader(FairFileHeader* f) {fFileHeader =f;}
-
-    /**Set the signal to background ratio in event units
-    *@param background :  Number of background Events for one signal
-    *@param Signalid :    Signal file Id, used when adding (setting) the signal file
-    */
-    void BGWindowWidthNo(UInt_t background, UInt_t Signalid);
-    /**Set the signal to background rate in time units
-    *@param background :  Time of background Events before one signal
-    *@param Signalid :    Signal file Id, used when adding (setting) the signal file
-    */
-    void BGWindowWidthTime(Double_t background, UInt_t Signalid);
 
     /**Check the maximum event number we can run to*/
     Int_t  CheckMaxEventNo(Int_t EvtEnd=0);
@@ -228,6 +196,36 @@ class FairRootManager : public TObject
     Int_t GetEntryNr() {return fEntryNr;}
     void SetEntryNr(Int_t val) {fEntryNr = val;}
 
+    void SetUseFairLinks(Bool_t val) {fUseFairLinks = val;};
+    Bool_t GetUseFairLinks() const {return fUseFairLinks;};
+
+    /**
+     * @param Status : if  true all inputs are mixed, i.e: each read event will take one entry from each input and put
+     * them in one big event and send it to the next step
+     */
+    /* void SetMixAllInputs(Bool_t Status) { */
+    /*    fMixAllInputs=kTRUE; */
+    /* } */
+   
+    
+    /** These methods have been moved to the FairFileSource */
+    void   SetSource(FairSource* tempSource) { fSource = tempSource; }    
+    FairSource* GetSource() { return fSource;}
+    Bool_t InitSource();
+    
+    void                SetListOfFolders(TObjArray* ta){ fListFolder=ta; }
+    TChain*             GetInChain ()                  { return fSourceChain;}
+    TChain*             GetSignalChainNo(UInt_t i)     { return fSignalChainList[i]; }
+    TTree*              GetInTree  ()                  { if ( fSourceChain ) return fSourceChain->GetTree(); return 0; }
+    const TFile*        GetRootFile()                  { if ( fSourceChain ) return fSourceChain->GetFile(); return 0; }
+    TFile*              GetInFile  ()                  { if ( fSourceChain ) return fSourceChain->GetFile(); return 0; }
+    void                SetInChain (TChain* tempChain, Int_t ident=-1);
+    /* /\**Set the input tree when running on PROOF worker*\/ */
+
+    void SetFinishRun(Bool_t val = kTRUE){ fFinishRun = val;}
+    Bool_t FinishRun() {return fFinishRun;}
+
+    static char* GetTreeName();
   private:
     /**private methods*/
     FairRootManager(const FairRootManager&);
@@ -235,12 +233,9 @@ class FairRootManager : public TObject
     /**  Set the branch address for a given branch name and return
         a TObject pointer, the user have to cast this pointer to the right type.*/
     TObject*            ActivateBranch(const char* BrName);
-    TObject*            ActivateBranchInInTree(const char* BrName);
     void                AddFriends( );
     /**Add a branch to memory, it will not be written to the output files*/
     void                AddMemoryBranch(const char*, TObject* );
-    void                AssignTClonesArrays();
-    void                AssignTClonesArray(TString branchName);
     /** Internal Check if Branch persistence or not (Memory branch)
     return value:
     1 : Branch is Persistance
@@ -248,18 +243,15 @@ class FairRootManager : public TObject
     0 : Branch does not exist
     */
     Int_t               CheckBranchSt(const char* BrName);
-    void                CheckFriendChains();
-    Bool_t              CompareBranchList(TFile* fileHandle, TString inputLevel);
-    void                CreateNewFriendChain(TString inputFile, TString inputLevel);
-    /**Create the Map for the branch persistency status  */
+        /**Create the Map for the branch persistency status  */
     void                CreatePerMap();
     TObject*            GetMemoryBranch( const char* );
-    void                GetRunIdInfo(TString fileName, TString inputLevel);
-    void                PrintFriendList();
-    void                SaveAllContainers();
-    /**Read a single entry*/
-    void                ReadMixedEvent(Int_t i);
+ //   void                GetRunIdInfo(TString fileName, TString inputLevel);
+
     FairWriteoutBuffer* GetWriteoutBuffer(TString branchName);
+
+
+    Int_t       fOldEntryNr;
 //_____________________________________________________________________
     /**private Members*/
     /**folder structure of output*/
@@ -268,40 +260,38 @@ class FairRootManager : public TObject
     TFolder*                            fCbmroot;
     /** current time in ns*/
     Double_t                            fCurrentTime;
-    /**Input file */
-    TFile*                              fInFile;
-    /**Input Chain */
-    TChain*                             fInChain;
-    /**Input Tree */
-    TTree*                              fInTree;
     /**Output file */
     TFile*                              fOutFile;
     /**Output tree */
     TTree*                              fOutTree;
-    /** list of folders from all input (and friends) files*/
-    TObjArray                           fListFolder; //!
     TObject**                           fObj2; //!
+    /** Counter for the number of branches activiated */
     Int_t                               fNObj;//!
+    /** A list which hold the pointer to the branch 
+     * and the name of the branch in memory, it contains all branches (TClonesArrays)
+     * persistance and Memory only branches
+     */
     std::map < TString , TObject* >     fMap;  //!
-    TTree*                              fPtrTree;//!
-    Int_t                               fCurrentEntries;//!
+
     /**Singleton instance*/
-    static FairRootManager*             fgInstance;
+#if !defined(__CINT__)
+    static TMCThreadLocal FairRootManager*  fgInstance;
+#else
+    static                FairRootManager*  fgInstance;
+#endif
+
     /**Branch id for this run */
     Int_t                               fBranchSeqId;
     /**List of branch names as TObjString*/
     TList*                               fBranchNameList; //!
-    /** Internally used to compress empty slots in data buffer*/
-    std::map<TString, std::queue<TClonesArray*> > fDataContainer;
+    /**List of Time based branchs names as TObjString*/
+    TList*                               fTimeBasedBranchNameList; //!
     /** Internally used to compress empty slots in data buffer*/
     std::map<TString, TClonesArray*> fActiveContainer;
     /** Internally used to read time ordered data from branches*/
     std::map<TString, FairTSBufferFunctional*> fTSBufferMap; //!
     std::map<TString, FairWriteoutBuffer* > fWriteoutBufferMap; //!
     std::map<Int_t, TBranch*> fInputBranchMap; //!    //Map of input branch ID with TBranch pointer
-
-    /** if kTRUE the entries of a branch are filled from the beginning --> no empty entries*/
-    Bool_t                              fCompressData;
     /**if kTRUE Read data according to time and not entries*/
     Bool_t                              fTimeStamps;
     /**Flag for creation of Map for branch persistency list  */
@@ -310,78 +300,36 @@ class FairRootManager : public TObject
     std::map < TString , Int_t >        fBrPerMap; //!
     /**Iterator for the fBrPerMap  Map*/
     std::map < TString, Int_t>::iterator     fBrPerMapIter;
-    /** List of all files added with AddFriend */
-    std::list<TString>                      fFriendFileList; //!
-
-    TString                             fInputFileName; //!
-    std::list<TString>                  fInputChainList;//!
-    std::map<TString, TChain*>          fFriendTypeList;//!
-
-    std::map<TString, std::list<TString>* > fCheckInputBranches; //!
-    std::list<TString>                      fInputLevel; //!
-    std::map<TString, std::multimap<TString, TArrayI> > fRunIdInfoAll; //!
-
-    FairLogger*                         fLogger;//!
-    /**True if signal and background mixing is used*/
-    Bool_t                              fMixedInput;//!
-    /**Actual identifier of the added signals, this is used to identify how many signals are added*/
-    UInt_t                              fActualSignalIdentifier; //!
-    /** Total number of signals added (Types and not files!)*/
-    UInt_t                              fNoOfSignals; //!
-    /** list of chains which has to be created for the different signals*/
-    std::list<TString>*                  fSignalChainList; //!
-    /**Chain containing the background*/
-    TChain*                              fBackgroundChain; //!
-    TFile*                               fBackgroundFile; //!
-    std::map<UInt_t, TChain*>            fSignalTypeList;//!
-
-    /** min time for one event (ns) */
-    Double_t                                fEventTimeMin;  //!
-    /** max time for one Event (ns) */
-    Double_t                                fEventTimeMax;  //!
-    /** Time of event since th start (ns) */
-    Double_t                                fEventTime;     //!
-    /** EventMean time used (P(t)=1/fEventMeanTime*Exp(-t/fEventMeanTime) */
-    Double_t                                fEventMeanTime; //!
-    /** used to generate random numbers for event time; */
-    TF1*                                    fTimeProb;      //!
-    /** MC Event header */
-    FairMCEventHeader*                      fMCHeader; //!
-
-    /**Event Header*/
-    FairEventHeader*                        fEvtHeader; //!
-
-    /**File Header*/
-    FairFileHeader*                        fFileHeader; //!
-
-    /**holds the SB ratio by number*/
-    std::map<UInt_t, Double_t>              fSignalBGN;//!
-    /** This is true if the event time used, came from simulation*/
-    Bool_t                                  fEventTimeInMCHeader; //!
-    /**True for background window in entry units*/
-    Bool_t                                  fSBRatiobyN;  //!
-    /**True for background window in time units (ns) */
-    Bool_t                                  fSBRatiobyT;  //!
+ 
     /** for internal use, to return the same event time for the same entry*/
     UInt_t                                  fCurrentEntryNo; //!
     /** for internal use, to return the same event time for the same entry*/
     UInt_t                                  fTimeforEntryNo; //!
-    /**No of entries in BG Chain*/
-    UInt_t                                  fNoOfBGEntries; //!
-    /**Hold the current entry for each input chain*/
-    std::map<UInt_t, UInt_t>                fCurrentEntry; //!
-    /**This flag is true if the event header was created in this session
-    * otherwise it is false which means the header was created in a previous data
-    * level and used here (e.g. in the digi)
-    */
-    Bool_t      fEvtHeaderIsNew; //!
     Bool_t  fFillLastData; //!
     Int_t fEntryNr; //!
 
+    TObjArray                           *fListFolder; //!
 
-    ClassDef(FairRootManager,7) // Root IO manager
-};
+    FairSource                          *fSource;
 
+    TChain                              *fSourceChain;
+    std::map<UInt_t, TChain*>            fSignalChainList;//!
+
+    FairEventHeader                     *fEventHeader;
+    
+    Bool_t fUseFairLinks; //!
+    Bool_t fFinishRun; //!
+    /** List of branches from input Chain or Tree*/
+    TObjArray* fListOfBranchesFromInput; //!
+    /** Iterator for the list of branches from input Chain or Tree */
+    TIterator* fListOfBranchesFromInputIter;//!
+    /** List of branches used with no-time stamp in time-based session */
+    TRefArray* fListOfNonTimebasedBranches; //!
+    /** Iterator for the list of branches used with no-time stamp in time-based session */
+    TIterator* fListOfNonTimebasedBranchesIter; //!
+
+    ClassDef(FairRootManager,11) // Root IO manager
+};
 
 
 #endif //FAIR_ROOT_MANAGER_H   
diff --git a/base/FairRun.cxx b/base/steer/FairRun.cxx
similarity index 54%
rename from base/FairRun.cxx
rename to base/steer/FairRun.cxx
index deeb247..b007bb8 100644
--- a/base/FairRun.cxx
+++ b/base/steer/FairRun.cxx
@@ -1,50 +1,70 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                   FairRun source file                         -----
 // -----            Created 06/01/04  by M. Al-Turany                  -----
 // -------------------------------------------------------------------------
 
-
 #include "FairRun.h"
-#include "FairTask.h"
-#include "FairRootManager.h"
-#include "FairRuntimeDb.h"
-#include "FairEventHeader.h"
-#include "FairFileHeader.h"
-#include <iostream>
+
+#include "FairEventHeader.h"            // for FairEventHeader
+#include "FairFileHeader.h"             // for FairFileHeader
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairTask.h"                   // for FairTask
+#include "FairLinkManager.h"            // for FairLinkManager
+
+#include "TFile.h"                      // for TFile
+#include "TList.h"                      // for TList
+#include "TObject.h"                    // for TObject
+
+#include <stddef.h>                     // for NULL
+
 //_____________________________________________________________________________
-FairRun* FairRun::fRunInstance= 0;
+TMCThreadLocal FairRun* FairRun::fRunInstance= 0;
 //_____________________________________________________________________________
 FairRun* FairRun::Instance()
 {
   return fRunInstance;
 }
 //_____________________________________________________________________________
-FairRun::FairRun()
+FairRun::FairRun(Bool_t isMaster)
   :TNamed(),
    fNTasks(0),
-   fLogger(FairLogger::GetLogger()),
    fRtdb(FairRuntimeDb::instance()),
    fTask(new FairTask("FairTaskList")),
    fOutname(""),
-   fRootManager(new FairRootManager()),
+   fRootManager(0),
    fOutFile(0),
    fRunId(0),
    fAna(kFALSE),
-   fEvHead(NULL),
+   fEvtHeader(NULL),
    fFileHeader(new FairFileHeader()),
-   fWriteRunInfo(kTRUE)
+   fGenerateRunInfo(kFALSE),
+   fIsMaster(isMaster),
+   fMarkFill(kTRUE)
 {
   if (fRunInstance) {
     Fatal("FairRun", "Singleton instance already exists.");
     return;
   }
   fRunInstance=this;
-  fRootManager->SetFileHeader(fFileHeader);
+
+  if ( isMaster ) {
+    fRootManager = new FairRootManager();
+  }
+  new FairLinkManager();
 }
 //_____________________________________________________________________________
 FairRun::~FairRun()
 {
-  fLogger->Debug(MESSAGE_ORIGIN," Enter Destructor of FairRun ");
+  LOG(DEBUG) << "Enter Destructor of FairRun" << FairLogger::endl;
   if (fTask) {
     delete fTask;  // There is another tasklist in MCApplication,
   }
@@ -56,9 +76,10 @@ FairRun::~FairRun()
     delete fRootManager; // who is responsible
     fRootManager=0;
   }
-  if (fEvHead) {
-    delete fEvHead;
+  if (fEvtHeader) {
+    delete fEvtHeader;
   }
+  LOG(DEBUG) << "Leave Destructor of FairRun" << FairLogger::endl;
 }
 //_____________________________________________________________________________
 
@@ -66,7 +87,7 @@ FairRun::~FairRun()
 void FairRun::SetOutputFile(const char* fname)
 {
   fOutname=fname;
-  fOutFile = fRootManager->OpenOutFile(fOutname);
+  if (fRootManager) fOutFile = fRootManager->OpenOutFile(fOutname);
 
 }
 //_____________________________________________________________________________
@@ -74,6 +95,8 @@ void FairRun::SetOutputFile(const char* fname)
 //_____________________________________________________________________________
 void FairRun::SetOutputFile(TFile* f)
 {
+  if (! fRootManager) return;
+
   fOutname=f->GetName();
   fRootManager->OpenOutFile(f);
   fOutFile = f;
@@ -110,12 +133,36 @@ FairTask* FairRun::GetTask(const char* taskName)
 //_____________________________________________________________________________
 FairEventHeader*  FairRun::GetEventHeader()
 {
-  if ( NULL == fEvHead ) {
-    fEvHead = new FairEventHeader();
+  if ( NULL == fEvtHeader ) {
+    fEvtHeader = new FairEventHeader();
   }
-  return fEvHead;
+  return fEvtHeader;
+}
+
+void FairRun::SetUseFairLinks(Bool_t val)
+{
+        fRootManager->SetUseFairLinks(val);
 }
+
 //_____________________________________________________________________________
+void FairRun::SetWriteRunInfoFile(Bool_t write)
+{
+  LOG(WARNING) << "Function FairRun::SetWriteRunInfoFile(Bool_t) is depcrecated and will vanish in future versions of FairRoot.\n";
+  LOG(WARNING) << "Please use FairRun::SetGenerateRunInfo(Bool_t) instead." << FairLogger::endl;
+
+  fGenerateRunInfo = write;
+}
+
+Bool_t FairRun::GetWriteRunInfoFile()
+{
+  LOG(WARNING) << "Function FairRun::GetWriteRunInfoFile() is depcrecated and will vanish in future versions of FairRoot.\n";
+  LOG(WARNING) << "Please use FairRun::IsRunInfoGenerated() instead." << FairLogger::endl;
+
+  return fGenerateRunInfo;
+}
+
+
+
 ClassImp(FairRun)
 
 
diff --git a/base/FairRun.h b/base/steer/FairRun.h
similarity index 57%
rename from base/FairRun.h
rename to base/steer/FairRun.h
index b145ebf..5e71176 100644
--- a/base/FairRun.h
+++ b/base/steer/FairRun.h
@@ -1,14 +1,25 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRRUN_H
 #define FAIRRUN_H
 
-#include "TNamed.h"
-#include "FairLogger.h"
-class FairTask;
-class TFile;
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TMCtls.h"                     // for multi-threading
+
+class FairEventHeader;
 class FairFileHeader;
-class FairRuntimeDb;
 class FairRootManager;
-class FairEventHeader;
+class FairRuntimeDb;
+class FairTask;
+class TFile;
+class FairField;
 
 /**
  * Configure the Simuation or Analysis
@@ -23,7 +34,7 @@ class FairRun : public TNamed
     /**
      * default ctor
      */
-    FairRun();
+    FairRun(Bool_t isMaster = kTRUE);
     /**
     * default dtor
     */
@@ -41,24 +52,28 @@ class FairRun : public TNamed
      * Initialize the Simulation or analysis
      */
     virtual void    Init()=0;
+    /*
+     * Get the magnetic field *
+     */
+    virtual FairField*  GetField()=0;
     /**
-     * run the analysis or simulation
-    */
+      * run the analysis or simulation
+     */
     virtual void    Run(Int_t NStart =0,Int_t NStop=0)=0;
     /**
      * Set the output file name for analysis or simulation
     */
-    void        SetOutputFile(const char* fname);
+    virtual void    SetOutputFile(const char* fname);
     /**
      * Set the output file for analysis or simulation
     */
-    void        SetOutputFile(TFile* f);
+    virtual void    SetOutputFile(TFile* f);
     /**
      *       Set the experiment dependent run header
      *       for each run
      */
     void        SetEventHeader(FairEventHeader* EvHeader)  {
-      fEvHead=EvHeader;
+      fEvtHeader=EvHeader;
     }
     /**
      * return a pointer to the RuntimeDB
@@ -76,9 +91,17 @@ class FairRun : public TNamed
      * return the run ID for the actul run
      */
     Int_t  GetRunId() {
-      return ((Int_t) fRunId);
+      return (static_cast<Int_t>(fRunId));
     }
 
+	/** 
+     * Set the Run ID
+	 */
+    void SetRunId(UInt_t runId)
+	{
+	  fRunId = runId; 
+    }    
+
     /**Get the detector specific run header*/
     FairEventHeader*  GetEventHeader();
     /**
@@ -109,10 +132,26 @@ class FairRun : public TNamed
     void CreateGeometryFile(const char* geofile);
 
     //** Set if RunInfo file should be written */
-    void SetWriteRunInfoFile(Bool_t write) { fWriteRunInfo = write;}
+    void SetWriteRunInfoFile(Bool_t write);
+
+    //** Set if RunInfo should be generated */
+    void SetGenerateRunInfo(Bool_t write) { fGenerateRunInfo = write;}
+
+    //** Get info if RunInfo file is written */
+    Bool_t GetWriteRunInfoFile();
 
     //** Get info if RunInfo file is written */
-    Bool_t GetWriteRunInfoFile() { return fWriteRunInfo;}
+    Bool_t IsRunInfoGenerated() { return fGenerateRunInfo;}
+
+    //** Switches the use of FairLinks */
+    void SetUseFairLinks(Bool_t val);
+
+    //** Get info if run on master */
+    Bool_t GetIsMaster() const { return fIsMaster;}
+
+    //** Mark/Unmark event to be filled into output. Default is TRUE. */
+    void MarkFill(Bool_t flag) { fMarkFill = flag; }
+
 
   private:
     FairRun(const FairRun& M);
@@ -123,10 +162,12 @@ class FairRun : public TNamed
     Int_t fNTasks;
 
   protected:
-    /** Fair Logger */
-    FairLogger*             fLogger;//!
     /** static pointer to this run*/
-    static FairRun*          fRunInstance;
+#if !defined(__CINT__)
+    static TMCThreadLocal FairRun* fRunInstance;
+#else
+    static                FairRun* fRunInstance;
+#endif
     /** RuntimeDb*/
     FairRuntimeDb*           fRtdb;
     /** Tasks used*/
@@ -142,12 +183,16 @@ class FairRun : public TNamed
     /** true for Anaylsis session*/
     Bool_t                   fAna;  //!
     /** MC Event Header */
-    FairEventHeader*         fEvHead; //!
+    FairEventHeader*         fEvtHeader; //!
     /** File  Header */
     FairFileHeader*          fFileHeader;
     /** true if RunInfo file should be written*/
-    Bool_t                   fWriteRunInfo;  //!
+    Bool_t                   fGenerateRunInfo;  //!
+    /** true if on master*/
+    Bool_t                   fIsMaster;  //!
+
+    Bool_t                   fMarkFill; //!
 
-    ClassDef(FairRun ,1)
+    ClassDef(FairRun ,4)
 };
 #endif //FAIRRUN_H
diff --git a/base/steer/FairRunAna.cxx b/base/steer/FairRunAna.cxx
new file mode 100644
index 0000000..98080db
--- /dev/null
+++ b/base/steer/FairRunAna.cxx
@@ -0,0 +1,917 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                   FairRunAna source file                      -----
+// -----            Created 06/01/04  by M. Al-Turany                  -----
+// -------------------------------------------------------------------------
+
+#include "FairRunAna.h"
+
+#include "FairBaseParSet.h"             // for FairBaseParSet
+#include "FairGeoParSet.h"              // for FairGeoParSet
+#include "FairEventHeader.h"            // for FairEventHeader
+#include "FairField.h"                  // for FairField
+#include "FairFieldFactory.h"           // for FairFieldFactory
+#include "FairFileHeader.h"             // for FairFileHeader
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairParIo.h"                  // for FairParIo
+#include "FairParSet.h"                 // for FairParSet
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRunIdGenerator.h"         // for FairRunIdGenerator
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairTask.h"                   // for FairTask
+#include "FairTrajFilter.h"             // for FairTrajFilter
+
+#include "FairFileSource.h"             // ONLY TEMPORARILY, FOR COMPABILITY
+#include "FairMixedSource.h"            // ONLY TEMPORARILY, FOR COMPABILITY
+
+#include "RVersion.h"                   // for ROOT_VERSION, etc
+#include "Riosfwd.h"                    // for ostream
+#include "TChain.h"                     // for TChain
+#include "TCollection.h"                // for TIter
+#include "TDirectory.h"                 // for TDirectory, gDirectory
+#include "TFile.h"                      // for TFile, gFile
+#include "TGeoManager.h"                // for gGeoManager, TGeoManager
+#include "TKey.h"                       // for TKey
+#include "TList.h"                      // for TList
+#include "TNamed.h"                     // for TNamed
+#include "TObjArray.h"                  // for TObjArray
+#include "TObject.h"                    // for TObject
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TSeqCollection.h"             // for TSeqCollection
+#include "TSystem.h"                    // for TSystem, gSystem
+#include "TTree.h"                      // for TTree
+
+#include <stdlib.h>                     // for NULL, exit
+#include "signal.h"
+#include <string.h>                     // for strcmp
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <list>                         // for list
+
+using std::cout;
+using std::endl;
+using std::list;
+
+Bool_t gFRAIsInterrupted;
+
+//_____________________________________________________________________________
+void FRA_handler_ctrlc(int)
+{
+  LOG(INFO) << "*********** CTRL C PRESSED *************" << FairLogger::endl;
+  gFRAIsInterrupted = kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRunAna* FairRunAna::fgRinstance= 0;
+//_____________________________________________________________________________
+FairRunAna* FairRunAna::Instance()
+{
+
+  return fgRinstance;
+}
+//_____________________________________________________________________________
+FairRunAna::FairRunAna()
+  :FairRun(),
+   fRunInfo(),
+   fIsInitialized(kFALSE),
+   fInputGeoFile(0),
+   fLoadGeo( kFALSE),
+   fStatic(kFALSE),
+   fField(0),
+   fTimeStamps(kFALSE),
+   fInFileIsOpen(kFALSE),
+   fEventTimeMin(0),
+   fEventTimeMax(0),
+   fEventTime(0),
+   fEventMeanTime(0),
+   fTimeProb(0),
+   fFinishProcessingLMDFile(kFALSE)
+  ,fFileSource(0)
+  ,fMixedSource(0)
+{
+
+  fgRinstance=this;
+  fAna=kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRunAna::~FairRunAna()
+{
+  //  delete fFriendFileList;
+  if (fField) {
+    delete fField;
+  }
+  if (gGeoManager) {
+    delete gGeoManager;
+  }
+}
+
+//_____________________________________________________________________________
+
+void  FairRunAna::SetGeomFile(const char* GeoFileName)
+{
+  if (fIsInitialized) {
+    LOG(FATAL) << "Geometry file has to be set before Run::Init !" 
+	       << FairLogger::endl;
+    exit(-1);
+  } else {
+
+    TFile* CurrentFile=gFile;
+    fInputGeoFile= new TFile(GeoFileName);
+    if (fInputGeoFile->IsZombie()) {
+      LOG(ERROR) << "Error opening Geometry Input file"
+		 << FairLogger::endl;
+      fInputGeoFile=0;
+    }
+    LOG(INFO) << "Opening Geometry input file: " << GeoFileName
+	      << FairLogger::endl;
+    fLoadGeo=kTRUE;
+    gFile=CurrentFile;
+  }
+}
+
+//_____________________________________________________________________________
+
+void FairRunAna::Init()
+{
+
+  if (fIsInitialized) {
+    LOG(FATAL) << "Error Init is already called before!" << FairLogger::endl;
+    exit(-1);
+  } else {
+    fIsInitialized=kTRUE;
+  }
+  fRtdb= GetRuntimeDb();
+
+  // Check if we have an input file to be used
+  fInFileIsOpen = fRootManager->InitSource();
+
+ //Load Geometry from user file
+  if (fLoadGeo) {
+    if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
+      TIter next(fInputGeoFile->GetListOfKeys());
+      TKey* key;
+      while ((key =dynamic_cast< TKey*>(next()))) {
+        if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
+          continue;
+        }
+        gGeoManager = dynamic_cast<TGeoManager*>(key->ReadObj());
+        break;
+      }
+    }
+  } else {
+    /*** Get the container that normly has the geometry and all the basic stuff from simulation*/
+    fRtdb->getContainer("FairGeoParSet");
+  }
+
+  if (fInFileIsOpen) {
+    //check that the geometry was loaded if not try all connected files!
+    if (fLoadGeo && gGeoManager==0) {
+      LOG(INFO) << "Geometry was not found in the input file we will look in the friends if any!" << FairLogger::endl;
+      TFile* currentfile= gFile;
+      TFile* nextfile=0;
+      TSeqCollection* fileList=gROOT->GetListOfFiles();
+      for (Int_t k=0; k<fileList->GetEntries(); k++) {
+        nextfile=dynamic_cast<TFile*>(fileList->At(k));
+        if (nextfile) {
+          nextfile->Get("FAIRGeom");
+        }
+        if (gGeoManager) {
+          break;
+        }
+      }
+      gFile=currentfile;
+    }
+  } else { //  if(fInputFile )
+    // NO input file but there is a geometry file
+    if (fLoadGeo) {
+      if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
+        TIter next(fInputGeoFile->GetListOfKeys());
+        TKey* key;
+        while ((key = dynamic_cast<TKey*>(next()))) {
+          if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
+            continue;
+          }
+          gGeoManager = dynamic_cast<TGeoManager*>(key->ReadObj());
+          break;
+        }
+      }
+    }
+  }
+ 
+  gROOT->GetListOfBrowsables()->Add(fTask);
+
+  // Init the RTDB containers
+
+  FairBaseParSet* par=dynamic_cast<FairBaseParSet*>(fRtdb->getContainer("FairBaseParSet"));
+
+
+  /**Set the IO Manager to run with time stamps*/
+  if (fTimeStamps) {
+    fRootManager->RunWithTimeStamps();
+  }
+
+
+
+  // Assure that basic info is there for the run
+  //  if(par && fInputFile) {
+  if (par && fInFileIsOpen) {
+
+    LOG(INFO) << "Parameter and input file are available, Assure that basic info is there for the run!" << FairLogger::endl;
+    fRootManager->ReadEvent(0);
+
+//    fEvtHeader = GetEventHeader();
+    GetEventHeader();
+    
+    fRootManager->FillEventHeader(fEvtHeader);
+    
+    fRunId = fEvtHeader->GetRunId();
+
+    //Copy the Event Header Info to Output
+    fEvtHeader->Register();
+
+    // Init the containers in Tasks
+
+    fRtdb->initContainers(fRunId);
+    fTask->SetParTask();
+    
+    //fRtdb->initContainers( fRunId );
+    
+  } else {  //end----- if(fMixedInput)
+    LOG(INFO) << "Initializing without input file or Mixed input"
+	      << FairLogger::endl;
+    FairEventHeader* evt = GetEventHeader();
+    evt->Register();
+    FairRunIdGenerator genid;
+    fRunId = genid.generateId();
+    fRtdb->addRun(fRunId);
+    evt->SetRunId( fRunId);
+    fTask->SetParTask();
+    fRtdb->initContainers( fRunId );
+
+  }
+  FairFieldFactory* fieldfact= FairFieldFactory::Instance();
+  if (fieldfact) {
+    fieldfact->SetParm();
+  }
+
+  fRtdb->initContainers(fRunId);
+  fFileHeader->SetRunId(fRunId);
+
+  // create a field
+  // <DB>
+  // Add test for external FairField settings
+  if (fieldfact && !fField) {
+    fField= fieldfact->createFairField();
+  }
+  // Now call the User initialize for Tasks
+  fTask->InitTask();
+  // if the vis manager is available then initialize it!
+  FairTrajFilter* fTrajFilter = FairTrajFilter::Instance();
+  if (fTrajFilter) {
+    fTrajFilter->Init();
+  }
+  // Create a list of time based branches (if any).
+  
+  fRootManager->UpdateListOfTimebasedBranches();
+  
+  // create the output tree after tasks initialisation
+  fOutFile->cd();
+  TTree* outTree =new TTree(FairRootManager::GetTreeName(), "/cbmout", 99);
+  fRootManager->TruncateBranchNames(outTree, "cbmout");
+  fRootManager->SetOutTree(outTree);
+  fRootManager->WriteFolder();
+  fRootManager->WriteFileHeader(fFileHeader);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAna::Run(Int_t Ev_start, Int_t Ev_end)
+{
+  gFRAIsInterrupted = kFALSE;
+
+  if (fTimeStamps) {
+    RunTSBuffers();
+  } else {
+    UInt_t tmpId =0;
+    //  if (fInputFile==0) {
+    if (!fInFileIsOpen) {
+      DummyRun(Ev_start,Ev_end);
+      return;
+    }
+
+   Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
+    if ( MaxAllowed != -1 ) {
+      if (Ev_end==0) {
+        if (Ev_start==0) {
+          Ev_end=MaxAllowed;
+        } else {
+          Ev_end =  Ev_start;
+          if ( Ev_end > MaxAllowed ) {
+            Ev_end = MaxAllowed;
+          }
+          Ev_start=0;
+        }
+      } else {
+        if (Ev_end > MaxAllowed) {
+          cout << "-------------------Warning---------------------------" << endl;
+          cout << " -W FairRunAna : File has less events than requested!!" << endl;
+          cout << " File contains : " << MaxAllowed  << " Events" << endl;
+          cout << " Requested number of events = " <<  Ev_end <<  " Events"<< endl;
+          cout << " The number of events is set to " << MaxAllowed << " Events"<< endl;
+          cout << "-----------------------------------------------------" << endl;
+          Ev_end = MaxAllowed;
+        }
+      }
+      LOG(INFO) << "FairRunAna::Run() After checking, the run will run from event " << Ev_start << " to " << Ev_end << "." << FairLogger::endl;
+    }
+    else {
+      LOG(INFO) << "FairRunAna::Run() continue running without stop" << FairLogger::endl;
+    }
+    
+    if (fGenerateRunInfo) {
+      fRunInfo.Reset();
+    }
+
+    Int_t readEventReturn = 0;
+
+    for (int i=Ev_start; i< Ev_end || MaxAllowed==-1 ; i++) {
+      
+      gSystem->IgnoreInterrupt();
+      //  gFRAIsInterrupted = kFALSE;
+      signal(SIGINT, FRA_handler_ctrlc);
+      
+      if ( gFRAIsInterrupted ) {
+        LOG(WARNING) << "FairRunAna::Run() Event loop was interrupted by the user!" << FairLogger::endl;
+        break;
+      }
+      
+      readEventReturn = fRootManager->ReadEvent(i);
+
+      if ( readEventReturn != 0 ) {
+        LOG(WARNING) << "FairRunAna::Run() fRootManager->ReadEvent(" << i << ") returned " << readEventReturn << ". Breaking the event loop" << FairLogger::endl;
+        break;
+      }
+      
+      fRootManager->FillEventHeader(fEvtHeader);
+
+      tmpId = fEvtHeader->GetRunId();
+      if ( tmpId != fRunId ) {
+        fRunId = tmpId;
+        if ( !fStatic ) {
+          Reinit( fRunId );
+          fTask->ReInitTask();
+        }
+      }
+      //std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime();
+      fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
+      fTask->ExecuteTask("");
+      Fill();
+      fRootManager->DeleteOldWriteoutBufferData();
+      fTask->FinishEvent();
+
+      if (fGenerateRunInfo) {
+        fRunInfo.StoreInfo();
+      }
+      if (NULL !=  FairTrajFilter::Instance()) {
+        FairTrajFilter::Instance()->Reset();
+      }
+
+    }
+
+    fRootManager->StoreAllWriteoutBufferData();
+    fTask->FinishTask();
+    if (fGenerateRunInfo) {
+      fRunInfo.WriteInfo();
+    }
+    fRootManager->LastFill();
+    fRootManager->Write();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAna::RunEventReco(Int_t Ev_start, Int_t Ev_end)
+{
+  UInt_t tmpId =0;
+
+  Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
+  if ( MaxAllowed != -1 ) {
+    if (Ev_end==0) {
+      if (Ev_start==0) {
+	Ev_end=MaxAllowed;
+      } else {
+	Ev_end =  Ev_start;
+	if ( Ev_end > MaxAllowed ) {
+	  Ev_end = MaxAllowed;
+	}
+	Ev_start=0;
+      }
+    } else {
+      if (Ev_end > MaxAllowed) {
+	cout << "-------------------Warning---------------------------" << endl;
+	cout << " -W FairRunAna : File has less events than requested!!" << endl;
+	cout << " File contains : " << MaxAllowed  << " Events" << endl;
+	cout << " Requested number of events = " <<  Ev_end <<  " Events"<< endl;
+	cout << " The number of events is set to " << MaxAllowed << " Events"<< endl;
+	cout << "-----------------------------------------------------" << endl;
+	Ev_end = MaxAllowed;
+      }
+    }
+    LOG(INFO) << "FairRunAna::Run() After checking, the run will run from event " << Ev_start << " to " << Ev_end << "." << FairLogger::endl;
+  }
+  else {
+    LOG(INFO) << "FairRunAna::Run() continue running without stop" << FairLogger::endl;
+  }
+  
+  if (fGenerateRunInfo) {
+    fRunInfo.Reset();
+  }
+
+  for (int i=Ev_start; i< Ev_end; i++) {
+    fRootManager->ReadEvent(i);
+    /**
+     * if we have simulation files then they have MC Event Header and the Run Id is in it, any way it
+     * would be better to make FairMCEventHeader a subclass of FairEvtHeader.
+     */
+    if ( tmpId != fRunId ) {
+      fRunId = tmpId;
+      if ( !fStatic ) {
+        Reinit( fRunId );
+        fTask->ReInitTask();
+      }
+    }
+    //FairMCEventHeader* header = dynamic_cast<FairMCEventHeader*>(fRootManager->GetObject("MCEventHeader.");
+    //    std::cout << "WriteoutBufferData with time: " << fRootManager->GetEventTime();
+    fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
+    fTask->ExecuteTask("");
+
+    fRootManager->FillEventHeader(fEvtHeader);
+    // Fill();
+    fTask->FinishEvent();
+
+    if (fGenerateRunInfo) {
+      fRunInfo.StoreInfo();
+    }
+    if (NULL !=  FairTrajFilter::Instance()) {
+      FairTrajFilter::Instance()->Reset();
+    }
+
+  }
+
+  fTask->FinishTask();
+  if (fGenerateRunInfo) {
+    fRunInfo.WriteInfo();
+  }
+  fRootManager->LastFill();
+  fRootManager->Write();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAna::Run(Double_t delta_t)
+{
+  while (fRootManager->ReadNextEvent(delta_t)==kTRUE) {
+    fTask->ExecuteTask("");
+    fRootManager->FillEventHeader(fEvtHeader);
+    Fill();
+    fRootManager->DeleteOldWriteoutBufferData();
+    fTask->FinishEvent();
+    if (NULL !=  FairTrajFilter::Instance()) {
+      FairTrajFilter::Instance()->Reset();
+    }
+  }
+
+  fRootManager->StoreAllWriteoutBufferData();
+  fTask->FinishTask();
+  fRootManager->LastFill();
+  fRootManager->Write();
+
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunAna::RunMQ(Long64_t entry)
+{
+  /**
+   This methode is only needed and used with ZeroMQ
+   it read a certain event and call the task exec, but no output is written
+   */
+  UInt_t tmpId =0;
+  fRootManager->ReadEvent(entry);
+  tmpId = fEvtHeader->GetRunId();
+  if ( tmpId != fRunId ) {
+    fRunId = tmpId;
+    if ( !fStatic ) {
+      Reinit( fRunId );
+      fTask->ReInitTask();
+    }
+  }
+  fTask->ExecuteTask("");
+  fRootManager->FillEventHeader(fEvtHeader);
+  fTask->FinishTask();
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunAna::Run(Long64_t entry)
+{
+  UInt_t tmpId =0;
+  fRootManager->ReadEvent(entry);
+  tmpId = fEvtHeader->GetRunId();
+  if ( tmpId != fRunId ) {
+    fRunId = tmpId;
+    if ( !fStatic ) {
+      Reinit( fRunId );
+      fTask->ReInitTask();
+    }
+  }
+  fTask->ExecuteTask("");
+  fRootManager->FillEventHeader(fEvtHeader);
+  fTask->FinishTask();
+  Fill();
+  fRootManager->DeleteOldWriteoutBufferData();
+  fRootManager->LastFill();
+  fRootManager->Write();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAna::RunTSBuffers()
+{
+  Int_t globalEvent = 0;
+
+  bool firstRun = true;
+  while (firstRun || fRootManager->AllDataProcessed() == kFALSE) {
+    firstRun = false;
+    if (globalEvent < fRootManager->CheckMaxEventNo(0) ) { //this step is necessary to load in all data which is not read in via TSBuffers
+      fRootManager->ReadNonTimeBasedEventFromBranches(globalEvent++);
+    }
+    fTask->ExecuteTask("");
+    fRootManager->FillEventHeader(fEvtHeader);
+    Fill();
+    fRootManager->DeleteOldWriteoutBufferData();
+    fTask->FinishEvent();
+    if (NULL !=  FairTrajFilter::Instance()) {
+      FairTrajFilter::Instance()->Reset();
+    }
+  }
+  fRootManager->StoreAllWriteoutBufferData();
+  fTask->FinishTask();
+  fRootManager->LastFill();
+  fRootManager->Write();
+}
+//_____________________________________________________________________________
+//_____________________________________________________________________________
+
+void FairRunAna::RunOnLmdFiles(UInt_t NStart, UInt_t NStop)
+{
+  if(NStart==0 && NStop==0) {
+    NStart=0;
+    NStop=1000000000;
+    LOG(INFO) << " Maximum number of event is set to 1E9" << FairLogger::endl;
+  }
+  for (UInt_t i=NStart; i< NStop; i++) {
+    if ( fFinishProcessingLMDFile ) {
+      i = NStop; ///Same result like break
+
+    }
+
+    fTask->ExecuteTask("");
+    fRootManager->FillEventHeader(fEvtHeader);
+    Fill();
+  }
+
+  fTask->FinishTask();
+  fRootManager->Write();
+
+}
+//_____________________________________________________________________________
+void FairRunAna::RunOnTBData() {
+      std::cout << "FairRunAna::RunOnTBData " << std::endl;
+        while (fRootManager->FinishRun() != kTRUE) {
+		fTask->ExecuteTask("");
+            Fill();
+            fTask->FinishEvent();
+        }
+
+        fTask->FinishTask();
+        fRootManager->LastFill();
+        fRootManager->Write();
+}
+//_____________________________________________________________________________
+void FairRunAna::DummyRun(Int_t Ev_start, Int_t Ev_end)
+{
+
+  /** This methode is just for testing, if you are not sure about what you do, don't use it */
+  for (int i=Ev_start; i< Ev_end; i++) {
+    fTask->ExecuteTask("");
+    fRootManager->FillEventHeader(fEvtHeader);
+    Fill();
+  }
+  fTask->FinishTask();
+  fRootManager->Write();
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAna::TerminateRun()
+{
+  fRootManager->StoreAllWriteoutBufferData();
+  fTask->FinishTask();
+  gDirectory->SetName(fRootManager->GetOutFile()->GetName());
+  //  fRunInfo.WriteInfo(); // CRASHES due to file ownership i guess...
+  //   cout << ">>> SlaveTerminate fRootManager->GetInChain()->Print()" << endl;
+  //   fRootManager->GetInChain()->Print();
+  //   cout << ">>>------------------------------------------------<<<" << endl;
+  fRootManager->LastFill();
+  fRootManager->Write();
+  fRootManager->CloseOutFile();
+}
+//_____________________________________________________________________________
+
+void FairRunAna::Reinit(UInt_t runId)
+{
+  // reinit procedure
+  fRtdb->initContainers( runId );
+}
+//_____________________________________________________________________________
+
+void  FairRunAna::RunWithTimeStamps()
+{
+  if (ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)) {
+    if (fIsInitialized) {
+      LOG(WARNING) << "RunWithTimeStamps has to be set before Run::Init !" << FairLogger::endl;
+      exit(-1);
+    } else {
+      fTimeStamps=kTRUE;
+      fRootManager->RunWithTimeStamps();
+    }
+  } else {
+    LOG(FATAL) << "RunWithTimeStamps need at least ROOT version 5.29.1" << FairLogger::endl;
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void  FairRunAna::SetContainerStatic(Bool_t tempBool)
+{
+  fStatic=tempBool;
+  if ( fStatic ) {
+    LOG(INFO) << "Parameter Cont. initialisation is static" << FairLogger::endl;
+  } else {
+    LOG(INFO) << "Parameter Cont. initialisation is NOT static" << FairLogger::endl;
+  }
+}
+
+// BELOW FUNCTIONS SHOULD BE DELETED AND MOVED TO FairFileSource ONLY
+//_____________________________________________________________________________
+void FairRunAna::SetInputFile(TString name)
+{
+  LOG(WARNING) << "FairRunAna::SetInputFile is obsolete. Set it by FairFileSource" << FairLogger::endl;
+  if ( fMixedSource ) 
+    { 
+      LOG(ERROR) << "Mixed input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fFileSource ) 
+    {
+      fFileSource = new FairFileSource(name);
+      SetSource(fFileSource);
+      return;
+    }
+  fFileSource->SetInputFile(name);
+}
+//_____________________________________________________________________________
+void FairRunAna::AddFriend (TString name)
+{
+  LOG(WARNING) << "FairRunAna::AddFriend is obsolete. Set it by FairFileSource" << FairLogger::endl;
+  if ( fMixedSource ) 
+    { 
+      LOG(ERROR) << "Mixed input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fFileSource ) 
+    {
+      LOG(ERROR) << "Input file not yet set!" << FairLogger::endl;
+      return;
+    }
+  fFileSource->AddFriend(name);
+}
+//_____________________________________________________________________________
+void FairRunAna::AddFile(TString name)
+{
+  LOG(WARNING) << "FairRunAna::AddFile is obsolete. Set it by FairFileSource" << FairLogger::endl;
+  if ( fMixedSource ) 
+    { 
+      LOG(ERROR) << "Mixed input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fFileSource ) 
+    {
+      LOG(ERROR) << "Input file not yet set!" << FairLogger::endl;
+      return;
+    }
+  fFileSource->AddFile(name);
+}
+//_____________________________________________________________________________
+// ABOVE FUNCTIONS SHOULD BE DELETED AND MOVED TO FairFileSource ONLY
+
+// BELOW FUNCTIONS SHOULD BE DELETED AND MOVED TO FairMixedSource ONLY
+//_____________________________________________________________________________
+void FairRunAna::SetSignalFile(TString name, UInt_t identifier )
+{
+  LOG(WARNING) << "FairRunAna::SetSignalFile is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if (identifier==0) {
+    LOG(FATAL) << " ----- Identifier 0 is reserved for background files! please use other value ------ " << FairLogger::endl;
+  }
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      fMixedSource = new FairMixedSource(name,identifier);
+      SetSource(fMixedSource);
+      return;
+    }
+  fMixedSource->AddSignalFile(name, identifier);
+}
+//_____________________________________________________________________________
+void FairRunAna::AddSignalFile(TString name, UInt_t identifier )
+{
+  LOG(WARNING) << "FairRunAna::AddSignalFile is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if (identifier==0) {
+    LOG(FATAL) << " ----- Identifier 0 is reserved for background files! please use other value ------ " << FairLogger::endl;
+  }
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      fMixedSource = new FairMixedSource(name,identifier);
+      SetSource(fMixedSource);
+      return;
+    }
+  fMixedSource->AddSignalFile(name, identifier);
+}
+//_____________________________________________________________________________
+void FairRunAna::SetBackgroundFile(TString name)
+{
+  LOG(WARNING) << "FairRunAna::SetBackgroundFile is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      fMixedSource = new FairMixedSource(name,0);
+      SetSource(fMixedSource);
+      return;
+    }
+  fMixedSource->SetBackgroundFile(name);
+}
+//_____________________________________________________________________________
+void FairRunAna::AddBackgroundFile(TString name)
+{
+  LOG(WARNING) << "FairRunAna::AddBackgroundFile is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      LOG(ERROR) << "Background file not yet set!" << FairLogger::endl;
+      return;
+    }
+  fMixedSource->AddBackgroundFile(name);
+}
+//_____________________________________________________________________________
+void  FairRunAna::BGWindowWidthNo(UInt_t background, UInt_t Signalid)
+{
+  LOG(WARNING) << "FairRunAna::BGWindowWidthNo is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      LOG(ERROR) << "Background file not yet set!" << FairLogger::endl;
+      return;
+    }
+  fMixedSource->BGWindowWidthNo(background, Signalid);
+}
+//_____________________________________________________________________________
+void  FairRunAna::BGWindowWidthTime(Double_t background, UInt_t Signalid)
+{
+  LOG(WARNING) << "FairRunAna::BGWindowWidthTime is obsolete. Set it by FairMixedSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      LOG(ERROR) << "Standard input already set!" << FairLogger::endl; 
+      return;
+    }
+  if ( !fMixedSource ) 
+    {
+      LOG(ERROR) << "Background file not yet set!" << FairLogger::endl;
+      return;
+    }
+  fMixedSource->BGWindowWidthTime(background, Signalid);
+}
+//_____________________________________________________________________________
+// ABOVE FUNCTIONS SHOULD BE DELETED AND MOVED TO FairMixedSource ONLY
+
+// BELOW FUNCTIONS SHOULD BE DELETED AND MOVED TO FairFileSource AND FairMixedSource ONLY
+//_____________________________________________________________________________
+void FairRunAna::SetEventTimeInterval(Double_t min, Double_t max)
+{
+  LOG(WARNING) << "FairRunAna::SetEventTimeInterval is obsolete. Set it by FairSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      fFileSource->SetEventTimeInterval(min,max);
+      return;
+    }
+  if ( fMixedSource ) 
+    {
+      fMixedSource->SetEventTimeInterval(min,max);
+      return;
+    }
+  LOG(ERROR) << "SetEventTimeInterval only by input source!" << FairLogger::endl; 
+}
+//_____________________________________________________________________________
+void  FairRunAna::SetEventMeanTime(Double_t mean)
+{
+  LOG(WARNING) << "FairRunAna::SetEventMeanTime is obsolete. Set it by FairSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      fFileSource->SetEventMeanTime(mean);
+      return;
+    }
+  if ( fMixedSource ) 
+    {
+      fMixedSource->SetEventMeanTime(mean);
+      return;
+    }
+  LOG(ERROR) << "SetEventMeanTime only by input source!" << FairLogger::endl; 
+}
+//_____________________________________________________________________________
+void FairRunAna::SetBeamTime(Double_t beamTime, Double_t gapTime)
+{
+  LOG(WARNING) << "FairRunAna::SetBeamTime is obsolete. Set it by FairSource" << FairLogger::endl;
+  if ( fFileSource ) 
+    { 
+      fFileSource->SetBeamTime(beamTime, gapTime);
+      return;
+    }
+  if ( fMixedSource ) 
+    {
+      fMixedSource->SetBeamTime(beamTime, gapTime);
+      return;
+    }
+  LOG(ERROR) << "SetBeamTime only by input source!" << FairLogger::endl; 
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunAna::Fill()
+{
+  if(fMarkFill)
+  {
+    fRootManager->Fill();
+  }
+  else
+  {
+    fMarkFill = kTRUE;
+  }
+}
+//_____________________________________________________________________________
+
+
+// void  FairRunAna::SetMixAllInputs(Bool_t Status)
+// {
+//    fLogger->Info(MESSAGE_ORIGIN, "Mixing for all input is choosed, in this mode one event per input file is read per step");
+//    fRootManager->SetMixAllInputs(Status);
+// }
+//_____________________________________________________________________________
+// ABOVE FUNCTIONS SHOULD BE DELETED AND MOVED TO FairFileSource AND FairMixedSource ONLY
+
+
+ClassImp(FairRunAna)
+
+
diff --git a/base/FairRunAna.h b/base/steer/FairRunAna.h
similarity index 63%
rename from base/FairRunAna.h
rename to base/steer/FairRunAna.h
index 5593d26..6d32423 100644
--- a/base/FairRunAna.h
+++ b/base/steer/FairRunAna.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRRUNANA_H
 #define FAIRRUNANA_H
 
@@ -9,23 +16,22 @@
  * @since 28.02.05
  */
 
-#include "FairRun.h"
-#include "FairRunInfo.h"
-#include "FairRootManager.h"
+#include "FairRun.h"                    // for FairRun
 
-#include "TProof.h"
-#include "TString.h"
-#include <iostream>
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRunInfo.h"                // for FairRunInfo
+
+#include "Rtypes.h"                     // for Bool_t, Double_t, UInt_t, etc
+#include "TString.h"                    // for TString
 
-class FairRuntimeDb;
-class FairEventHeader;
-class FairMCEventHeader;
 class FairField;
-class TFile;
-class FairLogger;
 class TF1;
+class TFile;
 class TTree;
 
+class FairFileSource;
+class FairMixedSource;
+
 class FairRunAna : public FairRun
 {
 
@@ -34,50 +40,86 @@ class FairRunAna : public FairRun
     static FairRunAna* Instance();
     virtual ~FairRunAna();
     FairRunAna();
-    FairRunAna(const char* type, const char* proofName="");
-    /** Add a friend file (input) by name)*/
-    void        AddFriend(TString fName);
     /**initialize the run manager*/
     void        Init();
     /**Run from event number NStart to event number NStop */
-    void        Run(Int_t NStart ,Int_t NStop);
+    void        Run(Int_t NStart=0 ,Int_t NStop=0);
     /**Run over the whole input file with timpe window delta_t as unit (entry)*/
     void        Run(Double_t delta_t);
     /**Run for the given single entry*/
     void        Run(Long64_t entry);
-    /**Run for one event, used on PROOF nodes*/
-    void        RunOneEvent(Long64_t entry);
-    /**Run from event number NStart to event number NStop over mixed input files */
-    void        RunMixed(Int_t NStart, Int_t NStop);
+    /**Run event reconstruction from event number NStart to event number NStop */
+    void        RunEventReco(Int_t NStart ,Int_t NStop);
     /**Run over all TSBuffers until the data is processed*/
     void        RunTSBuffers();
     /** the dummy run does not check the evt header or the parameters!! */
     void        DummyRun(Int_t NStart ,Int_t NStop);
-    /** run on proof from event NStart to event NStop*/
-    void        RunOnProof(Int_t NStart, Int_t NStop);
+    /** This methode is only needed and used with ZeroMQ
+      * it read a certain event and call the task exec, but no output is written
+      * @param entry : entry number in the tree
+      */
+    void RunMQ(Long64_t entry);
     /** Run on a list of lmd files*/
     void        RunOnLmdFiles(UInt_t NStart=0, UInt_t NStop=0);
+
+    void RunOnTBData();
     /** finish tasks, write output*/
     void        TerminateRun();
     /**Set the input signal file
      *@param name :        signal file name
      *@param identifier :  Unsigned integer which identify the signal file
      */
+
+    virtual void   SetSource(FairSource* tempSource) { fRootManager->SetSource(tempSource); }
+
+    // ********************************************************* //
+    // THE BELOW FUNCTIONS SHOULD BE MOVED TO FairFileSource
+    /**Set the input file by name*/
+    void        SetInputFile(TString fname);
+    /**Add a file to input chain */
+    void        AddFile(TString name);
+    /** Add a friend file (input) by name)*/
+    void        AddFriend(TString fName);
+    // ********************************************************* //
+    // THE BELOW FUNCTIONS SHOULD BE MOVED TO FairMixedSource
     void        SetSignalFile(TString name, UInt_t identifier );
-    /**Set the input background file by name*/
-    void        SetBackgroundFile(TString name);
-    /**Add input background file by name*/
-    void        AddBackgroundFile(TString name);
     /**Add signal file to input
      *@param name :        signal file name
      *@param identifier :  Unsigned integer which identify the signal file to which this signal should be added
      */
     void        AddSignalFile(TString name, UInt_t identifier );
-    /**Set the input file by name*/
-    void        SetInputFile(TString fname);
-    /**Add a file to input chain */
-    void        AddFile(TString name);
-
+    /**Set the input background file by name*/
+    void        SetBackgroundFile(TString name);
+    /**Add input background file by name*/
+    void        AddBackgroundFile(TString name);
+    /**Set the signal to background ratio in event units
+     *@param background :  Number of background Events for one signal
+     *@param Signalid :    Signal file Id, used when adding (setting) the signal file
+     * here we just forward the call to the FairRootManager
+     */
+    void BGWindowWidthNo(UInt_t background, UInt_t Signalid);
+    /**Set the signal to background rate in time units
+     *@param background :  Time of background Events before one signal
+     *@param Signalid :    Signal file Id, used when adding (setting) the signal file
+     * here we just forward the call to the FairRootManager
+     */
+    void BGWindowWidthTime(Double_t background, UInt_t Signalid);
+    /**
+     * This method will simply forward the call to the FairRootManager, 
+     * if  true all inputs are mixed, i.e: each read event will take one entry from each input and put
+     * them in one big event and send it to the next step
+    */
+    //    void SetMixAllInputs(Bool_t Status);
+    // ********************************************************* //
+    // THE BELOW FUNCTIONS SHOULD BE MOVED TO FairFileSource and FairMixedSource
+    /** Set the min and max limit for event time in ns */
+    void SetEventTimeInterval(Double_t min, Double_t max);
+    /** Set the mean time for the event in ns */
+    void SetEventMeanTime(Double_t mean);
+    /** Set the time intervall the beam is interacting and the gap in ns */
+    void SetBeamTime(Double_t beamTime, Double_t gapTime);
+    // ********************************************************* //
+ 
     void        Reinit(UInt_t runId);
     UInt_t      getRunId() {
       return fRunId;
@@ -100,60 +142,12 @@ class FairRunAna : public FairRun
      *  is not checked anymore after initialization
      */
 
-    /** Init containers executed on PROOF, which is part of Init when running locally*/
-    void        InitContainers();
-
-    /** set the input tree of fRootManager when running on PROOF worker*/
-    void        SetInTree (TTree* tempTree)   {
-      fRootManager->SetInTree (tempTree);
-    }
-
     void        SetContainerStatic(Bool_t tempBool=kTRUE);
     Bool_t      GetContainerStatic() { return fStatic; };
     void        RunWithTimeStamps();
     Bool_t      IsTimeStamp() {
       return fTimeStamps;
     }
-    void        CompressData();
-
-    /** Set the min and max limit for event time in ns */
-    void SetEventTimeInterval(Double_t min, Double_t max);
-
-    /** Set the mean time for the event in ns */
-    void SetEventMeanTime(Double_t mean);
-
-    /**Set the signal to background ratio in event units
-     *@param background :  Number of background Events for one signal
-     *@param Signalid :    Signal file Id, used when adding (setting) the signal file
-     * here we just forward the call to the FairRootManager
-     */
-    void BGWindowWidthNo(UInt_t background, UInt_t Signalid);
-    /**Set the signal to background rate in time units
-     *@param background :  Time of background Events before one signal
-     *@param Signalid :    Signal file Id, used when adding (setting) the signal file
-     * here we just forward the call to the FairRootManager
-     */
-    void BGWindowWidthTime(Double_t background, UInt_t Signalid);
-
-    /** GetProof */
-    TProof* GetProof() { return fProof;}
-
-    /** To be set to kTRUE only when running on PROOF worker, only by TSelector */
-    void SetRunOnProofWorker(Bool_t tb = kTRUE) {
-      fRunOnProofWorker = tb;
-    }
-    /** Set PROOF ARchive (PAR) file name*/
-    void SetProofParName(TString parName) {
-      fProofParName = parName;
-    }
-    /** Set directory for storing output files*/
-    void SetOutputDirectory(TString dirName) {
-      fOutputDirectory = dirName;
-    }
-    /** Set PROOF output status, possibilities: "copy","merge","dataset"*/
-    void SetProofOutputStatus(TString outStat) {
-      fProofOutputStatus = outStat;
-    }
 
     /** Set the flag for proccessing lmd files */
     void StopProcessingLMD( void ) {
@@ -164,7 +158,13 @@ class FairRunAna : public FairRun
       return fFinishProcessingLMDFile;
     }
 
-
+  protected:
+    /**
+     * Virtual function which calls the Fill function of the IOManager.
+     * Allows to override the function with an experiment specific version.
+    **/
+    virtual void Fill();
+                                               
   private:
 
     FairRunAna(const FairRunAna& M);
@@ -180,15 +180,11 @@ class FairRunAna : public FairRun
     TFile*                                  fInputGeoFile;
     static FairRunAna*                      fgRinstance;
     Bool_t                                  fLoadGeo;
-    FairEventHeader*                        fEvtHeader;//!
-    FairMCEventHeader*                      fMCHeader;//!
     /** true for static initialisation of parameters */
     Bool_t                                  fStatic;//!
     FairField*                              fField;
     Bool_t                                  fTimeStamps;
     Bool_t                                  fInFileIsOpen;//!
-    /**True if signal and background mixing is used*/
-    Bool_t                                  fMixedInput;//!
     /** min time for one event (ns) */
     Double_t                                fEventTimeMin;  //!
     /** max time for one Event (ns) */
@@ -199,24 +195,15 @@ class FairRunAna : public FairRun
     Double_t                                fEventMeanTime; //!
     /** used to generate random numbers for event time; */
     TF1*                                    fTimeProb;      //!
-    /** PROOF **/
-    TProof*                                 fProof;
-    /** flag indicating running in PROOF mode*/
-    Bool_t                                  fProofAnalysis; //!
-    /** executing on PROOF worker*/
-    Bool_t                                  fRunOnProofWorker; //!
-    /** PROOF server name*/
-    TString                                 fProofServerName; //!
-    /** PROOF ARchive (PAR) file name*/
-    TString                                 fProofParName; //!
-    /** Output directory*/
-    TString                                 fOutputDirectory; //!
-    /** Output status indicator: "copy","merge","dataset"*/
-    TString                                  fProofOutputStatus;
     /** Flag for proccessing lmd-files*/
-    Bool_t                                   fFinishProcessingLMDFile;  //!
+    Bool_t                                  fFinishProcessingLMDFile;  //!
+
+    /** Temporary member to preserve old functionality without setting source in macro */
+    FairFileSource*                         fFileSource;  //! 
+    /** Temporary member to preserve old functionality without setting source in macro */
+    FairMixedSource*                        fMixedSource; //! 
 
-    ClassDef(FairRunAna ,4)
+    ClassDef(FairRunAna ,6)
 
 };
 
diff --git a/base/steer/FairRunAnaProof.cxx b/base/steer/FairRunAnaProof.cxx
new file mode 100644
index 0000000..c59a27f
--- /dev/null
+++ b/base/steer/FairRunAnaProof.cxx
@@ -0,0 +1,434 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                   FairRunAnaProof source file                 -----
+// -----            Created 30/04/13  by R. Karabowicz                 -----
+// -------------------------------------------------------------------------
+
+#include "FairRunAnaProof.h"
+
+// #include "FairRootManager.h"
+#include "FairTask.h"
+#include "FairBaseParSet.h"
+#include "FairGeoParSet.h"
+#include "FairEventHeader.h"
+#include "FairFieldFactory.h"
+#include "FairRuntimeDb.h"
+#include "FairTrajFilter.h"
+#include "FairRunIdGenerator.h"
+#include "FairLogger.h"
+#include "FairFileHeader.h"
+#include "FairMCEventHeader.h"
+#include "FairParIo.h"
+#include "FairAnaSelector.h"
+
+#include "TROOT.h"
+// #include "TTree.h"
+// #include "TSeqCollection.h"
+#include "TGeoManager.h"
+#include "TKey.h"
+// #include "TF1.h"
+// #include "TSystem.h"
+#include "TProof.h"
+#include "TProofOutputFile.h"
+
+//_____________________________________________________________________________
+FairRunAnaProof* FairRunAnaProof::fRAPInstance= 0;
+//_____________________________________________________________________________
+FairRunAnaProof* FairRunAnaProof::Instance()
+{
+
+  return fRAPInstance;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRunAnaProof::FairRunAnaProof(const char* proofName)
+  :FairRunAna(),
+   fProof(NULL),
+   fRunOnProofWorker(kFALSE),
+   fProofServerName(proofName),
+   fProofParName("$VMCWORKDIR/gconfig/libFairRoot.par"),
+   fOutputDirectory(""),
+   fProofOutputStatus("copy"),
+   fProofFileSource(0)
+{
+  if ( strcmp(proofName,"RunOnProofWorker") == 0 ) {
+    fRunOnProofWorker = kTRUE;
+  }
+  else {
+    LOG(INFO) << "+++++++ T P R O O F +++++++++++++++++++++++++++++++++" << FairLogger::endl;
+    LOG(INFO) << "creating TProof* proof = TProof::Open(\"" << fProofServerName.Data()
+	 << "\");" << FairLogger::endl;
+    TProof::AddEnvVar("LOCALDATASERVER","file://");
+    //    TProof* proof = TProof::Open("lite:///?workers=1");
+    fProof = TProof::Open(fProofServerName.Data());
+    LOG(INFO) << "+++++++ C R E A T E D +++++++++++++++++++++++++++++++" << FairLogger::endl;
+  }
+
+  fRAPInstance=this;
+  fAna=kTRUE;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRunAnaProof::~FairRunAnaProof()
+{
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::Init()
+{
+  fInFileIsOpen = fRootManager->InitSource();
+
+  if (fIsInitialized) {
+    LOG(FATAL) << "Error Init is already called before!"
+	       << FairLogger::endl;
+    exit(-1);
+  } else {
+    fIsInitialized=kTRUE;
+  }
+
+  if ( !fRunOnProofWorker ) {
+    // Open the input file and add other input files added by AddFile to the
+    // input chain. Do a check if the added files are of the same type
+    // as the the input file. Same type means check if they contain the
+    // same branch.
+  }
+  //Load Geometry from user file
+
+  if (fLoadGeo) {
+    if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
+      TIter next(fInputGeoFile->GetListOfKeys());
+      TKey* key;
+      while ((key = static_cast<TKey*>(next()))) {
+        if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
+          continue;
+        }
+        gGeoManager = static_cast<TGeoManager*>(key->ReadObj());
+        break;
+      }
+    }
+  } else {
+//    FairGeoParSet* geopar=dynamic_cast<FairGeoParSet*>(fRtdb->getContainer("FairGeoParSet"));
+    fRtdb->getContainer("FairGeoParSet");
+  }
+
+  if (fInFileIsOpen) {
+    if ( fRunOnProofWorker ) {
+      if (fLoadGeo && gGeoManager==0) {
+        fProofFileSource->GetInTree()->GetCurrentFile()->Get("FAIRGeom");
+      }
+    } else {
+
+      // Add all friend files defined by AddFriend to the correct chain
+      if (fLoadGeo && gGeoManager==0) {
+        // Check if the geometry in the first file of the Chain
+        fProofFileSource->GetInTree()->GetCurrentFile()->Get("FAIRGeom");
+      }
+      //check that the geometry was loaded if not try all connected files!
+      if (fLoadGeo && gGeoManager==0) {
+        LOG(INFO) << "Geometry was not found in the input file we will look in the friends if any!" << FairLogger::endl;
+        TFile* currentfile= gFile;
+        TFile* nextfile=0;
+        TSeqCollection* fileList=gROOT->GetListOfFiles();
+        for (Int_t k=0; k<fileList->GetEntries(); k++) {
+          nextfile=static_cast<TFile*>(fileList->At(k));
+          if (nextfile) {
+            nextfile->Get("FAIRGeom");
+          }
+          if (gGeoManager) {
+            break;
+          }
+        }
+        gFile=currentfile;
+      }
+    }
+  } else { //  if(fInputFile )
+    // NO input file but there is a geometry file
+    if (fLoadGeo) {
+      if (fInputGeoFile!=0) { //First check if the user has a separate Geo file!
+        TIter next(fInputGeoFile->GetListOfKeys());
+        TKey* key;
+        while ((key = static_cast<TKey*>(next()))) {
+          if (strcmp(key->GetClassName(),"TGeoManager") != 0) {
+            continue;
+          }
+          gGeoManager = static_cast<TGeoManager*>(key->ReadObj());
+          break;
+        }
+      }
+    }
+  }
+  //Init the Chain ptr
+  //  fcurrent = fChainList.begin();
+// fOutFile = fRootManager->OpenOutFile(fOutname);
+
+  if ( !fRunOnProofWorker ) {
+    LOG(WARNING) << "QUITTING, CAUSE IT'S not running on proof worker" << FairLogger::endl;
+    return;
+  }
+  gROOT->GetListOfBrowsables()->Add(fTask);
+
+  // Init the RTDB containers
+  fRtdb= GetRuntimeDb();
+  FairBaseParSet* par=static_cast<FairBaseParSet*>
+                      (fRtdb->getContainer("FairBaseParSet"));
+
+  /**Set the IO Manager to run with time stamps*/
+  if (fTimeStamps) {
+    fRootManager->RunWithTimeStamps();
+  }
+
+
+
+  // Assure that basic info is there for the run
+
+  if (par && fInFileIsOpen) {
+
+    LOG(INFO) << "Parameter and input file are available, Assure that basic info is there for the run!" << FairLogger::endl;
+    fRootManager->ReadEvent(0);
+
+    fEvtHeader = static_cast<FairEventHeader*>(fRootManager->GetObject("EventHeader."));
+
+    if (fEvtHeader ==0) {
+      fEvtHeader=GetEventHeader();
+      fEvtHeader->SetRunId(fRunId);
+      //      fRootManager->SetEvtHeaderNew(kTRUE);
+    } else {
+      fRunId = fEvtHeader->GetRunId();
+    }
+
+    //Copy the Event Header Info to Output
+    fEvtHeader->Register();
+
+    // Init the containers in Tasks
+
+    fRtdb->initContainers(fRunId);
+    fTask->SetParTask();
+
+    fRtdb->initContainers( fRunId );
+    if (gGeoManager==0) {
+
+    }
+    //  fRootManager->SetBranchNameList(par->GetBranchNameList());
+    
+  } else {
+    LOG(INFO) << "Initializing without input file or Mixed input"
+	      << FairLogger::endl;
+    FairEventHeader* evt = GetEventHeader();
+    evt->Register();
+    FairRunIdGenerator genid;
+    fRunId = genid.generateId();
+    fRtdb->addRun(fRunId);
+    evt->SetRunId( fRunId);
+    fTask->SetParTask();
+    fRtdb->initContainers( fRunId );
+
+  }
+  FairFieldFactory* fieldfact= FairFieldFactory::Instance();
+  if (fieldfact) {
+    fieldfact->SetParm();
+  }
+
+  fRtdb->initContainers(fRunId);
+  fFileHeader->SetRunId(fRunId);
+
+  // create a field
+  // <DB>
+  // Add test for external FairField settings
+  if (fieldfact && !fField) {
+    fField= fieldfact->createFairField();
+  }
+  // Now call the User initialize for Tasks
+  fTask->InitTask();
+  // if the vis manager is available then initialize it!
+  FairTrajFilter* fTrajFilter = FairTrajFilter::Instance();
+  if (fTrajFilter) {
+    fTrajFilter->Init();
+  }
+
+  // create the output tree after tasks initialisation
+  fOutFile->cd();
+  TTree* outTree =new TTree(FairRootManager::GetTreeName(), "/cbmout", 99);
+  fRootManager->TruncateBranchNames(outTree, "cbmout");
+  fRootManager->SetOutTree(outTree);
+  fRootManager->WriteFolder();
+  fRootManager->WriteFileHeader(fFileHeader);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::InitContainers()
+{
+  fRtdb= GetRuntimeDb();
+  FairBaseParSet* par=dynamic_cast<FairBaseParSet*>
+                      (fRtdb->getContainer("FairBaseParSet"));
+
+  if (par && fInFileIsOpen) {
+    fRootManager->ReadEvent(0);
+
+    fEvtHeader = dynamic_cast<FairEventHeader*>(fRootManager->GetObject("EventHeader."));
+
+    if (NULL == fEvtHeader) LOG(FATAL) << "Could not read event header." << FairLogger::endl;
+
+    fRootManager->FillEventHeader(fEvtHeader);
+
+    fRunId = fEvtHeader->GetRunId();
+
+    //Copy the Event Header Info to Output
+    fEvtHeader->Register();
+
+    // Init the containers in Tasks
+    fRtdb->initContainers(fRunId);
+    fTask->ReInitTask();
+    //    fTask->SetParTask();
+    fRtdb->initContainers( fRunId );
+    if (gGeoManager==0) {
+      //   par->GetGeometry();
+    }
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::SetSource(FairSource* tempSource) {
+  // FairRunAnaProof should accept only FairFileSource
+  if (strncmp(tempSource->GetName(), "FairFileSource", 14) != 0) {
+    LOG(WARNING) << "FairRunAnaProof. Seems you are trying to set different source than FairFileSource" << FairLogger::endl;
+  }
+  fRootManager->SetSource(tempSource);
+  fProofFileSource = static_cast<FairFileSource*>(tempSource);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::Run(Int_t Ev_start, Int_t Ev_end)
+{
+  RunOnProof(Ev_start,Ev_end);
+  return;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::RunOneEvent(Long64_t entry)
+{
+  if (fTimeStamps) {
+    RunTSBuffers();
+  } else {
+    UInt_t tmpId =0;
+    fRootManager->ReadEvent(entry);
+
+    fRootManager->FillEventHeader(fEvtHeader);
+
+    tmpId = fEvtHeader->GetRunId();
+    if ( tmpId != fRunId ) {
+      fRunId = tmpId;
+      if ( !fStatic ) {
+        Reinit( fRunId );
+        fTask->ReInitTask();
+      }
+    }
+    fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
+
+    fTask->ExecuteTask("");
+    fRootManager->Fill();
+    fRootManager->DeleteOldWriteoutBufferData();
+    fTask->FinishEvent();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::RunOnProof(Int_t NStart,Int_t NStop)
+{
+  fProofOutputStatus.ToLower();
+  if ( !fProofOutputStatus.Contains("copy") && !fProofOutputStatus.Contains("merge") ) {
+    LOG(WARNING) << "FairRunAnaProof::RunOnProof. Do not know how to create output \"" << fProofOutputStatus.Data() << "\"." << FairLogger::endl;
+    LOG(WARNING) << "FairRunAnaProof::RunOnProof. Please use SetProofOutputStatus to either \"copy\" or \"merge\"." << FairLogger::endl;
+    LOG(WARNING) << "FairRunAnaProof::RunOnProof. For the current run using the \"merge\" setting." << FairLogger::endl;
+    fProofOutputStatus = "merge";
+  }
+
+//  TChain* inChain = static_cast<TChain*>(fRootManager->GetInChain());
+  TChain* inChain = static_cast<TChain*>(fProofFileSource->GetInChain());
+  TString par1File = "";
+  TString par2File = "";
+  if ( fRtdb->getFirstInput () ) {
+    par1File = fRtdb->getFirstInput ()->getFilename();
+  }
+  if ( fRtdb->getSecondInput() ) {
+    par2File = fRtdb->getSecondInput()->getFilename();
+  }
+
+  TString outDir = (fOutputDirectory.Length()>1?fOutputDirectory.Data():gSystem->WorkingDirectory());
+
+  TString outFile = Form("%s",fOutname);
+
+  fProof->AddInput(fTask);
+
+  fProof->AddInput(new TNamed("FAIRRUNANA_fContainerStatic",(fStatic?"kTRUE":"kFALSE")));
+  fProof->AddInput(new TNamed("FAIRRUNANA_fProofOutputStatus",fProofOutputStatus.Data()));
+  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputDirectory",outDir.Data()));
+  fProof->AddInput(new TNamed("FAIRRUNANA_fOutputFileName",outFile.Data()));
+  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput1FName",par1File.Data()));
+  fProof->AddInput(new TNamed("FAIRRUNANA_fParInput2FName",par2File.Data()));
+
+  // uploading packages not needed, as the libraries are in the rootmap now
+  // fProof->ClearPackages();
+  // fProof->UploadPackage(fProofParName.Data());
+  // fProof->EnablePackage(fProofParName.Data());
+
+  Int_t nofChainEntries = inChain->GetEntries();
+  LOG(INFO) << "FairRunAnaProof::RunOnProof(): The chain seems to have " << nofChainEntries << " entries." << FairLogger::endl;
+
+  TObjArray* listOfFiles = inChain->GetListOfFiles();
+  LOG(INFO) << "FairRunAnaProof::RunOnProof(): There are " << listOfFiles->GetEntries() << " files in the chain." << FairLogger::endl;
+
+  inChain->SetProof();
+
+  Int_t nofEventsToAnalyze = NStop-NStart;
+
+  if ( nofEventsToAnalyze <= 0 ) {
+    LOG(INFO) << "You requested to analyze events from " << NStart << " to " << NStop << " that is " << nofEventsToAnalyze << " events!!!" << FairLogger::endl;
+    nofEventsToAnalyze = nofChainEntries-NStart;
+    LOG(INFO) << "It will be changed to analyze all events from " << NStart << " to the end of chain (" << nofChainEntries << "), that is to analyze " << nofEventsToAnalyze << " events." << FairLogger::endl;
+  }
+
+  LOG(INFO) << "FairRunAnaProof::RunOnProof(): Starting inChain->Process(\"FairAnaSelector\",\"\","
+       << nofEventsToAnalyze << "," << NStart << ")" << FairLogger::endl;
+  inChain->Process("FairAnaSelector","",nofEventsToAnalyze,NStart);
+  LOG(INFO) << "FairRunAnaProof::RunOnProof(): inChain->Process DONE" << FairLogger::endl;
+
+  return;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::SetOutputFile(const char* fname)
+{
+  fOutname=fname;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunAnaProof::SetOutputFile(TFile* f)
+{
+  if (! fRootManager) return;
+
+  fOutname=f->GetName();
+  fRootManager->OpenOutFile(f);
+  fOutFile = f;
+
+}
+//_____________________________________________________________________________
+
+ClassImp(FairRunAnaProof)
+
+
diff --git a/base/steer/FairRunAnaProof.h b/base/steer/FairRunAnaProof.h
new file mode 100644
index 0000000..7630cea
--- /dev/null
+++ b/base/steer/FairRunAnaProof.h
@@ -0,0 +1,110 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRRUNANAPROOF_H
+#define FAIRRUNANAPROOF_H
+
+/**
+ * Configure and manage the  Analysis on proof
+ * @author R. Karabowicz
+ * @version 0.1
+ * @since 30.04.2013
+ */
+
+#include "FairRunAna.h"
+
+#include "FairFileSource.h" // FairRunAnaProof can only accept FairFileSource as source
+#include "TProof.h"
+
+class FairRunAnaProof : public FairRunAna
+{
+
+  public:
+
+    static FairRunAnaProof* Instance();
+    virtual ~FairRunAnaProof();
+    FairRunAnaProof(const char* proofName="");
+
+    /**initialize the run manager*/
+    void        Init();
+
+    /** Init containers executed on PROOF, which is part of Init when running locally*/
+    void        InitContainers();
+
+    /**
+     * Set the output file name for analysis or simulation
+    */
+    virtual void    SetOutputFile(const char* fname);
+    /**
+     * Set the output file for analysis or simulation
+    */
+    virtual void    SetOutputFile(TFile* f);
+
+    /**Run from event number NStart to event number NStop */
+    void        Run(Int_t NStart=0 ,Int_t NStop=0);
+    /**Run for one event, used on PROOF nodes*/
+    void        RunOneEvent(Long64_t entry);
+    /**Run on proof from event NStart to event NStop*/
+    void        RunOnProof(Int_t NStart, Int_t NStop);
+
+    /** set the input tree of fRootManager when running on PROOF worker*/
+    /* void        SetInTree (TTree* tempTree)   { */
+    /*   fRootManager->SetInTree (tempTree); */
+    /* } */
+
+    /** GetProof */
+    TProof* GetProof() {
+      return fProof;
+    }
+
+    /** To be set to kTRUE only when running on PROOF worker, only by TSelector */
+    void SetRunOnProofWorker(Bool_t tb = kTRUE) {
+      fRunOnProofWorker = tb;
+    }
+    /** Set PROOF ARchive (PAR) file name*/
+    void SetProofParName(TString parName) {
+      fProofParName = parName;
+    }
+    /** Set directory for storing output files*/
+    void SetOutputDirectory(TString dirName) {
+      fOutputDirectory = dirName;
+    }
+    /** Set PROOF output status, possibilities: "copy","merge"*/
+    void SetProofOutputStatus(TString outStat) {
+      fProofOutputStatus = outStat;
+    }
+
+    virtual void   SetSource(FairSource* tempSource);
+
+  protected:
+    static FairRunAnaProof*                 fRAPInstance;
+
+    /** PROOF **/
+    TProof*                                 fProof;
+    /** executing on PROOF worker*/
+    Bool_t                                  fRunOnProofWorker; //!
+    /** PROOF server name*/
+    TString                                 fProofServerName; //!
+    /** PROOF ARchive (PAR) file name*/
+    TString                                 fProofParName; //!
+    /** Output directory*/
+    TString                                 fOutputDirectory; //!
+    /** Output status indicator: "copy","merge","dataset"*/
+    TString                                  fProofOutputStatus;
+
+  private:
+  
+    FairRunAnaProof(const FairRunAnaProof&);
+    FairRunAnaProof operator=(const FairRunAnaProof&);
+
+    FairFileSource* fProofFileSource;
+    
+    ClassDef(FairRunAnaProof ,1)
+
+};
+
+#endif //FAIRRUNANAPROOF_H
diff --git a/base/steer/FairRunOnline.cxx b/base/steer/FairRunOnline.cxx
new file mode 100644
index 0000000..0627eb9
--- /dev/null
+++ b/base/steer/FairRunOnline.cxx
@@ -0,0 +1,627 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                   FairRunOnline source file                   -----
+// -----            Created 06/01/04  by M. Al-Turany                  -----
+// -------------------------------------------------------------------------
+
+#include "FairRunOnline.h"
+
+#include "FairRootManager.h"
+#include "FairTask.h"
+#include "FairBaseParSet.h"
+#include "FairEventHeader.h"
+#include "FairFieldFactory.h"
+#include "FairRuntimeDb.h"
+#include "FairRunIdGenerator.h"
+#include "FairLogger.h"
+#include "FairFileHeader.h"
+#include "FairParIo.h"
+#include "FairField.h"
+//#include "FairSource.h"
+#include "FairMbsSource.h"
+
+#include "FairGeoInterface.h"
+#include "FairGeoLoader.h"
+#include "FairGeoParSet.h"
+
+#include "TROOT.h"
+#include "TSystem.h"
+#include "TTree.h"
+#include "TSeqCollection.h"
+#include "TGeoManager.h"
+#include "TKey.h"
+#include "TF1.h"
+#include "TSystem.h"
+#include "TFolder.h"
+#include "TH1F.h"
+#include "TH2F.h"
+#include "THttpServer.h"
+
+#include <signal.h>
+#include <stdlib.h>
+#include <iostream>
+#include <list>
+
+using std::cout;
+using std::endl;
+using std::list;
+
+
+
+//_____________________________________________________________________________
+FairRunOnline* FairRunOnline::fgRinstance = 0;
+
+
+
+//_____________________________________________________________________________
+FairRunOnline* FairRunOnline::Instance()
+{
+  return fgRinstance;
+}
+
+
+FairRunOnline::FairRunOnline()
+  :FairRun(),
+   fAutomaticFinish(kTRUE),
+   fIsInitialized(kFALSE),
+   fStatic(kFALSE),
+   fField(0),
+   fFolder(new TFolder("HISTO", "HISTO")),
+   fGenerateHtml(kFALSE),
+   fHistFileName(""),
+   fRefreshRate(1000),
+   fNevents(0),
+   fServer(NULL),
+   fServerRefreshRate(0)
+{
+  fgRinstance = this;
+  fAna = kTRUE;
+  LOG(INFO) << "FairRunOnline constructed at " << this << FairLogger::endl;
+}
+//_____________________________________________________________________________
+FairRunOnline::FairRunOnline(FairSource* source)
+  :FairRun(),
+   fAutomaticFinish(kTRUE),
+   fIsInitialized(kFALSE),
+   fStatic(kFALSE),
+   fField(0),
+   fFolder(new TFolder("HISTO", "HISTO")),
+   fGenerateHtml(kFALSE),
+   fHistFileName(""),
+   fRefreshRate(1000),
+   fNevents(0),
+   fServer(NULL),
+   fServerRefreshRate(0)
+{
+  fRootManager->SetSource(source);
+  fgRinstance = this;
+  fAna = kTRUE;
+  LOG(INFO) << "FairRunOnline constructed at " << this << FairLogger::endl;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairRunOnline::~FairRunOnline()
+{
+  //  delete fFriendFileList;
+  if (fField) {
+    delete fField;
+  }
+  if (gGeoManager) {
+    delete gGeoManager;
+  }
+  if(fFolder) {
+    fFolder->Delete();
+    delete fFolder;
+  }
+  if(fServer)
+  {
+    delete fServer;
+  }
+}
+//_____________________________________________________________________________
+
+
+
+Bool_t gIsInterrupted;
+
+void handler_ctrlc(int)
+{
+  gIsInterrupted = kTRUE;
+}
+
+
+
+//_____________________________________________________________________________
+void FairRunOnline::Init()
+{
+  LOG(INFO)<<"FairRunOnline::Init"<<FairLogger::endl;
+  if (fIsInitialized) {
+    LOG(FATAL) << "Error Init is already called before!" << FairLogger::endl;
+    exit(-1);
+  } else {
+    fIsInitialized = kTRUE;
+  }
+
+  fRootManager->InitSource();
+
+  //  FairGeoLoader* loader = new FairGeoLoader("TGeo", "Geo Loader");
+  //  FairGeoInterface* GeoInterFace = loader->getGeoInterface();
+  //  GeoInterFace->SetNoOfSets(ListOfModules->GetEntries());
+  //  GeoInterFace->setMediaFile(MatFname.Data());
+  //  GeoInterFace->readMedia();
+
+  // Add a Generated run ID to the FairRunTimeDb for input data which contain a FairMCEventHeader
+  // The call doesn't make sense for online sources which doesn't contain a  FairMCEventHeader
+
+  if(kONLINE != fRootManager->GetSource()->GetSourceType())
+  {
+    fRootManager->ReadEvent(0);
+  }
+
+  GetEventHeader();
+  
+  fRootManager->FillEventHeader(fEvtHeader);
+
+  if(0 == fRunId) // Run ID was not set in run manager
+  {
+    if(0 == fEvtHeader->GetRunId()) // Run ID was not set in source
+    {
+      // Generate unique Run ID
+      FairRunIdGenerator genid;
+      fRunId = genid.generateId();
+      fRootManager->GetSource()->SetRunId(fRunId);
+    }
+    else
+    {
+      // Use Run ID from source
+      fRunId = fEvtHeader->GetRunId();
+    }
+  }
+  else
+  {
+    // Run ID was set in the run manager - propagate to source
+    fRootManager->GetSource()->SetRunId(fRunId);
+  }
+
+  fRtdb->addRun(fRunId);
+  fFileHeader->SetRunId(fRunId);
+  FairBaseParSet* par = dynamic_cast<FairBaseParSet*>(fRtdb->getContainer("FairBaseParSet"));
+  FairGeoParSet* geopar = dynamic_cast<FairGeoParSet*>(fRtdb->getContainer("FairGeoParSet"));
+  if (geopar) {
+    geopar->SetGeometry(gGeoManager);
+  }
+  if(fField) {
+    fField->Init();
+    fField->FillParContainer();
+  }
+  TList* containerList = fRtdb->getListOfContainers();
+  TIter next(containerList);
+  FairParSet* cont;
+  TObjArray* ContList= new TObjArray();
+  while ((cont=dynamic_cast<FairParSet*>(next()))) {
+    ContList->Add(new TObjString(cont->GetName()));
+  }
+  if (par) {
+    par->SetContListStr(ContList);
+    par->setChanged();
+    par->setInputVersion(fRunId,1);
+  }
+  if (geopar) {
+    geopar->setChanged();
+    geopar->setInputVersion(fRunId,1);
+  }
+  
+  fRootManager->WriteFileHeader(fFileHeader);
+
+  fRootManager->GetSource()->SetParUnpackers();
+  fTask->SetParTask();
+  fRtdb->initContainers(fRunId);
+
+  //  InitContainers();
+  // --- Get event header from Run
+  if ( ! fEvtHeader ) {
+    LOG(FATAL) << "FairRunOnline::InitContainers:No event header in run!" << FairLogger::endl;
+    return;
+  }
+  LOG(INFO) << "FairRunOnline::InitContainers: event header at " << fEvtHeader << FairLogger::endl;
+  fRootManager->Register("EventHeader.", "Event", fEvtHeader, kTRUE);
+  fEvtHeader->SetRunId(fRunId);
+
+  fRootManager->GetSource()->InitUnpackers();
+
+  // Now call the User initialize for Tasks
+  fTask->InitTask();
+
+  // create the output tree after tasks initialisation
+  fOutFile->cd();
+  TTree* outTree =new TTree(FairRootManager::GetTreeName(), "/cbmout", 99);
+  fRootManager->TruncateBranchNames(outTree, "cbmout");
+  fRootManager->SetOutTree(outTree);
+  fRootManager->WriteFolder();
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunOnline::InitContainers()
+{
+
+  fRtdb = GetRuntimeDb();
+  FairBaseParSet* par=static_cast<FairBaseParSet*>
+                      (fRtdb->getContainer("FairBaseParSet"));
+  LOG(INFO) << "FairRunOnline::InitContainers: par = " << par << FairLogger::endl;
+  if (NULL == par)
+    LOG(WARNING)<<"FairRunOnline::InitContainers: no  'FairBaseParSet' container !"<<FairLogger::endl;
+
+  if (par) {
+    fEvtHeader = static_cast<FairEventHeader*>(fRootManager->GetObject("EventHeader."));
+
+    fRunId = fEvtHeader->GetRunId();
+
+    //Copy the Event Header Info to Output
+    fEvtHeader->Register();
+
+    // Init the containers in Tasks
+    fRtdb->initContainers(fRunId);
+    fTask->ReInitTask();
+    //    fTask->SetParTask();
+    fRtdb->initContainers( fRunId );
+    //     if (gGeoManager==0) {
+    //       par->GetGeometry();
+    //     }
+  } else
+    {
+      // --- Get event header from Run
+      //      fEvtHeader = dynamic_cast<FairEventHeader*> (FairRunOnline::Instance()->GetEventHeade
+      GetEventHeader();
+      if ( ! fEvtHeader ) {
+	LOG(FATAL) << "FairRunOnline::InitContainers:No event header in run!" << FairLogger::endl;
+	return;
+      }
+      LOG(INFO) << "FairRunOnline::InitContainers: event header at " << fEvtHeader << FairLogger::endl;
+      fRootManager->Register("EventHeader.", "Event", fEvtHeader, kTRUE);
+    }
+}
+//_____________________________________________________________________________
+Int_t FairRunOnline::EventLoop()
+{
+  gSystem->IgnoreInterrupt();
+  signal(SIGINT, handler_ctrlc);
+
+  fRootManager->FillEventHeader(fEvtHeader);
+  Int_t tmpId = fEvtHeader->GetRunId();
+
+  if ( tmpId != -1 && tmpId != fRunId ) {
+    LOG(INFO) << "FairRunOnline::EventLoop() Call Reinit due to changed RunID (from " << fRunId << " to " << tmpId << FairLogger::endl;
+    fRunId = tmpId;
+    Reinit( fRunId );
+    fRootManager->GetSource()->ReInitUnpackers();
+    fTask->ReInitTask();
+  }
+
+  fRootManager->StoreWriteoutBufferData(fRootManager->GetEventTime());
+  fTask->ExecuteTask("");
+  fRootManager->FillEventHeader(fEvtHeader);
+  Fill();
+  fRootManager->DeleteOldWriteoutBufferData();
+  fTask->FinishEvent();
+  fNevents += 1;
+  if(fGenerateHtml && 0 == (fNevents%fRefreshRate))
+  {
+    WriteObjects();
+    GenerateHtml();
+  }
+  if(fServer && 0 == (fNevents%fServerRefreshRate))
+  {
+    fServer->ProcessRequests();
+  }
+    
+  if(gIsInterrupted)
+  {
+    return 1;
+  }
+
+  return 0;
+}
+
+//_____________________________________________________________________________
+void FairRunOnline::Run(Int_t Ev_start, Int_t Ev_end)
+{
+  fOutFile->cd();
+  
+  fNevents = 0;
+
+  gIsInterrupted = kFALSE;
+  
+  Int_t MaxAllowed=fRootManager->CheckMaxEventNo(Ev_end);
+  if ( MaxAllowed != -1 ) {
+    if (Ev_end==0) {
+      if (Ev_start==0) {
+        Ev_end=MaxAllowed;
+      } else {
+        Ev_end =  Ev_start;
+        if ( Ev_end > MaxAllowed ) {
+          Ev_end = MaxAllowed;
+        }
+        Ev_start=0;
+      }
+    } else {
+      if (Ev_end > MaxAllowed) {
+        cout << "-------------------Warning---------------------------" << endl;
+        cout << " -W FairRunAna : File has less events than requested!!" << endl;
+        cout << " File contains : " << MaxAllowed  << " Events" << endl;
+        cout << " Requested number of events = " <<  Ev_end <<  " Events"<< endl;
+        cout << " The number of events is set to " << MaxAllowed << " Events"<< endl;
+        cout << "-----------------------------------------------------" << endl;
+        Ev_end = MaxAllowed;
+      }
+    }
+  }
+  Int_t status;
+  if(Ev_start < 0) {
+    while(kTRUE) {
+      status = fRootManager->ReadEvent();
+      if(0 == status) {
+	status = EventLoop();
+      }
+      if(1 == status) {
+        break;
+      } else if(2 == status) {
+        continue;
+      }
+      if(gIsInterrupted)
+      {
+        break;
+      }
+    }
+  } else {
+    for (Int_t i = Ev_start; i < Ev_end; i++) {
+      status = fRootManager->ReadEvent(i);
+      if(0 == status) {
+	status = EventLoop();
+      }
+      if(1 == status) {
+        break;
+      } else if(2 == status) {
+        i -= 1;
+        continue;
+      }
+
+      if(gIsInterrupted)
+      {
+        break;
+      }
+    }
+  }
+ 
+  fRootManager->StoreAllWriteoutBufferData();
+  if (fAutomaticFinish) {
+    Finish();
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairRunOnline::Finish()
+{
+  fTask->FinishTask();
+  fRootManager->LastFill();
+  fRootManager->Write();
+  fRootManager->GetSource()->Close();
+
+  if(fGenerateHtml) {
+    WriteObjects();
+    GenerateHtml();
+  }
+
+  fRootManager->CloseOutFile();
+}
+
+//_____________________________________________________________________________
+void FairRunOnline::SetGenerateHtml(Bool_t flag, const char* histFileName, Int_t refreshRate)
+{
+  fGenerateHtml = flag;
+  fHistFileName = TString(histFileName);
+  fRefreshRate = refreshRate;
+}
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+void FairRunOnline::GenerateHtml()
+{
+  TString htmlName = TString(fHistFileName);
+  TString rootName = TString(fHistFileName);
+  Int_t last = htmlName.Last('/');
+  if(-1 != last) {
+    rootName.Remove(0, last+1);
+  }
+  htmlName.Remove(htmlName.Length()-4, htmlName.Length()-1);
+  htmlName += TString("html");
+
+  std::ofstream* ofile = new std::ofstream(htmlName);
+  (*ofile) << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << endl
+           << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" << endl
+           << "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1transitional.dtd\">" << endl
+           << "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">" << endl
+           << "<head>" << endl
+           << "<title>Read a ROOT file</title>" << endl
+           << "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=Edge; text/html\">" << endl
+           << "<script type=\"text/javascript\" src=\"http://root.cern.ch/js/3.2/scripts/JSRootCore.js\"></script>" << endl
+           << "</head>" << endl
+           << "<body onload=\"JSROOT.BuildSimpleGUI()\">" << endl
+           << "<div id=\"simpleGUI\"" << endl
+           << "files=\"" << rootName << "\"></div>" << endl
+           << "</body>" << endl
+           << "</html>" << endl;
+  ofile->close();
+  delete ofile;
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunOnline::ActivateHttpServer(Int_t refreshRate)
+{
+  fServer = new THttpServer("http:8080");
+  fServerRefreshRate = refreshRate;
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunOnline::RegisterHttpCommand(TString name, TString command)
+{
+  if(fServer)
+  {
+#if ROOT_VERSION_CODE > 336416
+      TString path = "/Objects/HISTO";
+      fServer->RegisterCommand(name, path + command);
+#else
+      LOG(WARNING)<<"THttp->RegisterCommand() only implemented in ROOT above version 5.34/26. Skip call of this function." << FairLogger::endl;
+#endif      
+  }
+}
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunOnline::WriteObjects()
+{
+  TDirectory *oldDir = gDirectory;
+
+  TFile *file = new TFile(fHistFileName, "RECREATE");
+
+  // Create iterator with the folder content
+  TIter iter(fFolder->GetListOfFolders());
+
+  // Pointer to an object
+  TObject* object;
+
+  // Class name of the object
+  TString className;
+
+  // Histogram pointers
+  TH1* h1;
+  TH2* h2;
+
+  // Loop over objects in the folder
+  while((object = iter())) {
+
+    // Get class name
+    className = object->ClassName();
+
+    // Recognise objects
+    if(0 == className.CompareTo("TH1F")) {
+      // If a histogram - plot it and save canvas
+      h1 = static_cast<TH1F*>(object);
+      h1->Write();
+    } else if(0 == className.CompareTo("TH2F")) {
+      // If a histogram - plot it and save canvas
+      h2 = static_cast<TH2F*>(object);
+      h2->Write();
+    } else if(0 == className.CompareTo("TH1D")) {
+      // If a histogram - plot it and save canvas
+      h1 = static_cast<TH1D*>(object);
+      h1->Write();
+    } else if(0 == className.CompareTo("TH2D")) {
+      // If a histogram - plot it and save canvas
+      h2 = static_cast<TH2D*>(object);
+      h2->Write();
+    }
+  }
+
+  file->Close();
+
+  oldDir->cd();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+
+
+//_____________________________________________________________________________
+void FairRunOnline::Reinit(UInt_t runId)
+{
+  // reinit procedure
+  fRtdb->initContainers( runId );
+}
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+void  FairRunOnline::SetContainerStatic(Bool_t tempBool)
+{
+  fStatic=tempBool;
+  if ( fStatic ) {
+    LOG(INFO) << "Parameter Cont. initialisation is static" 
+	      << FairLogger::endl;
+  } else {
+    LOG(INFO) << "Parameter Cont. initialisation is NOT static"
+	      << FairLogger::endl;
+  }
+}
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+void FairRunOnline::AddObject(TObject* object)
+{
+    if(NULL == object)
+    {
+        return;
+    }
+    if(fFolder) {
+        fFolder->Add(object);
+    }
+    if(fServer) {
+        TString classname = TString(object->ClassName());
+        if(classname.EqualTo("TCanvas"))
+        {
+            fServer->Register("CANVAS", object);
+        }
+        else if(classname.EqualTo("TFolder"))
+        {
+            fServer->Register("/", object);
+        }
+        else if(classname.Contains("TH1") || classname.Contains("TH2"))
+        {
+            fServer->Register("HISTO", object);
+        }
+        else
+        {
+            LOG(WARNING) << "FairRunOnline::AddObject : unrecognized object type : " << classname << FairLogger::endl;
+        }
+    }
+}
+//_____________________________________________________________________________
+
+
+
+//_____________________________________________________________________________
+void FairRunOnline::Fill()
+{
+  if(fMarkFill)
+  {
+    fRootManager->Fill();
+  }
+  else
+  {
+    fMarkFill = kTRUE;
+  }
+}
+//_____________________________________________________________________________
+
+
+
+ClassImp(FairRunOnline)
diff --git a/base/steer/FairRunOnline.h b/base/steer/FairRunOnline.h
new file mode 100644
index 0000000..cc2f0f2
--- /dev/null
+++ b/base/steer/FairRunOnline.h
@@ -0,0 +1,128 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef FAIRRUNONLINE_H
+#define FAIRRUNONLINE_H
+
+
+/**
+ * Configure and manage the Analysis
+ * @author M. Al-Turany D. Bertini
+ * @version 0.1
+ * @since 28.02.05
+ */
+
+#include "FairRun.h"
+#include "FairRootManager.h"
+
+#include "TString.h"
+#include <iostream>
+
+class FairRuntimeDb;
+class FairField;
+class TFile;
+class TF1;
+class TTree;
+class FairSource;
+class TFolder;
+class THttpServer;
+
+class FairRunOnline : public FairRun
+{
+
+  public:
+    static FairRunOnline* Instance();
+    virtual ~FairRunOnline();
+    FairRunOnline();
+    FairRunOnline(FairSource* source);
+
+    /**initialize the run manager*/
+    void        Init();
+    /**Run for the given number of events*/
+    void        Run(Int_t Ev_start, Int_t Ev_end);
+ 
+    void        Reinit(UInt_t runId);
+    UInt_t      getRunId() { return fRunId; }
+    /** Get the magnetic field **/
+    FairField*  GetField() { return fField; }
+    /** Set the magnetic Field */
+    void        SetField (FairField* ffield) { fField = ffield; }
+
+    /** Set if the run should be closed automatically after executing the
+        run functuion
+    **/
+    void        SetAutoFinish(Bool_t val) { fAutomaticFinish = val; }
+    /** Set the source which should be used **/
+    void        SetSource(FairSource* source) { fRootManager->SetSource(source); }
+    /** Return pointer to source **/
+    FairSource*  GetSource() { return fRootManager->GetSource(); }
+
+
+    /** Initialization of parameter container is set to static, i.e: the run id is
+     *  is not checked anymore after initialization
+     */
+
+    /** Init containers executed on PROOF, which is part of Init when running locally*/
+    void        InitContainers();
+    void        SetContainerStatic(Bool_t tempBool=kTRUE);
+    Bool_t      GetContainerStatic() { return fStatic; };
+
+    /** Add histogram to be displayed using THttpServer.*/
+    void AddObject(TObject* object);
+
+    void SetGenerateHtml(Bool_t flag, const char* histFileName, Int_t refreshRate);
+
+    /** Activate http server on current host port 8080. To be called before Init.
+     * @param refreshRate an interval in number of events for server update.
+     */
+    void ActivateHttpServer(Int_t refreshRate = 10000);
+
+    /** Register a command on the http server.
+     * @param name a command name starting with /
+     * @param command a call to method "/object_name/->Method()"
+     */
+    void RegisterHttpCommand(TString name, TString command);
+
+    /** Write last data to file, close input and output **/
+    void Finish();
+
+  private:
+
+    Bool_t fAutomaticFinish;
+
+    FairRunOnline(const FairRunOnline& M);
+    FairRunOnline& operator= (const  FairRunOnline&) { return *this; }
+
+    /** Main Event loop **/
+    Int_t EventLoop();
+
+  protected:
+    /** This variable became true after Init is called*/
+    Bool_t                                  fIsInitialized;
+    static FairRunOnline*                   fgRinstance;
+    /** true for static initialisation of parameters */
+    Bool_t                                  fStatic;//!
+    FairField*                              fField;
+
+    TFolder*    fFolder;       //!
+    Bool_t      fGenerateHtml; //!
+    TString     fHistFileName; //!
+    Int_t       fRefreshRate;  //!
+    Int_t       fNevents;      //!
+
+    THttpServer* fServer;             //!
+    Int_t        fServerRefreshRate;  //!
+
+    void WriteObjects();
+    void GenerateHtml();
+
+    virtual void Fill();
+
+    ClassDef(FairRunOnline, 0)
+};
+
+#endif //FAIRRUNONLINE_H
diff --git a/base/FairRunSim.cxx b/base/steer/FairRunSim.cxx
similarity index 66%
rename from base/FairRunSim.cxx
rename to base/steer/FairRunSim.cxx
index c9628d1..0efc2a1 100644
--- a/base/FairRunSim.cxx
+++ b/base/steer/FairRunSim.cxx
@@ -1,32 +1,54 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //_____________________________________________________________________________
 // -----                   FairRunSim source file                      -----
 // -----            Created 06/01/04  by M. Al-Turany                  -----
 //_____________________________________________________________________________
 #include "FairRunSim.h"
-#include "FairRootManager.h"
-#include "FairTrajFilter.h"
-#include "FairBaseParSet.h"
-#include "FairRunIdGenerator.h"
-#include "FairModule.h"
-#include "FairField.h"
-#include "FairRuntimeDb.h"
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
-#include "FairMCEventHeader.h"
-#include "FairPrimaryGenerator.h"
-#include "FairMesh.h"
-#include "TROOT.h"
-#include "TSystem.h"
-#include <iostream>
-#include "FairFileHeader.h"
+
+#include "FairBaseParSet.h"             // for FairBaseParSet
+#include "FairGeoParSet.h"              // for FairGeoParSet
+#include "FairField.h"                  // for FairField
+#include "FairFileHeader.h"             // for FairFileHeader
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairMCEventHeader.h"          // for FairMCEventHeader
+#include "FairMesh.h"                   // for FairMesh
+#include "FairModule.h"                 // for FairModule
+#include "FairParSet.h"                 // for FairParSet
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairRunIdGenerator.h"         // for FairRunIdGenerator
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairTask.h"                   // for FairTask
+#include "FairTrajFilter.h"             // for FairTrajFilter
+
+#include "Riosfwd.h"                    // for ostream
+#include "TCollection.h"                // for TIter
+#include "TGeoManager.h"                // for gGeoManager
+#include "TList.h"                      // for TList
+#include "TObjString.h"                 // for TObjString
+#include "TObject.h"                    // for TObject
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TSystem.h"                    // for TSystem, gSystem
+#include "TRandom.h"                    // for gRandom
+#include <stdlib.h>                     // for getenv, NULL
+#include <string.h>                     // for strcmp, strncmp
+#include <iostream>                     // for cout, endl, ostream
 
 using std::cout;
 using std::endl;
 
 ClassImp(FairRunSim)
 //_____________________________________________________________________________
-FairRunSim::FairRunSim()
-  :FairRun(),
+FairRunSim::FairRunSim(Bool_t isMaster)
+  :FairRun(isMaster),
    count(0),
    fApp(NULL),
    fBeamMom(0),
@@ -65,15 +87,17 @@ FairRunSim::FairRunSim()
 //_____________________________________________________________________________
 FairRunSim::~FairRunSim()
 {
-  fLogger->Debug(MESSAGE_ORIGIN," Enter Destructor of FairRunSim ");
+  LOG(DEBUG) << "Enter Destructor of FairRunSim " << FairLogger::endl;
   /** List of Modules is filled via AddModule from the macro, but it
    is the responsibility of FairRunSim to call the destructors of
    the modules-
   */
-  fLogger->Debug(MESSAGE_ORIGIN," Start deleting all registered modules");
+  LOG(DEBUG) << "Start deleting all registered modules" 
+	     << FairLogger::endl;
   ListOfModules->Delete();
   delete ListOfModules;
-  fLogger->Debug(MESSAGE_ORIGIN," Finish deleting all registered modules");
+  LOG(DEBUG) << "Finish deleting all registered modules"
+	     << FairLogger::endl;
 
   fIons->Delete();
   delete fIons;
@@ -123,7 +147,7 @@ void FairRunSim::Init()
   CheckFlukaExec();
 
 //  fOutFile=fRootManager->OpenOutFile(fOutname);
-  fLogger->Info(MESSAGE_ORIGIN,"==============  FairRunSim: Initialising simulation run ==============");
+  LOG(INFO) << "==============  FairRunSim: Initialising simulation run ==============" << FairLogger::endl;
 
   FairGeoLoader* loader=new FairGeoLoader(fLoaderName->Data(), "Geo Loader");
   FairGeoInterface* GeoInterFace=loader->getGeoInterface();
@@ -146,23 +170,35 @@ void FairRunSim::Init()
   /** Add Tasks to simulation if any*/
   fApp->AddTask(fTask);
 
-  FairBaseParSet* par=(FairBaseParSet*)(fRtdb->getContainer("FairBaseParSet"));
-  par->SetDetList(GetListOfModules());
-  par->SetGen(GetPrimaryGenerator());
-  par->SetBeamMom(fBeamMom);
-  par->SetGeometry(gGeoManager);
+  FairBaseParSet* par=dynamic_cast<FairBaseParSet*>(fRtdb->getContainer("FairBaseParSet"));
+  if (par) {
+    par->SetDetList(GetListOfModules());
+    par->SetGen(GetPrimaryGenerator());
+    par->SetBeamMom(fBeamMom);
+  }
+
+  FairGeoParSet* geopar=dynamic_cast<FairGeoParSet*>(fRtdb->getContainer("FairGeoParSet"));
+  if (geopar) {
+    geopar->SetGeometry(gGeoManager);
+  }
 
   // Set global Parameter Info
 
   if(fPythiaDecayer) {
     fApp->SetPythiaDecayer(fPythiaDecayer);
+    if (fPythiaDecayerConfig) {
+      fApp->SetPythiaDecayerConfig(fPythiaDecayerConfig);
+    }
   }
   if(fUserDecay) {
     fApp->SetUserDecay(fUserDecay);
+    if (fUserDecayConfig) {
+      fApp->SetUserDecayConfig(fUserDecayConfig);
+    }
   }
   // on/off visualisation
   if( fStoreTraj ) {
-    fLogger->Info(MESSAGE_ORIGIN, "Create visualisation manager ");
+    LOG(INFO) << "Create visualisation manager " << FairLogger::endl;
     new FairTrajFilter();
   }
   if(fRadLength) {
@@ -183,13 +219,19 @@ void FairRunSim::Init()
   TIter next(containerList);
   FairParSet* cont;
   TObjArray* ContList= new TObjArray();
-  while ((cont=(FairParSet*)next())) {
+  while ((cont=dynamic_cast<FairParSet*>(next()))) {
     ContList->Add(new TObjString(cont->GetName()));
   }
 
   par->SetContListStr(ContList);
+  par->SetRndSeed(gRandom->GetSeed());
+  
   par->setChanged();
   par->setInputVersion(fRunId,1);
+  
+  geopar->setChanged();
+  geopar->setInputVersion(fRunId,1);
+
 
 
   /**Set the configuration for MC engine*/
@@ -210,13 +252,18 @@ void FairRunSim::CheckFlukaExec()
   /** Private method for setting FLUKA simulation*/
   TString work = getenv("VMCWORKDIR");
   TString work_config=work+"/gconfig/";
+  work_config.ReplaceAll("//","/");
+
   TString config_dir= getenv("CONFIG_DIR");
+  config_dir.ReplaceAll("//","/");
   if (!config_dir.EndsWith("/")) { config_dir+="/"; }
+
   TString flout;
   if(strcmp(GetName(),"TFluka") == 0 ) {
     TString flexec="run_fluka.sh";
     if (TString(gSystem->FindFile(config_dir.Data(),flexec)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration is used :  %s ", config_dir.Data());
+      LOG(INFO) << "---User path for Configuration is used: " 
+		<< config_dir.Data() << FairLogger::endl;
     } else {
       flexec=work_config+"run_fluka.sh";
     }
@@ -226,6 +273,7 @@ void FairRunSim::CheckFlukaExec()
     TString macrodir = getenv("PWD");
     cout << macrodir << endl;
     flout = macrodir + "/fluka_out" ;
+    flout.ReplaceAll("//","/");
     gSystem->cd(flout.Data());
   }
 }
@@ -235,12 +283,17 @@ void FairRunSim::SetMCConfig()
   /** Private method for setting simulation and/or Geane configuration and cuts*/
 
   TString work = getenv("VMCWORKDIR");
-  TString Lib_config= getenv("GEANT4VMC_MACRO_DIR");
   TString work_config=work+"/gconfig/";
+  work_config.ReplaceAll("//","/");
+
+  TString Lib_config= getenv("GEANT4VMC_MACRO_DIR");
+  Lib_config.ReplaceAll("//","/");
+  if (!Lib_config.EndsWith("/")) { Lib_config+="/"; }
+
   TString config_dir= getenv("CONFIG_DIR");
+  config_dir.ReplaceAll("//","/");
+
   Bool_t AbsPath=kFALSE;
-  if (!config_dir.EndsWith("/")) { config_dir+="/"; }
-  if (!Lib_config.EndsWith("/")) { Lib_config+="/"; }
 
   TString LibMacro;
   TString LibFunction;
@@ -256,17 +309,20 @@ void FairRunSim::SetMCConfig()
     } else {
       if (fUserConfig.Contains("/")) { AbsPath=kTRUE; }
       g4Macro = fUserConfig;
-      fLogger->Info(MESSAGE_ORIGIN,"---------------User config is used : %s ",g4Macro.Data());
+      LOG(INFO) << "---------------User config is used: " 
+		<< g4Macro.Data() << FairLogger::endl;
     }
     if (TString(gSystem->FindFile(config_dir.Data(),g4LibMacro)) != TString("")) { //be carfull after this call the string g4LibMacro is empty if not found!!!!
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration (g4libs.C) is used : %s" ,config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (g4libs.C) is used: " 
+		<< config_dir.Data() << FairLogger::endl;
     } else {
       g4LibMacro=Lib_config+"g4libs.C";
     }
     LibMacro=g4LibMacro;
     LibFunction="g4libs()";
     if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),g4Macro)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration (g4Config.C) is used : %s" , config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (g4Config.C) is used: " 
+		<< config_dir.Data() << FairLogger::endl;
       ConfigMacro=g4Macro;
     } else {
       if(AbsPath) { ConfigMacro = fUserConfig; }
@@ -279,21 +335,24 @@ void FairRunSim::SetMCConfig()
     if(fUserConfig.IsNull()) {
       g3Macro="g3Config.C";
       fUserConfig = g3Macro;
-      fLogger->Info(MESSAGE_ORIGIN,"-------------- Standard Config is called ------------------------------------");
+      LOG(INFO) << "-------------- Standard Config is called ------------------------------------" << FairLogger::endl;
     } else {
       if (fUserConfig.Contains("/")) { AbsPath=kTRUE; }
       g3Macro = fUserConfig;
-      fLogger->Info(MESSAGE_ORIGIN,"---------------User config is used :  ", g3Macro.Data());
+      LOG(INFO) << "---------------User config is used: " 
+		<< g3Macro.Data() << FairLogger::endl;
     }
     if (TString(gSystem->FindFile(config_dir.Data(),g3LibMacro)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration (g3libs.C) is used : %s " , config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (g3libs.C) is used: " 
+		<< config_dir.Data() << FairLogger::endl;
     } else {
       g3LibMacro=work_config+"g3libs.C";
     }
     LibMacro=g3LibMacro;
     LibFunction="g3libs()";
     if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),g3Macro)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration (g3Config.C) is used : %s", config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (g3Config.C) is used: "
+		<< config_dir.Data() << FairLogger::endl;
       ConfigMacro=g3Macro;
     } else {
       if(AbsPath) { ConfigMacro = fUserConfig; }
@@ -309,17 +368,20 @@ void FairRunSim::SetMCConfig()
     } else {
       if (fUserConfig.Contains("/")) { AbsPath=kTRUE; }
       flMacro = fUserConfig;
-      fLogger->Info(MESSAGE_ORIGIN,"---------------User config is used : %s " , flMacro.Data());
+      LOG(INFO) << "---------------User config is used: " 
+		<< flMacro.Data() << FairLogger::endl;
     }
     if (TString(gSystem->FindFile(config_dir.Data(), flLibMacro)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN,"---User path for Configuration (fllibs.C) is used : %s", config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (fllibs.C) is used: "
+		<< config_dir.Data() << FairLogger::endl;
     } else {
       flLibMacro=work_config+"fllibs.C";
     }
     LibMacro=flLibMacro;
     LibFunction="fllibs()";
     if (!AbsPath && TString(gSystem->FindFile(config_dir.Data(),flMacro)) != TString("")) {
-      fLogger->Info(MESSAGE_ORIGIN, "---User path for Configuration (flConfig.C) is used : %s",  config_dir.Data());
+      LOG(INFO) << "---User path for Configuration (flConfig.C) is used: " 
+		<< config_dir.Data() << FairLogger::endl;
       ConfigMacro=flMacro;
     } else {
       if(AbsPath) { ConfigMacro = fUserConfig; }
@@ -328,7 +390,8 @@ void FairRunSim::SetMCConfig()
   }
   //----------------------------------------------SetCuts------------------------------------------------
   if (TString(gSystem->FindFile(config_dir.Data(),cuts)) != TString("")) {
-    fLogger->Info(MESSAGE_ORIGIN,"---User path for Cuts and Processes  (SetCuts.C) is used : %s", config_dir.Data());
+    LOG(INFO) << "---User path for Cuts and Processes (SetCuts.C) is used: "
+	      << config_dir.Data() << FairLogger::endl;
   } else {
     cuts =work_config+ fUserCuts;
   }
@@ -346,7 +409,7 @@ void FairRunSim::SetMCConfig()
 }
 
 //_____________________________________________________________________________
-void FairRunSim::Run(Int_t NEvents, Int_t NotUsed)
+void FairRunSim::Run(Int_t NEvents, Int_t)
 {
   fApp->RunMC(NEvents);
 }
@@ -365,15 +428,17 @@ void FairRunSim::SetMaterials(const char* MatFileName)
 {
   TString Mat="";
   TString work = getenv("GEOMPATH");
+  work.ReplaceAll("//","/");
   if (work.IsNull()) {
     work = getenv("VMCWORKDIR");
     Mat=work+"/geometry/";
+    Mat.ReplaceAll("//","/");
   } else {
     Mat=work;
     if (!Mat.EndsWith("/")) { Mat+="/"; }
   }
   MatFname=Mat+MatFileName;
-  fLogger->Info(MESSAGE_ORIGIN,"Media file used : %s ", MatFname.Data());
+  LOG(INFO) << "Media file used: " << MatFname.Data() << FairLogger::endl;
 }
 //_____________________________________________________________________________
 void FairRunSim::SetGeoModel( char* name )
@@ -381,10 +446,13 @@ void FairRunSim::SetGeoModel( char* name )
   if ( strncmp(fName,"TGeant3",7) == 0 ) {
     if (fLoaderName) { delete fLoaderName; }
     fLoaderName = new TString(name);
-    fLogger->Info(MESSAGE_ORIGIN,"FairRun::SetGeoModel(): G3 native geometry model used ");
+    LOG(INFO) << "FairRun::SetGeoModel(): G3 native geometry model used "
+	      << FairLogger::endl;
   } else {
-    fLogger->Info(MESSAGE_ORIGIN,"FairRun::SetGeoModel(): Geant3 MC engine only !");
-    fLogger->Info(MESSAGE_ORIGIN,"FairRun::SetGeoModel(): Method skipped ... ");
+    LOG(INFO) << "FairRun::SetGeoModel(): Geant3 MC engine only !"
+	      << FairLogger::endl;
+    LOG(INFO) << "FairRun::SetGeoModel(): Method skipped ... "
+	      << FairLogger::endl;
   }
 }
 //_____________________________________________________________________________
@@ -393,6 +461,7 @@ void  FairRunSim::SetPythiaDecayer(const TString& Config )
   /**switch On external decayer (Pythia). Config macro will be used */
   fPythiaDecayerConfig = Config;
   fPythiaDecayer =kTRUE;
+
 }
 //_____________________________________________________________________________
 
@@ -410,7 +479,7 @@ FairMCEventHeader*  FairRunSim::GetMCEventHeader()
 }
 //_____________________________________________________________________________
 
-FairRunSim* FairRunSim::fginstance= 0;
+TMCThreadLocal FairRunSim* FairRunSim::fginstance= 0;
 
 
 
diff --git a/base/FairRunSim.h b/base/steer/FairRunSim.h
similarity index 83%
rename from base/FairRunSim.h
rename to base/steer/FairRunSim.h
index 9286337..6943418 100644
--- a/base/FairRunSim.h
+++ b/base/steer/FairRunSim.h
@@ -1,20 +1,29 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRRUNSIM_H
 #define FAIRRUNSIM_H
 
-#include "FairRun.h"
+#include "FairRun.h"                    // for FairRun
 
-#include "FairMCApplication.h"
-#include "FairIon.h"
-#include "FairParticle.h"
-#include "TObjArray.h"
-#include "TString.h"
-#include <iostream>
+#include "FairIon.h"                    // for FairIon
+#include "FairMCApplication.h"          // for FairMCApplication
+#include "FairParticle.h"               // for FairParticle
+
+#include "Rtypes.h"                     // for Bool_t, Double_t, Int_t, etc
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+#include "TMCtls.h"                     // for multi-threading
 
-class FairModule;
 class FairField;
-class FairPrimaryGenerator;
 class FairMCEventHeader;
 class FairMesh;
+class FairModule;
+class FairPrimaryGenerator;
 
 /**
  * Configure the Simulation session
@@ -26,7 +35,7 @@ class FairRunSim : public FairRun
 {
   public:
     /** default ctor*/
-    FairRunSim();
+    FairRunSim(Bool_t isMaster = kTRUE);
     /** default dtor*/
     virtual ~FairRunSim();
     /** Singelton instance*/
@@ -155,7 +164,11 @@ class FairRunSim : public FairRun
     Bool_t                 fUseBeamMom; //!                        /** flag for use Beam Energy  */
     FairPrimaryGenerator*  fGen; //!                               /** Primary Event Generator */
     FairMCEventHeader*     fMCEvHead; //!                          /** MC Event Header */
-    static FairRunSim*     fginstance;//!                          /** Singelton Instance */
+#if !defined(__CINT__)
+    static TMCThreadLocal FairRunSim*  fginstance;//!              /** Singleton Instance */
+#else
+    static                FairRunSim*  fginstance;//!              /** Singleton Instance */
+#endif
     FairField*             fField;                                 /** Magnetic Field */
     const char*            fMapName; //!                           /** Input file name map*/
     TObjArray*             fIons; //!                              /** Array of user defined ions */
diff --git a/base/FairTSBufferFunctional.cxx b/base/steer/FairTSBufferFunctional.cxx
similarity index 81%
rename from base/FairTSBufferFunctional.cxx
rename to base/steer/FairTSBufferFunctional.cxx
index d8610a2..97a1b24 100644
--- a/base/FairTSBufferFunctional.cxx
+++ b/base/steer/FairTSBufferFunctional.cxx
@@ -1,7 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairTSBufferFunctional.h"
 
-#include "FairRootManager.h"
-#include "FairTimeStamp.h"
+#include "FairLink.h"                   // for FairLink
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairTimeStamp.h"              // for FairTimeStamp
+
+#include "TBranch.h"                    // for TBranch
+#include "TClass.h"                     // for TClass
+#include "TClonesArray.h"               // for TClonesArray
+#include "TTree.h"                      // for TTree
+
+#include <stddef.h>                     // for NULL
 
 ClassImp(FairTSBufferFunctional);
 
@@ -15,7 +30,7 @@ FairTSBufferFunctional::FairTSBufferFunctional(TString branchName, TTree* source
    fStopFunction (stopFunction),
    fBranch(NULL),
    fBranchIndex(-1),
-   fStartIndex(-1),
+   fTerminate(kFALSE),
    fVerbose(0)
 {
   fBranch = sourceTree->GetBranch(branchName.Data());
@@ -23,7 +38,7 @@ FairTSBufferFunctional::FairTSBufferFunctional(TString branchName, TTree* source
     std::cout << "-E- FairTSBufferFunctional::FairTSBufferFunctional Branch " << branchName << " does not exist!" << std::endl;
   }
   FairRootManager* ioman = FairRootManager::Instance();
-  fInputArray = (TClonesArray*)ioman->GetObject(branchName.Data());
+  fInputArray = static_cast<TClonesArray*>(ioman->GetObject(branchName.Data()));
   fBufferArray = new TClonesArray(fInputArray->GetClass()->GetName());
   fOutputArray = new TClonesArray(fInputArray->GetClass()->GetName());
 
@@ -31,14 +46,13 @@ FairTSBufferFunctional::FairTSBufferFunctional(TString branchName, TTree* source
 
 TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter)
 {
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)
 
   Double_t actualTime = 0.;
   int posBuffer = 0;
 
   if (fStopFunction == 0) {                 //no function is given ==> read in data in traditional way event by event
     ReadInNextEntry();
-    fOutputArray->AbsorbObjects((TClonesArray*)fInputArray, 0, fInputArray->GetEntriesFast() - 1);
+    fOutputArray->AbsorbObjects(static_cast<TClonesArray*>(fInputArray), 0, fInputArray->GetEntriesFast() - 1);
     return fOutputArray;
   }
   if (fVerbose > 1) {
@@ -58,7 +72,7 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter)
   if (fVerbose > 1) {
     std::cout << "-I- FairTSBufferFunctional::GetData fBufferArray->GetEntriesFast(): " << fBufferArray->GetEntriesFast() << std::endl;
   }
-  FairTimeStamp* dataPoint = (FairTimeStamp*)fBufferArray->Last();
+  FairTimeStamp* dataPoint = static_cast<FairTimeStamp*>(fBufferArray->Last());
   if (dataPoint == 0) {
     if (fVerbose > 0) {
       std::cout << "-I- FairTSBufferFunctional::GetData dataPoint is empty ==> All Data read in" << std::endl;
@@ -66,7 +80,7 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter)
     return fOutputArray;
   }
 
-  dataPoint = (FairTimeStamp*)fBufferArray->First();
+  dataPoint = static_cast<FairTimeStamp*>(fBufferArray->First());
 
   while (!(*fStopFunction)(dataPoint, stopParameter)) {     //check if you have reached end of requested data
     posBuffer++;
@@ -79,7 +93,7 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter)
     if (posBuffer == fBufferArray->GetEntriesFast()) {
       break;
     }
-    dataPoint = (FairTimeStamp*)fBufferArray->At(posBuffer);
+    dataPoint = static_cast<FairTimeStamp*>(fBufferArray->At(posBuffer));
     if (fVerbose > 1) {
       std::cout << posBuffer << " TimeStampData: " << dataPoint->GetTimeStamp() << std::endl;
     }
@@ -110,13 +124,12 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t stopParameter)
   if (fVerbose > 1) {
     std::cout << "-I- FairTSBufferFunctional::GetData: Read in up to entry: " << fBranchIndex << " with actualTime " << actualTime << " and requested stopParameter " << stopParameter << std::endl;
   }
-#endif
+
   return fOutputArray;
 }
 
 TClonesArray* FairTSBufferFunctional::GetData(Double_t startParameter, Double_t stopParameter)
 {
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)
   if (fStartFunction != 0) {
     fBufferArray->Clear();
     Int_t startIndex = FindStartIndex(startParameter);
@@ -126,7 +139,6 @@ TClonesArray* FairTSBufferFunctional::GetData(Double_t startParameter, Double_t
       fBufferArray->AbsorbObjects(fInputArray, startIndex, fInputArray->GetEntries() -1);
     }
   }
-#endif
   return GetData(stopParameter);
 }
 
@@ -134,7 +146,7 @@ Int_t FairTSBufferFunctional::FindStartIndex(Double_t startParameter)
 {
   FairTimeStamp* dataPoint;
   Int_t tempIndex = fBranchIndex;
-  Bool_t runBackwards = kTRUE;
+//  Bool_t runBackwards = kTRUE;
   Int_t previousIndex = -1;
   Int_t previousBranchIndex = -1;
 
@@ -147,7 +159,7 @@ Int_t FairTSBufferFunctional::FindStartIndex(Double_t startParameter)
 
   if (fInputArray->GetEntries() == 0) {         //If the previous entries in the tree are also empty run in the forward direction
     ReadInNextFilledEntry();
-    runBackwards = kFALSE;
+//    runBackwards = kFALSE;
   }
 
   if (fInputArray->GetEntries() == 0) {         //If there is still no data the branch is empty!
@@ -157,13 +169,13 @@ Int_t FairTSBufferFunctional::FindStartIndex(Double_t startParameter)
   fBranchIndex = tempIndex;
   //Now we have data or FindStartIndex already returned -1
 
-  dataPoint = (FairTimeStamp*)fInputArray->Last();
+  dataPoint = static_cast<FairTimeStamp*>(fInputArray->Last());
   //std::cout << "DataPoint: " << *dataPoint << std::endl;
   while(!(*fStartFunction)(dataPoint, startParameter)) {
     //std::cout << "DataPoint Search Entry: " << fBranchIndex << ": " << *dataPoint << std::endl;
     ReadInNextFilledEntry();
     if (fInputArray->GetEntries() != 0) {
-      dataPoint = (FairTimeStamp*)fInputArray->Last();
+      dataPoint = static_cast<FairTimeStamp*>(fInputArray->Last());
     } else {
       return -1;
     }
@@ -186,7 +198,7 @@ Int_t FairTSBufferFunctional::FindStartIndex(Double_t startParameter)
         return -1;
       }
     }
-    dataPoint = (FairTimeStamp*)fInputArray->At(startPos);
+    dataPoint = static_cast<FairTimeStamp*>(fInputArray->At(startPos));
   }
   fBranchIndex = previousBranchIndex;
   return previousIndex;
@@ -220,14 +232,12 @@ Int_t FairTSBufferFunctional::ReadInPreviousFilledEntry(Int_t startEntry)
 
 void FairTSBufferFunctional::AbsorbDataBufferArray()
 {
-#if ROOT_VERSION_CODE >= ROOT_VERSION(5,29,1)
   if (fInputArray->GetEntriesFast() > 0) {
     if (fVerbose > 1) {
       std::cout << "-I- FairTSBufferFunctional::ReadInNextFilledEntry: Absorb InputArray into Buffer" << std::endl;
     }
     fBufferArray->AbsorbObjects(fInputArray, 0, fInputArray->GetEntries() - 1);
   }
-#endif
 }
 
 void FairTSBufferFunctional::ReadInNextEntry()
@@ -244,7 +254,7 @@ void FairTSBufferFunctional::ReadInEntry(Int_t number)
   if (number < fBranch->GetEntries()) {
     fBranch->GetEntry(number);
     for (int i = 0; i < fInputArray->GetEntriesFast(); i++) {
-      ((FairTimeStamp*) fInputArray->At(i))->SetEntryNr(FairLink(0, number, FairRootManager::Instance()->GetBranchId(fBranch->GetName()), i, 1));
+      (static_cast<FairTimeStamp*>( fInputArray->At(i)))->SetEntryNr(FairLink(0, number, FairRootManager::Instance()->GetBranchId(fBranch->GetName()), i, 1));
     }
     if (fVerbose > 1)
       std::cout
@@ -256,6 +266,9 @@ void FairTSBufferFunctional::ReadInEntry(Int_t number)
 
 Bool_t FairTSBufferFunctional::AllDataProcessed()
 {
+  if (fTerminate == kTRUE){
+	return kTRUE;
+  }
   if (fBranchIndex + 1 >= fBranch->GetEntries()) {
     if(fBufferArray->GetEntriesFast() == 0) {
       if (fOutputArray->GetEntriesFast() == 0) {
diff --git a/base/FairTSBufferFunctional.h b/base/steer/FairTSBufferFunctional.h
similarity index 78%
rename from base/FairTSBufferFunctional.h
rename to base/steer/FairTSBufferFunctional.h
index 089e411..8cd8a6a 100644
--- a/base/FairTSBufferFunctional.h
+++ b/base/steer/FairTSBufferFunctional.h
@@ -1,16 +1,27 @@
-
-
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FairTSBufferFunctionalFunctional_H_
 #define FairTSBufferFunctionalFunctional_H_
 
-#include "FairTimeStamp.h"
+#include "FairTimeStamp.h"              // for FairTimeStamp
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, Bool_t, Double_t, etc
+#include "TObject.h"                    // for TObject
+#include "TString.h"                    // for TString
 
-#include "TObject.h"
-#include "TTree.h"
-#include "TBranch.h"
-#include "TClonesArray.h"
+#include <functional>                   // for binary_function
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+class TBranch;
+class TClonesArray;
+class TTree;
 
-#include <functional>
 
 /**
  * \class BinaryFunctor
@@ -24,6 +35,11 @@
  * The method TimeOut is used to break the processing if for example always the same data is requested.
  */
 
+#if defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Weffc++"
+#endif
+
 class BinaryFunctor : public std::binary_function<FairTimeStamp* ,double, bool>
 {
   public :
@@ -32,8 +48,14 @@ class BinaryFunctor : public std::binary_function<FairTimeStamp* ,double, bool>
     virtual bool TimeOut() {return false;}
     virtual void ResetTimeOut() {};
 
+    virtual ~BinaryFunctor() {};
+
 };
 
+#if defined(__GNUC__) || defined(__GNUG__)
+#pragma GCC diagnostic pop
+#endif
+
 /**
  * \class StopTime
  * Gives you all the data which is older than the given parameter StopTime.
@@ -147,9 +169,12 @@ class FairTSBufferFunctional : public TObject
     TClonesArray* GetData(Double_t stopParameter);
     TClonesArray* GetData(Double_t startParameter, Double_t stopParameter);
     Int_t GetBranchIndex() {return fBranchIndex;}
-    void SetStartFunction(BinaryFunctor* function) {fStartFunction=function;}
-    void SetStopFunction(BinaryFunctor* function) {fStopFunction = function;}
+
+    void SetBranchIndex(const Int_t val) { fBranchIndex = val; }
+    void SetStartFunction(BinaryFunctor* function) { fStartFunction = function;}
+    void SetStopFunction(BinaryFunctor* function)  { fStopFunction  = function;}
     Bool_t AllDataProcessed();
+    void Terminate(){ fTerminate = kTRUE; }
 
     Bool_t TimeOut() {
       Bool_t stopTimeOut = fStopFunction->TimeOut();
@@ -185,7 +210,8 @@ class FairTSBufferFunctional : public TObject
 
     TBranch* fBranch;
     Int_t fBranchIndex;
-    Int_t fStartIndex;
+
+    Bool_t fTerminate;
 
     Int_t fVerbose;
 
diff --git a/base/FairTask.cxx b/base/steer/FairTask.cxx
similarity index 53%
rename from base/FairTask.cxx
rename to base/steer/FairTask.cxx
index 8107753..c6c7c38 100644
--- a/base/FairTask.cxx
+++ b/base/steer/FairTask.cxx
@@ -1,12 +1,26 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                        FairTask source file                   -----
 // -----          Created 12/01/04  by M. Al-Turany / D. Bertini       -----
 // -------------------------------------------------------------------------
 
 #include "FairTask.h"
-#include "FairLogger.h"
 
-#include <iostream>
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairMonitor.h"                // for FairMonitor
+
+#include "TCollection.h"                // for TIter
+#include "TList.h"                      // for TList
+#include "TObject.h"                    // for TObject
+
+#include <iostream>                     // for cout, endl
+
 using std::cout;
 using std::endl;
 
@@ -15,7 +29,8 @@ FairTask::FairTask()
   : TTask(),
     fVerbose(0),
     fInputPersistance(-1),
-    fLogger(FairLogger::GetLogger())
+    fLogger(FairLogger::GetLogger()),
+    fOutputPersistance()
 {
 }
 // -------------------------------------------------------------------------
@@ -27,7 +42,8 @@ FairTask::FairTask(const char* name, Int_t iVerbose)
   : TTask(name, "FairTask"),
     fVerbose(iVerbose),
     fInputPersistance(-1),
-    fLogger(FairLogger::GetLogger())
+    fLogger(FairLogger::GetLogger()),
+    fOutputPersistance()
 {
 
 }
@@ -44,12 +60,14 @@ FairTask::~FairTask() { }
 // -----   Public method InitTask   ----------------------------------------
 void FairTask::InitTask()
 {
+  FairMonitor::GetMonitor()->SetCurrentTask(this);
   if ( ! fActive ) { return; }
   InitStatus tStat = Init();
   if ( tStat == kFATAL ) {
     fLogger->Fatal(MESSAGE_ORIGIN,"Initialization of Task %s failed fatally", fName.Data());
   }
   if ( tStat == kERROR ) { fActive = kFALSE; }
+  FairMonitor::GetMonitor()->SetCurrentTask(0);
   InitTasks();
 }
 // -------------------------------------------------------------------------
@@ -121,6 +139,87 @@ void FairTask::InitTasks()
 }
 // -------------------------------------------------------------------------
 
+//______________________________________________________________________________
+void FairTask::ExecuteTask(Option_t *option)
+{
+   // Execute main task and its subtasks.
+   // When calling this function, the Exec function of the corresponding class
+   // is invoked, then the list of its subtasks is executed calling recursively
+   // all the subtasks, etc.
+   //
+   // The option parameter may be used to select different execution steps
+   // within a task. This parameter is passed also to all the subtasks.
+
+   if (fgBeginTask) {
+      Error("ExecuteTask","Cannot execute task:%s, already running task: %s",GetName(),fgBeginTask->GetName());
+      return;
+   }
+   if (!IsActive()) return;
+
+   fOption = option;
+   fgBeginTask = this;
+   fgBreakPoint = 0;
+
+   if (fBreakin) return;
+   if (gDebug > 1) {
+     LOG(INFO)<<"Execute task:"<<GetName()<<" : "<<GetTitle()<<FairLogger::endl;
+   }
+   FairMonitor::GetMonitor()->StartMonitoring(this,"EXEC");
+   Exec(option);
+   FairMonitor::GetMonitor()->StopMonitoring(this,"EXEC");
+
+
+   fHasExecuted = kTRUE;
+   ExecuteTasks(option);
+
+   if (fBreakout) return;
+
+   if (!fgBreakPoint) {
+      fgBeginTask->CleanTasks();
+      fgBeginTask = 0;
+   }
+}
+// -------------------------------------------------------------------------
+
+//______________________________________________________________________________
+void FairTask::ExecuteTasks(Option_t *option)
+{
+   // Execute all the subtasks of a task.
+
+   TIter next(fTasks);
+   FairTask *task;
+   while((task=static_cast<FairTask*>(next()))) {
+      if (fgBreakPoint) return;
+      if (!task->IsActive()) continue;
+      if (task->fHasExecuted) {
+         task->ExecuteTasks(option);
+         continue;
+      }
+      if (task->fBreakin == 1) {
+         printf("Break at entry of task: %s\n",task->GetName());
+         fgBreakPoint = this;
+         task->fBreakin++;
+         return;
+      }
+
+      if (gDebug > 1) {
+	LOG(INFO)<<"Execute task:"<<task->GetName()<<" : "<<task->GetTitle()<<FairLogger::endl;
+      }
+      FairMonitor::GetMonitor()->StartMonitoring(task,"EXEC");
+      task->Exec(option);
+      FairMonitor::GetMonitor()->StopMonitoring(task,"EXEC");
+
+      task->fHasExecuted = kTRUE;
+      task->ExecuteTasks(option);
+      if (task->fBreakout == 1) {
+	printf("Break at exit of task: %s\n",task->GetName());
+	fgBreakPoint = this;
+	task->fBreakout++;
+	return;
+      }
+   }
+}
+// -------------------------------------------------------------------------
 
 
 // -----   Protected method ReInitTasks   ----------------------------------
@@ -164,5 +263,19 @@ void FairTask::FinishEvents()
 }
 // -------------------------------------------------------------------------
 
+void FairTask::SetOutputBranchPersistent(TString branchName, Bool_t persistence)
+{
+  fOutputPersistance.insert ( std::pair<TString,Bool_t>(branchName, persistence) );
+}
+
+Bool_t FairTask::IsOutputBranchPersistent(TString branchName)
+{  
+  std::map<TString, Bool_t>::iterator it = fOutputPersistance.find(branchName);
+  if (it != fOutputPersistance.end()) {
+    return it->second;
+  } else {
+    return kTRUE;
+  }
+}
 
 ClassImp(FairTask)
diff --git a/base/FairTask.h b/base/steer/FairTask.h
similarity index 68%
rename from base/FairTask.h
rename to base/steer/FairTask.h
index 43a36b0..36f0f4e 100644
--- a/base/FairTask.h
+++ b/base/steer/FairTask.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairTask header file                      -----
 // -----          Created 12/01/04  by M. Al-Turany / D. Bertini       -----
@@ -15,10 +22,16 @@
 #ifndef FAIRTASK_H
 #define FAIRTASK_H
 
-#include "FairLogger.h"
-#include "FairRootManager.h"
+#include "TTask.h"                      // for TTask
 
-#include "TTask.h"
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Rtypes.h"                     // for Int_t, FairTask::Class, etc
+#include "TString.h"                    // for TString
+
+#include <map>
+
+class FairLogger;
 
 enum InitStatus {kSUCCESS, kERROR, kFATAL};
 
@@ -71,6 +84,17 @@ class FairTask : public TTask
       fInputPersistance = ioman->CheckBranch(branchName);
     }
 
+    virtual void  ExecuteTask(Option_t *option="0");  // *MENU*
+
+    /** Set persistency of branch with given name true or false
+     *  In case is is set to false the branch will not be written to the output.
+    **/   
+    void SetOutputBranchPersistent(TString, Bool_t);
+
+    /** Check if the branch with the given name is persistent.
+     *  If the branch is not in the map, the default return value is true.
+    **/  
+    Bool_t IsOutputBranchPersistent(TString);
 
   protected:
 
@@ -106,10 +130,10 @@ class FairTask : public TTask
     /** Recursive intialisation of subtasks at begin of run **/
     void InitTasks();
 
-
     /** Recursive reinitialisation of subtasks **/
     void ReInitTasks();
 
+    virtual void  ExecuteTasks(Option_t *option);
 
     /** Recursive parameter initialisation for subtasks **/
     void SetParTasks();
@@ -121,10 +145,13 @@ class FairTask : public TTask
     void FinishEvents();
 
   private:
+
+    std::map<TString, Bool_t> fOutputPersistance;
+
     FairTask(const FairTask&);
     FairTask& operator=(const FairTask&);
 
-    ClassDef(FairTask,2);
+    ClassDef(FairTask,3);
 
 };
 
diff --git a/base/FairTrajFilter.cxx b/base/steer/FairTrajFilter.cxx
similarity index 81%
rename from base/FairTrajFilter.cxx
rename to base/steer/FairTrajFilter.cxx
index f597015..4ca5ac7 100644
--- a/base/FairTrajFilter.cxx
+++ b/base/steer/FairTrajFilter.cxx
@@ -1,15 +1,32 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // ********************************************* //
 // ***        D. Kresan   2004-Sep-14        *** //
 // ***        D.Kresan@gsi.de                *** //
 // ********************************************* //
 
-#include <iostream>
+#include "FairTrajFilter.h"
 
-#include "TParticle.h"
+#include "FairRootManager.h"            // for FairRootManager
 
-#include "FairTrajFilter.h"
-#include "FairRootManager.h"
-#include "TMath.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TClonesArray.h"               // for TClonesArray
+#include "TError.h"                     // for Fatal
+#include "TGeoTrack.h"                  // for TGeoTrack
+#include "TMath.h"                      // for Pi, TwoPi, Log
+#include "TMathBase.h"                  // for Abs
+#include "TParticle.h"                  // for TParticle
+#include "TGeoManager.h"
+#include "TGeoVolume.h"
+#include "TGeoBBox.h"
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using namespace std;
 
@@ -145,10 +162,15 @@ Bool_t FairTrajFilter::IsAccepted(const TParticle* p) const
 void FairTrajFilter::SetVertexCut(Double_t vxMin, Double_t vyMin, Double_t vzMin,
                                   Double_t vxMax, Double_t vyMax, Double_t vzMax)
 {
+  TGeoBBox* cave = static_cast<TGeoBBox*>(gGeoManager->GetTopVolume()->GetShape());
+  cave->ComputeBBox();
+  Double_t caveX = 2.*cave->GetDX();
+  Double_t caveY = 2.*cave->GetDY();
+  Double_t caveZ = 2.*cave->GetDZ();
   if( (vxMax<vxMin) || (vyMax<vyMin) || (vzMax<vzMin) ||
-      (TMath::Abs(vxMin)>2000.) || (TMath::Abs(vxMax)>2000.) ||
-      (TMath::Abs(vyMin)>2000.) || (TMath::Abs(vyMax)>2000.) ||
-      (TMath::Abs(vzMin)>2000.) || (TMath::Abs(vzMax)>2000.) ) {
+      (TMath::Abs(vxMin)>caveX) || (TMath::Abs(vxMax)>caveX) ||
+      (TMath::Abs(vyMin)>caveY) || (TMath::Abs(vyMax)>caveY) ||
+      (TMath::Abs(vzMin)>caveZ) || (TMath::Abs(vzMax)>caveZ) ) {
     cout << "-E- FairTrajFilter::SetVertexCut() : invalid region, ignoring." << endl;
     return;
   }
@@ -321,7 +343,7 @@ TGeoTrack* FairTrajFilter::AddTrack(TParticle* p)
 TGeoTrack* FairTrajFilter::GetTrack(Int_t trackId)
 {
 
-  return (TGeoTrack*)fTrackCollection->At(trackId);
+  return static_cast<TGeoTrack*>(fTrackCollection->At(trackId));
 }
 
 
diff --git a/base/FairTrajFilter.h b/base/steer/FairTrajFilter.h
similarity index 90%
rename from base/FairTrajFilter.h
rename to base/steer/FairTrajFilter.h
index 50f6fff..0f69100 100644
--- a/base/FairTrajFilter.h
+++ b/base/steer/FairTrajFilter.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // ********************************************* //
 // ***        D. Kresan   2004-Sep-14        *** //
 // ***        D.Kresan@gsi.de                *** //
@@ -6,15 +13,14 @@
 #ifndef FAIR_TRAJ_FILTER_H
 #define FAIR_TRAJ_FILTER_H 1
 
+#include "Rtypes.h"                     // for Double_t, Bool_t, Int_t, etc
+#include "TGeoTrack.h"                  // IWYU pragma: keep needed by cint
+#include "TMath.h"                      // for Pi, TwoPi
+#include "TString.h"                    // for TString
 
-#include "Rtypes.h"
-#include "TClonesArray.h"
-#include "TGeoTrack.h"
-#include "TMath.h"
-
+class TClonesArray;
 class TParticle;
 
-
 /**
  * @class FairTrajFilter
  * The filter for storing of the trajectories.
diff --git a/base/FairWriteoutBuffer.cxx b/base/steer/FairWriteoutBuffer.cxx
similarity index 65%
rename from base/FairWriteoutBuffer.cxx
rename to base/steer/FairWriteoutBuffer.cxx
index 30d20ce..b1925b6 100644
--- a/base/FairWriteoutBuffer.cxx
+++ b/base/steer/FairWriteoutBuffer.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * FairWriteoutBuffer.cpp
  *
@@ -6,18 +13,24 @@
  */
 
 #include "FairWriteoutBuffer.h"
-#include "FairRootManager.h"
-#include "TClonesArray.h"
-#include <iostream>
 
+#include "FairLogger.h"                 // for FairLogger
+#include "FairRootManager.h"            // for FairRootManager
+
+#include <iostream>                     // for operator<<, ostream, cout, etc
+#include <iterator>                     // for reverse_iterator
+
+//_____________________________________________________________________________
 FairWriteoutBuffer::FairWriteoutBuffer(TString branchName, TString className, TString folderName, Bool_t persistance)
   : TObject(),
+    fStartTime_map(),
     fDeadTime_map(),
     fBranchName(branchName),
     fClassName(className),
     fTreeSave(true),
     fActivateBuffering(kTRUE),
-    fVerbose(0)
+    fVerbose(0),
+    fLogger(FairLogger::GetLogger())
 {
   FairRootManager::Instance()->Register(branchName, className, folderName, persistance);
   if (fBranchName == "" || fClassName == "") {
@@ -26,6 +39,7 @@ FairWriteoutBuffer::FairWriteoutBuffer(TString branchName, TString className, TS
     fTreeSave = true;
   }
 }
+//_____________________________________________________________________________
 
 void FairWriteoutBuffer::WriteOutData(double time)
 {
@@ -56,6 +70,7 @@ void FairWriteoutBuffer::WriteOutData(double time)
   }
 
 }
+//_____________________________________________________________________________
 
 void FairWriteoutBuffer::WriteOutDataDeadTimeMap(double time)
 {
@@ -74,19 +89,21 @@ void FairWriteoutBuffer::WriteOutDataDeadTimeMap(double time)
       if (fVerbose > 0) {
         std::cout << "-I- FairWriteoutBuffer::WriteOutData size: " << data.size() << std::endl;
       }
-      for (int i = 0; i < data.size(); i++) {
+      for (unsigned int i = 0; i < data.size(); i++) {
         AddNewDataToTClonesArray(data[i]);
         if (fVerbose > 1) {
           std::cout << i << " : ";
           data[i]->Print();
           std::cout << std::endl;
         }
+        delete data[i];
       }
     }
   } else {
     ioman->GetTClonesArray(fBranchName);
   }
 }
+//_____________________________________________________________________________
 
 void FairWriteoutBuffer::WriteOutAllData()
 {
@@ -107,6 +124,7 @@ void FairWriteoutBuffer::WriteOutAllData()
     WriteOutData(ultimateTime);
   }
 }
+//_____________________________________________________________________________
 
 std::vector<FairTimeStamp*> FairWriteoutBuffer::GetRemoveOldData(double time)
 {
@@ -122,6 +140,7 @@ std::vector<FairTimeStamp*> FairWriteoutBuffer::GetRemoveOldData(double time)
   fDeadTime_map.erase(fDeadTime_map.begin(), fDeadTime_map.lower_bound(time));
   return result;
 }
+//_____________________________________________________________________________
 
 std::vector<FairTimeStamp*> FairWriteoutBuffer::GetAllData()
 {
@@ -130,24 +149,28 @@ std::vector<FairTimeStamp*> FairWriteoutBuffer::GetAllData()
 
 void FairWriteoutBuffer::FillNewData(FairTimeStamp* data, double startTime, double activeTime)
 {
+  FairTimeStamp* dataClone = static_cast<FairTimeStamp*>(data->Clone());
+
   if (fActivateBuffering) {
     if (fVerbose > 0) {
       std::cout << "StartTime: " << startTime << std::endl;
     }
-    std::pair<double, FairTimeStamp*> timeData(activeTime, data);
+    std::pair<double, FairTimeStamp*> timeData(activeTime, dataClone);
     fStartTime_map.insert(std::pair<double, std::pair<double, FairTimeStamp*> >(startTime, timeData));
   } else {
-    AddNewDataToTClonesArray(data);
+    AddNewDataToTClonesArray(dataClone);
+    delete dataClone;
   }
 
 }
+//_____________________________________________________________________________
 
-void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime)
+void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime, double startTime)
 {
   if (fActivateBuffering) {
     typedef  std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
-    typedef  std::map<FairTimeStamp, double>::iterator DataMapIter;
-
+//    typedef  std::map<FairTimeStamp, double>::iterator DataMapIter;
+    if (activeTime < 0) activeTime = 0; // to avoid errors due to wrong (negative) returnvalues of overwritten modify function by subdetector groups. A negative (-1) aktiveTime already indicate empty data maps!
     double timeOfOldData = FindTimeForData(data);
     // PrintDeadTimeMap();
     if(timeOfOldData > -1) {        //if an older active data object is already present
@@ -182,13 +205,19 @@ void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activ
       }
 
       if (dataFound == true) {
-        std::vector<std::pair<double, FairTimeStamp*> > modifiedData = Modify(std::pair<double, FairTimeStamp*>(currentdeadtime, oldData), std::pair<double, FairTimeStamp*>(-1, data));
-        for (int i = 0; i < modifiedData.size(); i++) {
-          FillDataToDeadTimeMap(modifiedData[i].second, modifiedData[i].first);
-          if (fVerbose > 1) {
-            std::cout << i << " :Modified Data: " << modifiedData[i].first << " : " << modifiedData[i].second << std::endl;
-          }
-        }
+	if (timeOfOldData > startTime) {                                     //if older active data can interference with the new data call modify function
+	  std::vector<std::pair<double, FairTimeStamp*> > modifiedData = Modify(std::pair<double, FairTimeStamp*>(currentdeadtime, oldData), std::pair<double, FairTimeStamp*>(activeTime, data));
+	  for (unsigned int i = 0; i < modifiedData.size(); i++) {
+	    FillDataToDeadTimeMap(modifiedData[i].second, modifiedData[i].first,0);//startTime  = 0 since the Maps are already empty and the startTime therefore doesn't matter anymore
+	    if (fVerbose > 1) {
+	      std::cout << i << " :Modified Data: " << modifiedData[i].first << " : " << modifiedData[i].second << std::endl;
+	    }
+	  }
+	} else {                           //no interference can happen between old hit and new hit
+	  AddNewDataToTClonesArray(oldData);    //therefore the old hit is written out
+	  fDeadTime_map.insert(std::pair<double, FairTimeStamp*>(activeTime, data));      //and the new hit is stored
+	  FillDataMap(data, activeTime);
+	}
       } else {
         std::cout << "-E- FairWriteoutBuffer::FillDataToDeadTimeMap: old data present in dataMap but not in deadTimeMap!" << std::endl;
       }
@@ -204,8 +233,10 @@ void FairWriteoutBuffer::FillDataToDeadTimeMap(FairTimeStamp* data, double activ
     }
   } else {
     AddNewDataToTClonesArray(data);
+    delete data;
   }
 }
+//_____________________________________________________________________________
 
 void FairWriteoutBuffer::MoveDataFromStartTimeMapToDeadTimeMap(double time)
 {
@@ -214,10 +245,12 @@ void FairWriteoutBuffer::MoveDataFromStartTimeMapToDeadTimeMap(double time)
   startTimeMapIter stopTime = fStartTime_map.lower_bound(time);
   for (startTimeMapIter iter = fStartTime_map.begin(); iter != stopTime; iter++) {
     std::pair<double, FairTimeStamp*> data = iter->second;
-    FillDataToDeadTimeMap(data.second, data.first);
+    double startTime = iter->first;
+    FillDataToDeadTimeMap(data.second, data.first, startTime);
   }
   fStartTime_map.erase(fStartTime_map.begin(), stopTime);
 }
+//_____________________________________________________________________________
 
 void FairWriteoutBuffer::PrintStartTimeMap()
 {
@@ -229,7 +262,7 @@ void FairWriteoutBuffer::PrintStartTimeMap()
   }
   std::cout << " |" << std::endl;
 }
-
+//_____________________________________________________________________________
 void FairWriteoutBuffer::PrintDeadTimeMap()
 {
   typedef  std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
@@ -241,6 +274,7 @@ void FairWriteoutBuffer::PrintDeadTimeMap()
   }
   std::cout << std::endl;
 }
+//_____________________________________________________________________________
 
 
 ClassImp(FairWriteoutBuffer);
diff --git a/base/FairWriteoutBuffer.h b/base/steer/FairWriteoutBuffer.h
similarity index 60%
rename from base/FairWriteoutBuffer.h
rename to base/steer/FairWriteoutBuffer.h
index 4c3685d..39b257b 100644
--- a/base/FairWriteoutBuffer.h
+++ b/base/steer/FairWriteoutBuffer.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /**
  * @class FairWriteoutBuffer
  *
@@ -24,40 +31,59 @@
 #ifndef FairWriteoutBuffer_H_
 #define FairWriteoutBuffer_H_
 
+#include "TObject.h"                    // for TObject
 
+#include "FairLogger.h"                 // for FairLogger
+#include "FairRootManager.h"            // for FairRootManager
+#include "FairTimeStamp.h"              // for FairTimeStamp
 
-#include "TObject.h"
-#include "TString.h"
-//#include "FairWriteoutBufferAbsBasis.h"
-#include "FairTimeStamp.h"
-#include <map>
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Bool_t, Int_t, etc
+#include "TClonesArray.h"               // for TClonesArray
+#include "TString.h"                    // for TString
 
+#include <iostream>                     // for cout, ostream
+#include <map>                          // for multimap
+#include <utility>                      // for pair
+#include <vector>                       // for vector
 
 class FairWriteoutBuffer: public TObject
 {
   public:
     FairWriteoutBuffer() : TObject(), fStartTime_map(), fDeadTime_map(), fBranchName(), fClassName(),
-      fTreeSave(false), fActivateBuffering(kFALSE), fVerbose(0) {};
+      fTreeSave(false), fActivateBuffering(kFALSE), fVerbose(0), fLogger(FairLogger::GetLogger()) {};
     FairWriteoutBuffer(TString branchName, TString className, TString folderName, Bool_t persistance);
     virtual ~FairWriteoutBuffer() {};
 
-    virtual void SaveDataToTree(Bool_t val = kTRUE) {fTreeSave = val;}    ///< If SaveDataToTree is set the data is stored at the end of the buffering into the given TClonesArray.
-    virtual void ActivateBuffering(Bool_t val = kTRUE) {fActivateBuffering=val;} ///< fActivateBuffering has to be set to kTRUE to use the buffering. Otherwise the data is directly stored in the given TClonesArray.
+    virtual void SaveDataToTree(Bool_t val = kTRUE) {
+      fTreeSave = val;   ///< If SaveDataToTree is set the data is stored at the end of the buffering into the given TClonesArray.
+    }
+    virtual void ActivateBuffering(Bool_t val = kTRUE) {
+      fActivateBuffering=val;   ///< fActivateBuffering has to be set to kTRUE to use the buffering. Otherwise the data is directly stored in the given TClonesArray.
+    }
 
+   Bool_t IsBufferingActivated(){ return fActivateBuffering;}
+  
 /// Fills a pointer to a data object into the buffer. StartTime gives the time when the data can influence later data, activeTime gives the time how long the data can influence later data.
 /// Both time data has to be given as an absolute time!
     virtual void FillNewData(FairTimeStamp* data, double startTime, double activeTime);
 
-    virtual Int_t GetNData() {return fDeadTime_map.size();}
+    virtual Int_t GetNData() {
+      return fDeadTime_map.size();
+    }
     virtual std::vector<FairTimeStamp*> GetRemoveOldData(double time);
     virtual std::vector<FairTimeStamp*> GetAllData();
 
 
-    virtual void SetVerbose(Int_t val) {fVerbose = val;}
+    virtual void SetVerbose(Int_t val) {
+      fVerbose = val;
+    }
 
     virtual void DeleteOldData() {
-      TClonesArray* myArray = FairRootManager::Instance()->GetTClonesArray(fBranchName);
-      myArray->Delete();
+      if ( fBranchName.Length() > 0 ) {
+        TClonesArray* myArray = FairRootManager::Instance()->GetTClonesArray(fBranchName);
+        myArray->Delete();
+      }
     }
 
     virtual void WriteOutData(double time);
@@ -72,7 +98,7 @@ class FairWriteoutBuffer: public TObject
 
     ///Modify defines the behavior of the buffer if data should be stored which is already in the buffer. Parameters are the old data with the active time, the new data with an active time.
     ///Modify returns than a vector with the new data which should be stored.
-    virtual std::vector<std::pair<double, FairTimeStamp*> > Modify(std::pair<double, FairTimeStamp*> oldData, std::pair<double, FairTimeStamp*> newData) {
+    virtual std::vector<std::pair<double, FairTimeStamp*> > Modify(std::pair<double, FairTimeStamp*> oldData, std::pair<double, FairTimeStamp*>) {
       std::vector<std::pair<double, FairTimeStamp*> > result;
       result.push_back(oldData);
       return result;
@@ -81,9 +107,11 @@ class FairWriteoutBuffer: public TObject
 
     virtual void WriteOutDataDeadTimeMap(double time);
     virtual void MoveDataFromStartTimeMapToDeadTimeMap(double time);
-    virtual void FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime);
+    virtual void FillDataToDeadTimeMap(FairTimeStamp* data, double activeTime, double startTime);
 
-    virtual void PrintData(FairTimeStamp* data) {std::cout << data->GetTimeStamp();}; ///< Method should be overwritten in derived classes to print the data of an object stored in the buffer
+    virtual void PrintData(FairTimeStamp* data) {
+      std::cout << data->GetTimeStamp();
+    }; ///< Method should be overwritten in derived classes to print the data of an object stored in the buffer
     virtual void PrintDeadTimeMap();
     virtual void PrintStartTimeMap();
 
@@ -95,6 +123,12 @@ class FairWriteoutBuffer: public TObject
     Bool_t fTreeSave;
     Bool_t fActivateBuffering;
     Int_t fVerbose;
+    FairLogger* fLogger;  //! /// FairLogger
+
+  private:
+    FairWriteoutBuffer(const FairWriteoutBuffer&);
+    FairWriteoutBuffer& operator=(const FairWriteoutBuffer&);
+
     ClassDef(FairWriteoutBuffer, 1);
 };
 
diff --git a/base/steer/FairWriteoutBufferAbsBasis.h b/base/steer/FairWriteoutBufferAbsBasis.h
new file mode 100644
index 0000000..3647e50
--- /dev/null
+++ b/base/steer/FairWriteoutBufferAbsBasis.h
@@ -0,0 +1,32 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairWriteoutBufferAbsBasis.h
+ *
+ *  Created on: Jul 18, 2011
+ *      Author: stockman
+ */
+
+#ifndef FAIRWRITEOUTBUFFERABSBASIS_H_
+#define FAIRWRITEOUTBUFFERABSBASIS_H_
+
+#include "TObject.h"
+
+class FairWriteoutBufferAbsBasis : public TObject
+{
+  public:
+    virtual ~FairWriteoutBufferAbsBasis() {};
+
+    virtual void WriteOutData(double time) = 0;
+    virtual void WriteOutAllData() = 0;
+
+    ClassDef(FairWriteoutBufferAbsBasis,1)
+};
+
+
+#endif /* FAIRWRITEOUTBUFFERABSBASIS_H_ */
diff --git a/base/steer/README.md b/base/steer/README.md
new file mode 100644
index 0000000..84d81ca
--- /dev/null
+++ b/base/steer/README.md
@@ -0,0 +1,20 @@
+steer
+========
+
+The steering classes of the FairRoot are stored here.
+The `FairRun` class is the base of all data processors (`FairRunSim`, `FairRunAna`, `FairRunOnline`, `FairRunAnaProof`).
+
+<!---
+* `FairRunSim` manages the Monte Carlo simulations
+* `FairRunAna` manages the analysis/data processing
+* `FairRunOnline` to analyze data from `FairSource`
+* `FairRunAnaProof` manages the data analysis on the *PROOF* (Parallel ROOT Facility for parallel data processing on the event level)
+-->
+
+The `FairRootManager` takes care for the input-output communication in the run classes. The `FairTask` is the base class for the analysis code.
+
+The radiation length studies may be performed using the `FairRad...` classes.
+
+In order to visualize the simulated particle trajectories, one should SetStoreTraj(kTRUE) of the `FairRunSim` object. It is possible to implement cuts via the singleton `FairTrajFilter` class.
+
+The mother classes for the time based simulation are also located here (`FairWriteoutBuffer`, `FairRingSorter`, `FairRingSorterTask`). One finds here also the `FairTSBufferFunctional` providing realistic access to the time based simulated data for further analysis.
diff --git a/bbc/CMakeLists.txt b/bbc/CMakeLists.txt
index db7c665..a412b79 100644
--- a/bbc/CMakeLists.txt
+++ b/bbc/CMakeLists.txt
@@ -7,19 +7,18 @@ ${ROOT_INCLUDE_DIR}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
 ${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/bbc
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(BBC_SRCS
 MpdBbcGeo.cxx 
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 8e2019b..68022d7 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -1 +1,8 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 add_subdirectory(modules)
diff --git a/cmake/README.md b/cmake/README.md
new file mode 100644
index 0000000..117f79a
--- /dev/null
+++ b/cmake/README.md
@@ -0,0 +1,9 @@
+cmake
+========
+
+Steering classes for the `cmake` software that manages the build processes of the FairRoot software.
+
+* *modules* directory stores the functions responsible for the identification of the packages that FairRoot depends on;
+* *scripts* folder stores the functions that are checking the system requirements;
+* *cuda* contains cmake modules to find the CUDA Toolkit (http://www.nvidia.com/object/cuda_home_new.html) enabling parallel computations on the NVIDIA GPUs;
+* *checks* to test the cxx11 compatibility.
\ No newline at end of file
diff --git a/cmake/checks/CMakeLists.txt b/cmake/checks/CMakeLists.txt
old mode 100755
new mode 100644
index 6572579..fc93e49
--- a/cmake/checks/CMakeLists.txt
+++ b/cmake/checks/CMakeLists.txt
@@ -1,32 +1,39 @@
-
-project("c++11_test")
-
-cmake_minimum_required(VERSION 2.8.2)
-
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}")
-include(CheckCXX11Features.cmake)
-
-# GCC specifics
-if(CMAKE_COMPILER_IS_GNUCXX)
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c++0x")
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
-endif()
-# Visual Studio specifics
-if(MSVC)
-  # Warning Level 4 for Debug builds
-  list(APPEND CMAKE_CXX_FLAGS_DEBUG " /W4")
-  list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS_DEBUG)
-endif()
-# Clang
-If(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c++11")
-  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
-EndIf()
-
-#add_executable(testme "demo.cpp")
-#foreach(flag ${CXX11_FEATURE_LIST})
-#  set_property(TARGET testme
-#	APPEND PROPERTY COMPILE_DEFINITIONS ${flag}
-#	)
-#endforeach()
-
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+
+project("c++11_test")
+
+cmake_minimum_required(VERSION 2.8.2)
+
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}")
+include(CheckCXX11Features.cmake)
+
+# GCC specifics
+if(CMAKE_COMPILER_IS_GNUCXX)
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c++0x")
+  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
+endif()
+# Visual Studio specifics
+if(MSVC)
+  # Warning Level 4 for Debug builds
+  list(APPEND CMAKE_CXX_FLAGS_DEBUG " /W4")
+  list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS_DEBUG)
+endif()
+# Clang
+If(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -std=c++11")
+  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -ggdb")
+EndIf()
+
+#add_executable(testme "demo.cpp")
+#foreach(flag ${CXX11_FEATURE_LIST})
+#  set_property(TARGET testme
+#	APPEND PROPERTY COMPILE_DEFINITIONS ${flag}
+#	)
+#endforeach()
+
diff --git a/cmake/checks/c++11-test-__func__-N2340.cpp b/cmake/checks/c++11-test-__func__-N2340.cpp
deleted file mode 100755
index c10dd18..0000000
--- a/cmake/checks/c++11-test-__func__-N2340.cpp
+++ /dev/null
@@ -1,8 +0,0 @@
-#include <cstring>
-
-int main()
-{
-	if (!__func__) { return 1; }
-	if(std::strlen(__func__) <= 0) { return 1; }
-	return 0;
-}
diff --git a/cmake/checks/c++11-test-nullptr-N2431.cpp b/cmake/checks/c++11-test-nullptr-N2431.cpp
deleted file mode 100755
index 6c5ae66..0000000
--- a/cmake/checks/c++11-test-nullptr-N2431.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-int main()
-{
-	int* test = nullptr;
-	return test ? 1 : 0;
-}
diff --git a/cmake/checks/c++11-test-static_assert-N1720_fail_compile.cpp b/cmake/checks/c++11-test-static_assert-N1720_fail_compile.cpp
deleted file mode 100755
index d97b679..0000000
--- a/cmake/checks/c++11-test-static_assert-N1720_fail_compile.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-int main()
-{
-	static_assert(1 < 0, "this should fail");
-	return 0;
-}
diff --git a/cmake/checks/cxx11-test-__func__.cpp b/cmake/checks/cxx11-test-__func__.cpp
new file mode 100755
index 0000000..3bfd8a8
--- /dev/null
+++ b/cmake/checks/cxx11-test-__func__.cpp
@@ -0,0 +1,8 @@
+int main(void)
+{
+	if (!__func__)
+		return 1;
+	if (!(*__func__))
+		return 1;
+	return 0;
+}
diff --git a/cmake/checks/c++11-test-auto-N2546.cpp b/cmake/checks/cxx11-test-auto.cpp
similarity index 93%
rename from cmake/checks/c++11-test-auto-N2546.cpp
rename to cmake/checks/cxx11-test-auto.cpp
index dbff414..948648e 100755
--- a/cmake/checks/c++11-test-auto-N2546.cpp
+++ b/cmake/checks/cxx11-test-auto.cpp
@@ -1,12 +1,12 @@
-
-int main()
-{
-	auto i = 5;
-	auto f = 3.14159f;
-	auto d = 3.14159;
-	bool ret = (
-		(sizeof(f) < sizeof(d)) &&
-		(sizeof(i) == sizeof(int))
-	);
-	return ret ? 0 : 1;
-}
+
+int main()
+{
+	auto i = 5;
+	auto f = 3.14159f;
+	auto d = 3.14159;
+	bool ret = (
+		(sizeof(f) < sizeof(d)) &&
+		(sizeof(i) == sizeof(int))
+	);
+	return ret ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-auto_fail_compile.cpp b/cmake/checks/cxx11-test-auto_fail_compile.cpp
new file mode 100644
index 0000000..3c0e3f2
--- /dev/null
+++ b/cmake/checks/cxx11-test-auto_fail_compile.cpp
@@ -0,0 +1,7 @@
+int main(void)
+{
+	// must fail because there is no initializer
+	auto i;
+
+	return 0;
+}
diff --git a/cmake/checks/cxx11-test-auto_ret_type.cpp b/cmake/checks/cxx11-test-auto_ret_type.cpp
new file mode 100644
index 0000000..937b683
--- /dev/null
+++ b/cmake/checks/cxx11-test-auto_ret_type.cpp
@@ -0,0 +1,8 @@
+auto foo(int i) -> int {
+	return i - 1;
+}
+
+int main()
+{
+	return foo(1);
+}
diff --git a/cmake/checks/cxx11-test-class_override_final.cpp b/cmake/checks/cxx11-test-class_override_final.cpp
new file mode 100644
index 0000000..5e938ff
--- /dev/null
+++ b/cmake/checks/cxx11-test-class_override_final.cpp
@@ -0,0 +1,21 @@
+class base {
+public:
+    virtual int foo(int a)
+     { return 4 + a; }
+    virtual int bar(int a) final
+     { return a - 2; }
+};
+
+class sub final : public base {
+public:
+    virtual int foo(int a) override
+     { return 8 + 2 * a; };
+};
+
+int main(void)
+{
+    base b;
+    sub s;
+
+    return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-class_override_final_fail_compile.cpp b/cmake/checks/cxx11-test-class_override_final_fail_compile.cpp
new file mode 100644
index 0000000..bc00b27
--- /dev/null
+++ b/cmake/checks/cxx11-test-class_override_final_fail_compile.cpp
@@ -0,0 +1,25 @@
+class base {
+public:
+    virtual int foo(int a)
+     { return 4 + a; }
+    virtual int bar(int a) final
+     { return a - 2; }
+};
+
+class sub final : public base {
+public:
+    virtual int foo(int a) override
+     { return 8 + 2 * a; };
+    virtual int bar(int a)
+     { return a; }
+};
+
+class impossible : public sub { };
+
+int main(void)
+{
+    base b;
+    sub s;
+
+    return 1;
+}
diff --git a/cmake/checks/c++11-test-constexpr-N2235.cpp b/cmake/checks/cxx11-test-constexpr.cpp
similarity index 92%
rename from cmake/checks/c++11-test-constexpr-N2235.cpp
rename to cmake/checks/cxx11-test-constexpr.cpp
index 9f969e4..ed62451 100755
--- a/cmake/checks/c++11-test-constexpr-N2235.cpp
+++ b/cmake/checks/cxx11-test-constexpr.cpp
@@ -1,19 +1,19 @@
-constexpr int square(int x)
-{
-	return x*x;
-}
-
-constexpr int the_answer()
-{
-	return 42;
-}
-
-int main()
-{
-	int test_arr[square(3)];
-	bool ret = (
-		(square(the_answer()) == 1764) &&
-		(sizeof(test_arr)/sizeof(test_arr[0]) == 9)
-	);
-	return ret ? 0 : 1;
-}
+constexpr int square(int x)
+{
+	return x*x;
+}
+
+constexpr int the_answer()
+{
+	return 42;
+}
+
+int main()
+{
+	int test_arr[square(3)];
+	bool ret = (
+		(square(the_answer()) == 1764) &&
+		(sizeof(test_arr)/sizeof(test_arr[0]) == 9)
+	);
+	return ret ? 0 : 1;
+}
diff --git a/cmake/checks/c++11-test-constructor-delegation-N1986.cpp b/cmake/checks/cxx11-test-constructor-delegation.cpp
similarity index 100%
rename from cmake/checks/c++11-test-constructor-delegation-N1986.cpp
rename to cmake/checks/cxx11-test-constructor-delegation.cpp
diff --git a/cmake/checks/c++11-test-cstdint.cpp b/cmake/checks/cxx11-test-cstdint.cpp
similarity index 87%
rename from cmake/checks/c++11-test-cstdint.cpp
rename to cmake/checks/cxx11-test-cstdint.cpp
index 58d4381..ca2c72d 100755
--- a/cmake/checks/c++11-test-cstdint.cpp
+++ b/cmake/checks/cxx11-test-cstdint.cpp
@@ -1,10 +1,11 @@
-#include <cstdint>
-int main()
-{
-	bool test = 
-		(sizeof(int8_t) == 1) &&
-		(sizeof(int16_t) == 2) &&
-		(sizeof(int32_t) == 4) &&
-		(sizeof(int64_t) == 8);
-	return test ? 0 : 1;
-}
+#include <cstdint>
+
+int main()
+{
+	bool test =
+		(sizeof(int8_t) == 1) &&
+		(sizeof(int16_t) == 2) &&
+		(sizeof(int32_t) == 4) &&
+		(sizeof(int64_t) == 8);
+	return test ? 0 : 1;
+}
diff --git a/cmake/checks/c++11-test-decltype-N2343.cpp b/cmake/checks/cxx11-test-decltype.cpp
similarity index 91%
rename from cmake/checks/c++11-test-decltype-N2343.cpp
rename to cmake/checks/cxx11-test-decltype.cpp
index d023885..0dbb1cc 100755
--- a/cmake/checks/c++11-test-decltype-N2343.cpp
+++ b/cmake/checks/cxx11-test-decltype.cpp
@@ -1,11 +1,10 @@
-
-bool check_size(int i)
-{
-	return sizeof(int) == sizeof(decltype(i));
-}
-
-int main()
-{
-	bool ret = check_size(42);
-	return ret ? 0 : 1;
-}
+bool check_size(int i)
+{
+	return sizeof(int) == sizeof(decltype(i));
+}
+
+int main()
+{
+	bool ret = check_size(42);
+	return ret ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-funcptr-to-lambda-conversion.cpp b/cmake/checks/cxx11-test-funcptr-to-lambda-conversion.cpp
new file mode 100644
index 0000000..c5b27b2
--- /dev/null
+++ b/cmake/checks/cxx11-test-funcptr-to-lambda-conversion.cpp
@@ -0,0 +1,26 @@
+
+// test funcptr to lambda conversion in such pattern. Some old compiler may not compile the following code
+// comment : direct lambda assignment to function ptr in the main() may still works for the same compilers, however.
+using func_type = int();
+struct A
+{
+    int foo(func_type* f)
+    {
+        return f();
+    }
+};
+
+struct B
+{
+    int bar(A& a) 
+    {
+        return a.foo([](){return 42;});
+    }
+};
+
+int main() 
+{
+    A a;
+    B b;
+    return (42==b.bar(a)) ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-initializer_list.cpp b/cmake/checks/cxx11-test-initializer_list.cpp
new file mode 100644
index 0000000..35e6c38
--- /dev/null
+++ b/cmake/checks/cxx11-test-initializer_list.cpp
@@ -0,0 +1,27 @@
+#include <vector>
+
+class seq {
+public:
+    seq(std::initializer_list<int> list);
+
+    int length() const;
+private:
+    std::vector<int> m_v;
+};
+
+seq::seq(std::initializer_list<int> list)
+    : m_v(list)
+{
+}
+
+int seq::length() const
+{
+    return m_v.size();
+}
+
+int main(void)
+{
+    seq a = {18, 20, 2, 0, 4, 7};
+
+    return (a.length() == 6) ? 0 : 1;
+}
diff --git a/cmake/checks/c++11-test-lambda-N2927.cpp b/cmake/checks/cxx11-test-lambda.cpp
similarity index 93%
rename from cmake/checks/c++11-test-lambda-N2927.cpp
rename to cmake/checks/cxx11-test-lambda.cpp
index b86ad17..4c33ed5 100755
--- a/cmake/checks/c++11-test-lambda-N2927.cpp
+++ b/cmake/checks/cxx11-test-lambda.cpp
@@ -1,5 +1,5 @@
-int main()
-{
-	int ret = 0;
-	return ([&ret]() -> int { return ret; })();
-}
+int main()
+{
+	int ret = 0;
+	return ([&ret]() -> int { return ret; })();
+}
diff --git a/cmake/checks/c++11-test-long_long-N1811.cpp b/cmake/checks/cxx11-test-long_long.cpp
similarity index 94%
rename from cmake/checks/c++11-test-long_long-N1811.cpp
rename to cmake/checks/cxx11-test-long_long.cpp
index 2ae6988..0911127 100755
--- a/cmake/checks/c++11-test-long_long-N1811.cpp
+++ b/cmake/checks/cxx11-test-long_long.cpp
@@ -1,7 +1,7 @@
-int main(void)
-{
-	long long l;
-	unsigned long long ul;
-
-	return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
-}
+int main(void)
+{
+	long long l;
+	unsigned long long ul;
+
+	return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-nullptr.cpp b/cmake/checks/cxx11-test-nullptr.cpp
new file mode 100755
index 0000000..9f41071
--- /dev/null
+++ b/cmake/checks/cxx11-test-nullptr.cpp
@@ -0,0 +1,6 @@
+int main(void)
+{
+	void *v = nullptr;
+
+	return v ? 1 : 0;
+}
diff --git a/cmake/checks/c++11-test-nullptr-N2431_fail_compile.cpp b/cmake/checks/cxx11-test-nullptr_fail_compile.cpp
similarity index 67%
rename from cmake/checks/c++11-test-nullptr-N2431_fail_compile.cpp
rename to cmake/checks/cxx11-test-nullptr_fail_compile.cpp
index 5747f1b..6a002bc 100755
--- a/cmake/checks/c++11-test-nullptr-N2431_fail_compile.cpp
+++ b/cmake/checks/cxx11-test-nullptr_fail_compile.cpp
@@ -1,5 +1,6 @@
-int main()
-{
-	int i = nullptr;
-	return 1;
-}
+int main(void)
+{
+	int i = nullptr;
+
+	return 1;
+}
diff --git a/cmake/checks/cxx11-test-regex.cpp b/cmake/checks/cxx11-test-regex.cpp
new file mode 100644
index 0000000..2fe01c4
--- /dev/null
+++ b/cmake/checks/cxx11-test-regex.cpp
@@ -0,0 +1,26 @@
+#include <algorithm>
+#include <regex>
+
+int parse_line(std::string const& line)
+{
+	std::string tmp;
+	if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
+		tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
+	} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
+		tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
+	} else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
+		tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
+	} else {
+		tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
+	}
+	return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
+}
+
+int main()
+{
+	bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
+				(parse_line("f 7//7 3//-3 -2//2") == 3) &&
+				(parse_line("f 7/7 3/-3 -2/2") == 3) &&
+				(parse_line("f 7 3 -2") == 3);
+	return test ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-rvalue-references.cpp b/cmake/checks/cxx11-test-rvalue-references.cpp
new file mode 100644
index 0000000..e6e7e5a
--- /dev/null
+++ b/cmake/checks/cxx11-test-rvalue-references.cpp
@@ -0,0 +1,57 @@
+#include <cassert>
+
+class rvmove {
+public:
+   void *ptr;
+   char *array;
+
+   rvmove()
+    : ptr(0),
+    array(new char[10])
+   {
+     ptr = this;
+   }
+
+   rvmove(rvmove &&other)
+    : ptr(other.ptr),
+    array(other.array)
+   {
+    other.array = 0;
+    other.ptr = 0;
+   }
+
+   ~rvmove()
+   {
+    assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0)));
+    delete[] array;
+   }
+
+   rvmove &operator=(rvmove &&other)
+   {
+     delete[] array;
+     ptr = other.ptr;
+     array = other.array;
+     other.array = 0;
+     other.ptr = 0;
+     return *this;
+   }
+
+   static rvmove create()
+   {
+     return rvmove();
+   }
+private:
+  rvmove(const rvmove &);
+  rvmove &operator=(const rvmove &);
+};
+
+int main()
+{
+  rvmove mine;
+  if (mine.ptr != &mine)
+    return 1;
+  mine = rvmove::create();
+  if (mine.ptr == &mine)
+    return 1;
+  return 0;
+}
diff --git a/cmake/checks/c++11-test-rvalue_references-N2118.cpp b/cmake/checks/cxx11-test-rvalue_references.cpp
similarity index 91%
rename from cmake/checks/c++11-test-rvalue_references-N2118.cpp
rename to cmake/checks/cxx11-test-rvalue_references.cpp
index ef4e421..75fb555 100755
--- a/cmake/checks/c++11-test-rvalue_references-N2118.cpp
+++ b/cmake/checks/cxx11-test-rvalue_references.cpp
@@ -1,15 +1,15 @@
-int foo(int& lvalue)
-{
-	return 123;
-}
-
-int foo(int&& rvalue)
-{
-	return 321;
-}
-
-int main()
-{
-	int i = 42;
-	return ((foo(i) == 123) && (foo(42) == 321)) ? 0 : 1;
-}
+int foo(int& lvalue)
+{
+	return 123;
+}
+
+int foo(int&& rvalue)
+{
+	return 321;
+}
+
+int main()
+{
+	int i = 42;
+	return ((foo(i) == 123) && (foo(42) == 321)) ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-sharedpointer.cpp b/cmake/checks/cxx11-test-sharedpointer.cpp
new file mode 100755
index 0000000..5ec3b40
--- /dev/null
+++ b/cmake/checks/cxx11-test-sharedpointer.cpp
@@ -0,0 +1,8 @@
+#include <memory>
+using std::shared_ptr;
+
+int main()
+{
+    
+    return 0;
+}
diff --git a/cmake/checks/c++11-test-sizeof_member-N2253.cpp b/cmake/checks/cxx11-test-sizeof_member.cpp
similarity index 71%
rename from cmake/checks/c++11-test-sizeof_member-N2253.cpp
rename to cmake/checks/cxx11-test-sizeof_member.cpp
index 3049ed1..4902fc7 100755
--- a/cmake/checks/c++11-test-sizeof_member-N2253.cpp
+++ b/cmake/checks/cxx11-test-sizeof_member.cpp
@@ -1,14 +1,14 @@
-struct foo {
-	char bar;
-	int baz;
-};
-
-int main(void)
-{
-	bool ret = (
-		(sizeof(foo::bar) == 1) &&
-		(sizeof(foo::baz) >= sizeof(foo::bar)) &&
-		(sizeof(foo) >= sizeof(foo::bar)+sizeof(foo::baz))
-	);
-	return ret ? 0 : 1;
-}
+struct foo {
+	char bar;
+	int baz;
+};
+
+int main(void)
+{
+	bool ret = (
+		(sizeof(foo::bar) == 1) &&
+		(sizeof(foo::baz) >= sizeof(foo::bar)) &&
+		(sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz))
+	);
+	return ret ? 0 : 1;
+}
diff --git a/cmake/checks/cxx11-test-sizeof_member_fail.cpp b/cmake/checks/cxx11-test-sizeof_member_fail.cpp
new file mode 100644
index 0000000..0348c2c
--- /dev/null
+++ b/cmake/checks/cxx11-test-sizeof_member_fail.cpp
@@ -0,0 +1,9 @@
+struct foo {
+	int baz;
+	double bar;
+};
+
+int main(void)
+{
+	return (sizeof(foo::bar) == 4) ? 0 : 1;
+}
diff --git a/cmake/checks/c++11-test-static_assert-N1720.cpp b/cmake/checks/cxx11-test-static_assert.cpp
similarity index 82%
rename from cmake/checks/c++11-test-static_assert-N1720.cpp
rename to cmake/checks/cxx11-test-static_assert.cpp
index eae3c9a..47c2fef 100755
--- a/cmake/checks/c++11-test-static_assert-N1720.cpp
+++ b/cmake/checks/cxx11-test-static_assert.cpp
@@ -1,5 +1,5 @@
-int main()
-{
-	static_assert(0 < 1, "your ordering of integers is screwed");
-	return 0;
-}
+int main(void)
+{
+	static_assert(0 < 1, "your ordering of integers is screwed");
+	return 0;
+}
diff --git a/cmake/checks/cxx11-test-static_assert_fail_compile.cpp b/cmake/checks/cxx11-test-static_assert_fail_compile.cpp
new file mode 100755
index 0000000..362fcdd
--- /dev/null
+++ b/cmake/checks/cxx11-test-static_assert_fail_compile.cpp
@@ -0,0 +1,5 @@
+int main(void)
+{
+	static_assert(1 < 0, "your ordering of integers is screwed");
+	return 0;
+}
diff --git a/cmake/checks/c++11-test-variadic_templates-N2555.cpp b/cmake/checks/cxx11-test-variadic_templates.cpp
similarity index 93%
rename from cmake/checks/c++11-test-variadic_templates-N2555.cpp
rename to cmake/checks/cxx11-test-variadic_templates.cpp
index 79fae84..4518e88 100755
--- a/cmake/checks/c++11-test-variadic_templates-N2555.cpp
+++ b/cmake/checks/cxx11-test-variadic_templates.cpp
@@ -1,23 +1,23 @@
-int Accumulate()
-{
-	return 0;
-}
-
-template<typename T, typename... Ts>
-int Accumulate(T v, Ts... vs)
-{
-	return v + Accumulate(vs...);
-}
-
-template<int... Is>
-int CountElements()
-{
-	return sizeof...(Is);
-}
-
-int main()
-{
-	int acc = Accumulate(1, 2, 3, 4, -5);
-	int count = CountElements<1,2,3,4,5>();
-	return ((acc == 5) && (count == 5)) ? 0 : 1;
-}
+int Accumulate()
+{
+	return 0;
+}
+
+template<typename T, typename... Ts>
+int Accumulate(T v, Ts... vs)
+{
+	return v + Accumulate(vs...);
+}
+
+template<int... Is>
+int CountElements()
+{
+	return sizeof...(Is);
+}
+
+int main()
+{
+	int acc = Accumulate(1, 2, 3, 4, -5);
+	int count = CountElements<1,2,3,4,5>();
+	return ((acc == 5) && (count == 5)) ? 0 : 1;
+}
diff --git a/cmake/checks/demo.cpp b/cmake/checks/demo.cpp
index 782681b..f647d15 100755
--- a/cmake/checks/demo.cpp
+++ b/cmake/checks/demo.cpp
@@ -1,23 +1,23 @@
-
-#include <iostream>
-
-int main()
-{
-	std::cout << "Testing\n";
-	std::cout << "Has static_assert: " <<
-#ifdef HAS_CXX11_STATIC_ASSERT
-		"yes :)"
-#else
-		"no"
-#endif
-		<< "\n";
-	std::cout << "Has variadic templates: " <<
-#ifdef HAS_CXX11_VARIADIC_TEMPLATES
-		"yes :)"
-#else
-		"no"
-#endif
-		<< "\n";
-	return 0;
-}
-
+
+#include <iostream>
+
+int main()
+{
+	std::cout << "Testing\n";
+	std::cout << "Has static_assert: " <<
+#ifdef HAS_CXX11_STATIC_ASSERT
+		"yes :)"
+#else
+		"no"
+#endif
+		<< "\n";
+	std::cout << "Has variadic templates: " <<
+#ifdef HAS_CXX11_VARIADIC_TEMPLATES
+		"yes :)"
+#else
+		"no"
+#endif
+		<< "\n";
+	return 0;
+}
+
diff --git a/cmake/cuda/FindCUDA.cmake b/cmake/cuda/FindCUDA.cmake
index 7487e64..21483dc 100644
--- a/cmake/cuda/FindCUDA.cmake
+++ b/cmake/cuda/FindCUDA.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Tools for building CUDA C files: libraries and build dependencies.
 # This script locates the NVIDIA CUDA C tools. It should work on linux, windows,
 # and mac and should be reasonably up to date with CUDA C releases.
diff --git a/cmake/cuda/FindCUDA/make2cmake.cmake b/cmake/cuda/FindCUDA/make2cmake.cmake
old mode 100755
new mode 100644
index d41b72d..5db0d21
--- a/cmake/cuda/FindCUDA/make2cmake.cmake
+++ b/cmake/cuda/FindCUDA/make2cmake.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 #  James Bigler, NVIDIA Corp (nvidia.com - jbigler)
 #  Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
 #
@@ -76,7 +83,7 @@ if (${depend_text} MATCHES ".+")
       list(APPEND dependency_list "${file_absolute}")
     endif()
 
-  endforeach(file)
+  endforeach()
 
 else()
   # message("FOUND NO DEPENDS")
diff --git a/cmake/cuda/FindCUDA/parse_cubin.cmake b/cmake/cuda/FindCUDA/parse_cubin.cmake
index 2518c68..bbc1c6b 100644
--- a/cmake/cuda/FindCUDA/parse_cubin.cmake
+++ b/cmake/cuda/FindCUDA/parse_cubin.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 #  James Bigler, NVIDIA Corp (nvidia.com - jbigler)
 #  Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
 #
@@ -65,11 +72,11 @@ if (${file_text} MATCHES ".+")
             # Skip the rest of this block.
             # message("Skipping ${entry}")
             # set(skip TRUE)
-          # else (${entry} MATCHES "^_")
+          # else ()
             message("Kernel:    ${entry}")
-          # endif (${entry} MATCHES "^_")
+          # endif ()
 
-        endif(${entry} MATCHES "[^g]name = ([^ ]+)")
+        endif()
 
         # Skip the rest of the block if necessary
         if(NOT skip)
@@ -96,14 +103,14 @@ if (${file_text} MATCHES ".+")
             message("")
           endif()
 
-        endif(NOT skip)
+        endif()
 
 
-      endforeach(entry)
+      endforeach()
 
-    endif(line MATCHES "^code")
+    endif()
 
-  endforeach(line)
+  endforeach()
 
 else()
   # message("FOUND NO DEPENDS")
diff --git a/cmake/cuda/FindCUDA/run_nvcc.cmake b/cmake/cuda/FindCUDA/run_nvcc.cmake
old mode 100755
new mode 100644
index b31011c..1b23106
--- a/cmake/cuda/FindCUDA/run_nvcc.cmake
+++ b/cmake/cuda/FindCUDA/run_nvcc.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 #  James Bigler, NVIDIA Corp (nvidia.com - jbigler)
 #
 #  Copyright (c) 2008 - 2009 NVIDIA Corporation.  All rights reserved.
@@ -49,6 +56,7 @@
 #
 # generated_cubin_file:STRING=<> File to generate.  This argument must be passed
 #                                                   in if build_cubin is true.
+# generate_dependency_only:BOOL=<> Only generate the dependency file.
 
 if(NOT generated_file)
   message(FATAL_ERROR "You must specify generated_file on the command line")
@@ -62,6 +70,7 @@ set(cmake_dependency_file "@cmake_dependency_file@") # path
 set(CUDA_make2cmake "@CUDA_make2cmake@") # path
 set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path
 set(build_cubin @build_cubin@) # bool
+set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # bool
 # We won't actually use these variables for now, but we need to set this, in
 # order to force this file to be run again if it changes.
 set(generated_file_path "@generated_file_path@") # path
@@ -102,8 +111,15 @@ endif()
 # Add the build specific configuration flags
 list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}})
 
-if(DEFINED CCBIN)
-  set(CCBIN -ccbin "${CCBIN}")
+# Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority
+list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 )
+list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 )
+if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 )
+  if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN)
+    set(CCBIN -ccbin "${CCBIN}")
+  else()
+    set(CCBIN -ccbin "${CUDA_HOST_COMPILER}")
+  endif()
 endif()
 
 # cuda_execute_process - Executes a command with optional command echo and status message.
@@ -139,7 +155,7 @@ macro(cuda_execute_process status command)
     endforeach()
     # Echo the command
     execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string})
-  endif(verbose)
+  endif()
   # Run the command
   execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result )
 endmacro()
@@ -217,14 +233,18 @@ endif()
 
 # Delete the temporary file
 cuda_execute_process(
-  "Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}"
-  COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}"
+  "Removing ${cmake_dependency_file}.tmp"
+  COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp"
   )
 
 if(CUDA_result)
   message(FATAL_ERROR "Error generating ${generated_file}")
 endif()
 
+if (generate_dependency_only)
+  return()
+endif()
+
 # Generate the code
 cuda_execute_process(
   "Generating ${generated_file}"
@@ -277,4 +297,4 @@ if( build_cubin )
     -P "${CUDA_parse_cubin}"
     )
 
-endif( build_cubin )
+endif()
diff --git a/cmake/modules/CheckCXX11Features.cmake b/cmake/modules/CheckCXX11Features.cmake
index a170268..ff7e763 100644
--- a/cmake/modules/CheckCXX11Features.cmake
+++ b/cmake/modules/CheckCXX11Features.cmake
@@ -1,109 +1,154 @@
-# Checks for C++11 features
-#  CXX11_FEATURE_LIST - a list containing all supported features
-#  HAS_CXX11_AUTO                   - auto keyword
-#  HAS_CXX11_NULLPTR                - nullptr
-#  HAS_CXX11_LAMBDA                 - lambdas
-#  HAS_CXX11_STATIC_ASSERT          - static_assert()
-#  HAS_CXX11_RVALUE_REFERENCES      - rvalue references
-#  HAS_CXX11_DECLTYPE               - decltype keyword
-#  HAS_CXX11_CSTDINT_H              - cstdint header
-#  HAS_CXX11_LONG_LONG              - long long signed & unsigned types
-#  HAS_CXX11_VARIADIC_TEMPLATES     - variadic templates
-#  HAS_CXX11_CONSTEXPR              - constexpr keyword
-#  HAS_CXX11_SIZEOF_MEMBER          - sizeof() non-static members
-#  HAS_CXX11_FUNC                   - __func__ preprocessor constant
-#  HAS_CXX11_CONSTRUCTOR_DELEGATION - constructor delegation
-#
-# Original script by Rolf Eike Beer
-# Modifications by Andreas Weis
-# More tests added by Florian Uhlig
-#
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8.2)
-
-SET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
-IF(CMAKE_COMPILER_IS_GNUCXX)
-	SET(CMAKE_CXX_FLAGS "-std=c++0x")
-endif()
-If(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-  set(CMAKE_CXX_FLAGS "-std=c++11")
-EndIf()
-
-MACRO(CXX11_CHECK_FEATURE FEATURE_NAME FEATURE_NUMBER RESULT_VAR)
-	IF (NOT DEFINED ${RESULT_VAR})
-		SET(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11/cxx11_${FEATURE_NAME}")
-
-		IF (${FEATURE_NUMBER})
-			SET(_SRCFILE_BASE ${CheckSrcDir}/c++11-test-${FEATURE_NAME}-N${FEATURE_NUMBER})
-			SET(_LOG_NAME "\"${FEATURE_NAME}\" (N${FEATURE_NUMBER})")
-		ELSE (${FEATURE_NUMBER})
-			SET(_SRCFILE_BASE ${CheckSrcDir}/c++11-test-${FEATURE_NAME})
-			SET(_LOG_NAME "\"${FEATURE_NAME}\"")
-		ENDIF (${FEATURE_NUMBER})
-		MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME}")
-
-		SET(_SRCFILE "${_SRCFILE_BASE}.cpp")
-		SET(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
-		SET(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
-
-		IF (CROSS_COMPILING)
-			try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}")
-			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-				try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}")
-			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-		ELSE (CROSS_COMPILING)
-			try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
-					"${_bindir}" "${_SRCFILE}")
-			IF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-				SET(${RESULT_VAR} TRUE)
-			ELSE (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-				SET(${RESULT_VAR} FALSE)
-			ENDIF (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
-			IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-				try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
-						"${_bindir}_fail" "${_SRCFILE_FAIL}")
-				IF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-					SET(${RESULT_VAR} TRUE)
-				ELSE (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-					SET(${RESULT_VAR} FALSE)
-				ENDIF (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
-			ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
-		ENDIF (CROSS_COMPILING)
-		IF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
-			try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}")
-			IF (_TMP_RESULT)
-				SET(${RESULT_VAR} FALSE)
-			ELSE (_TMP_RESULT)
-				SET(${RESULT_VAR} TRUE)
-			ENDIF (_TMP_RESULT)
-		ENDIF (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
-
-		IF (${RESULT_VAR})
-			MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- works")
-			LIST(APPEND CXX11_FEATURE_LIST ${RESULT_VAR})
-		ELSE (${RESULT_VAR})
-			MESSAGE(STATUS "Checking C++11 support for ${_LOG_NAME} -- not supported")
-		ENDIF (${RESULT_VAR})
-		SET(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
-	ENDIF (NOT DEFINED ${RESULT_VAR})
-ENDMACRO(CXX11_CHECK_FEATURE)
-
-CXX11_CHECK_FEATURE("auto"               2546 HAS_CXX11_AUTO)
-CXX11_CHECK_FEATURE("nullptr"            2431 HAS_CXX11_NULLPTR)
-CXX11_CHECK_FEATURE("lambda"             2927 HAS_CXX11_LAMBDA)
-CXX11_CHECK_FEATURE("static_assert"      1720 HAS_CXX11_STATIC_ASSERT)
-CXX11_CHECK_FEATURE("rvalue_references"  2118 HAS_CXX11_RVALUE_REFERENCES)
-CXX11_CHECK_FEATURE("decltype"           2343 HAS_CXX11_DECLTYPE)
-CXX11_CHECK_FEATURE("cstdint"            ""   HAS_CXX11_CSTDINT_H)
-CXX11_CHECK_FEATURE("long_long"          1811 HAS_CXX11_LONG_LONG)
-CXX11_CHECK_FEATURE("variadic_templates" 2555 HAS_CXX11_VARIADIC_TEMPLATES)
-CXX11_CHECK_FEATURE("constexpr"          2235 HAS_CXX11_CONSTEXPR)
-CXX11_CHECK_FEATURE("sizeof_member"      2253 HAS_CXX11_SIZEOF_MEMBER)
-CXX11_CHECK_FEATURE("__func__"           2340 HAS_CXX11_FUNC)
-CXX11_CHECK_FEATURE("constructor-delegation" 1986  HAS_CXX11_CONSTRUCTOR_DELEGATION)
-
-SET(CXX11_FEATURE_LIST ${CXX11_FEATURE_LIST} CACHE STRING "C++11 feature support list")
-MARK_AS_ADVANCED(FORCE CXX11_FEATURE_LIST)
-
-SET(CMAKE_CXX_FLAGS ${CHECK_CXX11_OLD_CMAKE_CXX_FLAGS})
-UNSET(CHECK_CXX11_OLD_CMAKE_CXX_FLAGS)
-
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+# - Check which parts of the C++11 standard the compiler supports
+#
+# When found it will set the following variables
+#
+#  CXX11_COMPILER_FLAGS         - the compiler flags needed to get C++11 features
+#
+#  HAS_CXX11_AUTO               - auto keyword
+#  HAS_CXX11_AUTO_RET_TYPE      - function declaration with deduced return types
+#  HAS_CXX11_CLASS_OVERRIDE     - override and final keywords for classes and methods
+#  HAS_CXX11_CONSTEXPR          - constexpr keyword
+#  HAS_CXX11_CSTDINT_H          - cstdint header
+#  HAS_CXX11_DECLTYPE           - decltype keyword
+#  HAS_CXX11_FUNC               - __func__ preprocessor constant
+#  HAS_CXX11_INITIALIZER_LIST   - initializer list
+#  HAS_CXX11_LAMBDA             - lambdas
+#  HAS_CXX11_LIB_REGEX          - regex library
+#  HAS_CXX11_LONG_LONG          - long long signed & unsigned types
+#  HAS_CXX11_NULLPTR            - nullptr
+#  HAS_CXX11_RVALUE_REFERENCES  - rvalue references
+#  HAS_CXX11_SIZEOF_MEMBER      - sizeof() non-static members
+#  HAS_CXX11_STATIC_ASSERT      - static_assert()
+#  HAS_CXX11_VARIADIC_TEMPLATES - variadic templates
+#  HAS_CXX11_SHAREDPOINTER      - shared pointer 
+
+#=============================================================================
+# Copyright 2011,2012 Rolf Eike Beer <eike@sf-mail.de>
+# Copyright 2012 Andreas Weis
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+#
+# Each feature may have up to 3 checks, every one of them in it's own file
+# FEATURE.cpp              - example that must build and return 0 when run
+# FEATURE_fail.cpp         - example that must build, but may not return 0 when run
+# FEATURE_fail_compile.cpp - example that must fail compilation
+#
+# The first one is mandatory, the latter 2 are optional and do not depend on
+# each other (i.e. only one may be present).
+#
+
+if (NOT CMAKE_CXX_COMPILER_LOADED)
+    message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled")
+endif ()
+
+cmake_minimum_required(VERSION 2.8.2)
+
+#
+### Check for needed compiler flags
+#
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG)
+if (NOT _HAS_CXX11_FLAG)
+    check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG)
+endif ()
+
+if (_HAS_CXX11_FLAG)
+    set(CXX11_COMPILER_FLAGS "-std=c++11")
+elseif (_HAS_CXX0X_FLAG)
+    set(CXX11_COMPILER_FLAGS "-std=c++0x")
+endif ()
+
+function(cxx11_check_feature FEATURE_NAME RESULT_VAR)
+    if (NOT DEFINED ${RESULT_VAR})
+        set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11/cxx11_${FEATURE_NAME}")
+
+        set(_SRCFILE_BASE ${CheckSrcDir}/cxx11-test-${FEATURE_NAME})
+        set(_LOG_NAME "\"${FEATURE_NAME}\"")
+        message(STATUS "Checking C++11 support for ${_LOG_NAME}")
+
+        set(_SRCFILE "${_SRCFILE_BASE}.cpp")
+        set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
+        set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
+
+        if (CROSS_COMPILING)
+            try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}"
+                        COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+            if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+                try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}"
+                            COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+            endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        else (CROSS_COMPILING)
+            try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+                    "${_bindir}" "${_SRCFILE}"
+                    COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+            if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+                set(${RESULT_VAR} TRUE)
+            else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+                set(${RESULT_VAR} FALSE)
+            endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+            if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+                try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+                        "${_bindir}_fail" "${_SRCFILE_FAIL}"
+                         COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+                if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+                    set(${RESULT_VAR} TRUE)
+                else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+                    set(${RESULT_VAR} FALSE)
+                endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+            endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+        endif (CROSS_COMPILING)
+        if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+            try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}"
+                        COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+            if (_TMP_RESULT)
+                set(${RESULT_VAR} FALSE)
+            else (_TMP_RESULT)
+                set(${RESULT_VAR} TRUE)
+            endif (_TMP_RESULT)
+        endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+
+        if (${RESULT_VAR})
+            message(STATUS "Checking C++11 support for ${_LOG_NAME}: works")
+        else (${RESULT_VAR})
+            message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported")
+        endif (${RESULT_VAR})
+        set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
+    endif (NOT DEFINED ${RESULT_VAR})
+endfunction(cxx11_check_feature)
+
+cxx11_check_feature("__func__" HAS_CXX11_FUNC)
+cxx11_check_feature("auto" HAS_CXX11_AUTO)
+cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE)
+cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE)
+cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR)
+cxx11_check_feature("constructor-delegation" HAS_CXX11_CONSTRUCTOR_DELEGATION)
+cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H)
+cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE)
+cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST)
+cxx11_check_feature("lambda" HAS_CXX11_LAMBDA)
+cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG)
+cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR)
+cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX)
+cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES)
+cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER)
+cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT)
+cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES)
+cxx11_check_feature("sharedpointer" HAS_CXX11_SHAREDPOINTER)
+cxx11_check_feature("funcptr-to-lambda-conversion" HAS_CXX11_PATTERN1)
+
diff --git a/cmake/modules/CheckCompiler.cmake b/cmake/modules/CheckCompiler.cmake
index 7d722b9..9358c56 100644
--- a/cmake/modules/CheckCompiler.cmake
+++ b/cmake/modules/CheckCompiler.cmake
@@ -1,4 +1,11 @@
-MACRO ( Check_Compiler ) 
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+MACRO ( Check_Compiler )
 
 
 # Set a default build type for single-configuration
@@ -7,47 +14,106 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE RelWithDebInfo)
 endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
 
-STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
-STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
+# Check for the existence of fairsoft-config
+# This program only exist in newer versions of fairsoft. If the file exist extract information about
+# the compiler and compiler flags used to install fairsoft.
+# Compare compiler and compiler flags used to compile fairsoft with the compiler and flags used now
+# In case of differences print a warning
+Find_Program(FAIRSOFT_CONFIG fairsoft-config PATHS $ENV{SIMPATH}/bin $ENV{FAIRSOFT_ROOT}/bin NO_DEFAULT_PATH)
+
+If(FAIRSOFT_CONFIG)
+  Message(STATUS "fairsoft-config found")
+  Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cc
+                  OUTPUT_VARIABLE FAIRSOFT_C_COMPILER)
+  Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxx
+                  OUTPUT_VARIABLE FAIRSOFT_CXX_COMPILER)
+  Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --f77
+                  OUTPUT_VARIABLE FAIRSOFT_Fortran_COMPILER)
+
+  # Strip whitespaces, otherwise readlink and comparison don't work
+  String(STRIP ${FAIRSOFT_C_COMPILER} FAIRSOFT_C_COMPILER)
+  String(STRIP ${FAIRSOFT_CXX_COMPILER} FAIRSOFT_CXX_COMPILER)
+  String(STRIP ${FAIRSOFT_Fortran_COMPILER} FAIRSOFT_Fortran_COMPILER)
+
+  Get_Filename_Component(FAIRSOFT_C_COMPILER ${FAIRSOFT_C_COMPILER} REALPATH)
+  Get_Filename_Component(FAIRSOFT_CXX_COMPILER ${FAIRSOFT_CXX_COMPILER} REALPATH)
+  Get_Filename_Component(FAIRSOFT_Fortran_COMPILER ${FAIRSOFT_Fortran_COMPILER} REALPATH)
+  
+  Set(FAIRROOT_C_COMPILER ${CMAKE_C_COMPILER})
+  Set(FAIRROOT_CXX_COMPILER ${CMAKE_CXX_COMPILER})
+  Set(FAIRROOT_Fortran_COMPILER ${CMAKE_Fortran_COMPILER})
+  String(STRIP ${FAIRROOT_C_COMPILER} FAIRROOT_C_COMPILER)
+  String(STRIP ${FAIRROOT_CXX_COMPILER} FAIRROOT_CXX_COMPILER)
+  If(FAIRROOT_Fortran_COMPILER)
+    String(STRIP ${FAIRROOT_Fortran_COMPILER} FAIRROOT_Fortran_COMPILER)
+    Get_Filename_Component(FAIRROOT_Fortran_COMPILER ${FAIRROOT_Fortran_COMPILER} REALPATH)
+  EndIf()
+
+  Get_Filename_Component(FAIRROOT_C_COMPILER ${FAIRROOT_C_COMPILER} REALPATH)
+  Get_Filename_Component(FAIRROOT_CXX_COMPILER ${FAIRROOT_CXX_COMPILER} REALPATH)
+
+  #KG
+  If(NOT (${FAIRSOFT_C_COMPILER} STREQUAL ${FAIRROOT_C_COMPILER}) OR NOT (${FAIRSOFT_CXX_COMPILER} STREQUAL ${FAIRROOT_CXX_COMPILER}))
+    execute_process(COMMAND diff ${FAIRSOFT_CXX_COMPILER} ${FAIRROOT_CXX_COMPILER} OUTPUT_VARIABLE COMPILER_DIFF)
+    If(${COMPILER_DIFF})
+      Message(STATUS "C compiler used for FairSoft installation:  ${FAIRSOFT_C_COMPILER}")
+      Message(STATUS "C compiler used now:  ${FAIRROOT_C_COMPILER}")
+      Message(STATUS "CXX compiler used for FairSoft installation:  ${FAIRSOFT_CXX_COMPILER}")
+      Message(STATUS "CXX compiler used now:  ${FAIRROOT_CXX_COMPILER}")
+      Message(STATUS "The compiler during the compilation of FairSoft is different from the current one.")
+      If(USE_DIFFERENT_COMPILER)
+        Message(STATUS "The error was silenced by the usage of -DUSE_DIFFERENT_COMPILER=TRUE")
+      Else()
+        Message(FATAL_ERROR "This is seen as an error. If you know that the setting is correct you can silence the error by using the CMake flag -DUSE_DIFFERENT_COMPILER=TRUE")
+      EndIf()
+    EndIf()
+  EndIf()
+
+  If(FAIRROOT_Fortran_COMPILER) 
+    If(NOT (${FAIRSOFT_Fortran_COMPILER} STREQUAL ${FAIRROOT_Fortran_COMPILER}))
+      String(STRIP ${FAIRSOFT_Fortran_COMPILER} FAIRSOFT_Fortran_COMPILER)
+      Message(STATUS "Fortran compiler used for FairSoft installation:  ${FAIRSOFT_Fortran_COMPILER}")
+      Message(STATUS "Fortran compiler used now:  ${FAIRROOT_Fortran_COMPILER}")
+      Message(STATUS "The compiler during the compilation of FairSoft is different from the current one.")
+      If(USE_DIFFERENT_COMPILER)
+        Message(STATUS "The error was silenced by the usage of -DUSE_DIFFERENT_COMPILER=TRUE")
+      Else()
+        Message(FATAL_ERROR "This is seen as an error. If you know that the setting is correct you can silence the error by using the CMake flag -DUSE_DIFFERENT_COMPILER=TRUE")
+      EndIf()
+    EndIf()
+  EndIf()
+
+  Execute_Process(COMMAND ${FAIRSOFT_CONFIG} --cxxflags
+                  OUTPUT_VARIABLE FAIRSOFT_CXX_FLAGS)
+  String(STRIP ${FAIRSOFT_CXX_FLAGS} FAIRSOFT_CXX_FLAGS)
+  Set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FAIRSOFT_CXX_FLAGS}")
+Else()
+  Message(STATUS "fairsoft-config not found")
+EndIf()
+
 
 if (CMAKE_SYSTEM_NAME MATCHES Linux)
-   MESSAGE("--- Found a Linux ssytem")
+   MESSAGE("--- Found a Linux system")
    if (CMAKE_COMPILER_IS_GNUCXX)
       MESSAGE("--- Found GNU compiler collection")
 #      set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
 #      set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
       # we profile...
-      if(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
+#      if(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
 #        set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
 #        set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
-         set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lprofiler")
-         set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -lprofiler")
-      endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
-      # using OpenMP
-      if(CMAKE_BUILD_TYPE_TOLOWER MATCHES openmp)
-         set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fopenmp") 
-         set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fopenmp") 
-      endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES openmp)
-	# using XROOTD
-      if(CMAKE_BUILD_TYPE_TOLOWER MATCHES xrootd)
-         set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lNetx") 
-         set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -lNetx") 
-      endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES xrootd)
+#      endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES profile)
 
    # Select flags.
-   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
-#   set(CMAKE_CXX_FLAGS_NIGHTLY        "-O0 -g -Wshadow -Weffc++ -ftest-coverage -fprofile-arcs")
-   set(CMAKE_CXX_FLAGS_NIGHTLY        "-O0 -g -Weffc++")
-   set(CMAKE_CXX_FLAGS_TEST           "-O2 -g -Weffc++")
-   set(CMAKE_CXX_FLAGS_RELEASE        "-O2")
+   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -Wshadow")
+   set(CMAKE_CXX_FLAGS_NIGHTLY        "-O0 -g -Wshadow -Weffc++")
+   set(CMAKE_CXX_FLAGS_TEST           "-O2 -g -Wshadow -Weffc++")
+   set(CMAKE_CXX_FLAGS_RELEASE        "-O2 -Wshadow ")
 #   set(CMAKE_CXX_FLAGS_DEBUG          "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
-   set(CMAKE_CXX_FLAGS_DEBUG          "-g")
+   set(CMAKE_CXX_FLAGS_DEBUG          "-g -Wshadow ")
    set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g3 -fno-inline  -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common -fexceptions")
-   set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
+   set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -ftest-coverage -fprofile-arcs -Wshadow -Weffc++ -Wall -Wextra -Wunused-variable")
    set(CMAKE_CXX_FLAGS_ARRAY_CHECK    "-g3 -fno-inline -ftest-coverage -fprofile-arcs -fstack-protector")
-   set(CMAKE_CXX_FLAGS_OPENMP         "-g -fopenmp")
-   set(CMAKE_CXX_FLAGS_XROOTD         "-D XROOTD")
-
    set(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g")
    set(CMAKE_C_FLAGS_RELEASE          "-O2")
 #   set(CMAKE_C_FLAGS_DEBUG            "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
@@ -55,8 +121,6 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux)
    set(CMAKE_C_FLAGS_DEBUGFULL        "-g3 -fno-inline -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common -fexceptions")
    set(CMAKE_C_FLAGS_PROFILE          "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
    set(CMAKE_C_FLAGS_ARRAY_CHECK      "-g3 -fno-inline -ftest-coverage -fprofile-arcs -fstack-protector")
-   set(CMAKE_C_FLAGS_OPENMP           "-g -fopenmp")
-   set(CMAKE_C_FLAGS_XROOTD           "-D XROOTD")
 
 #   set ( CMAKE_C_FLAGS     "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
 #   set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common")
@@ -67,40 +131,36 @@ if (CMAKE_SYSTEM_NAME MATCHES Linux)
 #      set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_SHARED_LINKER_FLAGS}")
 #      set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined -lc ${CMAKE_MODULE_LINKER_FLAGS}")
 
-   
    # Select flags.
-   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -Wshadow -wd1125 -wd654 wd161")
-   set(CMAKE_CXX_FLAGS_NIGHTLY        "-O0 -g -Wshadow -Weffc++ -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_TEST           "-O2 -g -Wshadow -Weffc++ -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_RELEASE        "-O2 -Wshadow -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_DEBUG          "-g -Wshadow -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g3 -fno-inline  -Wnon-virtual-dtor -ansi -Wall -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common -fexceptions")
-   set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_ARRAY_CHECK    "-g3 -fno-inline -fstack-protector -wd1125 -wd654 -wd161")
-   set(CMAKE_CXX_FLAGS_OPENMP         "-g -openmp -Wshadow -wd1125 -wd654")
-   set(CMAKE_CXX_FLAGS_XROOTD         "-D XROOTD")
-
+   set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ")
+   set(CMAKE_CXX_FLAGS_RELEASE        "-O2")
+   set(CMAKE_CXX_FLAGS_DEBUG          "-O2 -g -0b0 -noalign")
+   set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g -Ob0 -noalign -W")
    set(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g")
    set(CMAKE_C_FLAGS_RELEASE          "-O2")
-#   set(CMAKE_C_FLAGS_DEBUG            "-g -O2 -fno-reorder-blocks -fno-schedule-insns -fno-inline")
-   set(CMAKE_C_FLAGS_DEBUG            "-g")
-   set(CMAKE_C_FLAGS_DEBUGFULL        "-g3 -fno-inline -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common -fexceptions")
-   set(CMAKE_C_FLAGS_PROFILE          "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
-   set(CMAKE_C_FLAGS_ARRAY_CHECK      "-g3 -fno-inline -ftest-coverage -fprofile-arcs -fstack-protector")
-   set(CMAKE_C_FLAGS_OPENMP           "-g -openmp")
-   set(CMAKE_C_FLAGS_XROOTD           "-D XROOTD")
- 	 
+   set(CMAKE_C_FLAGS_DEBUG            "-O2 -g -Ob0 -noalign")
+   set(CMAKE_C_FLAGS_DEBUGFULL        "-g -Ob0 -noalign -W")
+
 #   set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}   -ansi -Wpointer-arith -fno-common")
 #   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ansi -Wpointer-arith -fno-exceptions -fno-common")
 
-     # Get the directory where to find libimf. The only way I found is to get the install dir from icpc and 
-     # from there one knows where the the libraries are installed 
-    Execute_process(COMMAND which icpc OUTPUT_VARIABLE _bla) 
-    String(REPLACE "bin" "compiler/lib" _intel_lib_dirs ${_bla}) 
-    String(REPLACE "/icpc" "" _intel_lib_dirs ${_intel_lib_dirs}) 
-    String(STRIP ${_intel_lib_dirs} _intel_lib_dirs) 
+    # Get the directory where to find libimf. The only way I found is to get the install dir from icpc and
+    # from there one knows where the the libraries are installed
+   Execute_process(COMMAND which icpc OUTPUT_VARIABLE _bla)
+   String(REPLACE "bin" "compiler/lib" _intel_lib_dirs ${_bla})
+   String(REPLACE "/icpc" "" _intel_lib_dirs ${_intel_lib_dirs})
+   String(STRIP ${_intel_lib_dirs} _intel_lib_dirs)
 
    endif (CMAKE_C_COMPILER MATCHES "icc")
+   if (CMAKE_C_COMPILER MATCHES "clang")
+      MESSAGE("--- Clang compiler")
+
+   # Select flags.
+
+   set(CMAKE_C_FLAGS_PROFILE          "--coverage -g3")
+   set(CMAKE_CXX_FLAGS_PROFILE          "--coverage -g3")
+
+   endif (CMAKE_C_COMPILER MATCHES "clang")
 endif (CMAKE_SYSTEM_NAME MATCHES Linux)
 
 
@@ -115,41 +175,70 @@ if (CMAKE_SYSTEM_NAME MATCHES Darwin)
       STRING(COMPARE EQUAL "10.7" "${MAC_OS_VERSION}" MAC_OS_10_7)
       IF(MAC_OS_10_5 OR MAC_OS_10_6 OR MAC_OS_10_7)
         SET(CMAKE_CXX_FLAGS "-m64")
-	SET(CMAKE_C_FLAGS "-m64")
+        SET(CMAKE_C_FLAGS "-m64")
         SET(CMAKE_Fortran_FLAGS "-m64")
       ENDIF(MAC_OS_10_5 OR MAC_OS_10_6 OR MAC_OS_10_7)
 
-      SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")
-      SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")
+      # Check for Xcode version 7.3.0
+      SET(CLANG_730 -1)
+      IF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+        EXEC_PROGRAM("clang --version | grep \"version 7.3.0\"" OUTPUT_VARIABLE CLANG_VERSION)
+        IF(CLANG_VERSION)
+          STRING(FIND ${CLANG_VERSION} "version 7.3.0" CLANG_730)
+        ENDIF(CLANG_VERSION)
+      ENDIF(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+
+      SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -single_module -undefined dynamic_lookup")
+      SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -single_module -undefined dynamic_lookup")
+
+      # Do not use -flat_namespace flag for Xcode 7.3.0
+      IF(CLANG_730 LESS 0)
+        SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -flat_namespace")
+        SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -flat_namespace")
+      ENDIF(CLANG_730 LESS 0)
+
 #      MESSAGE("C_FLAGS: ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}")
 #      MESSAGE("CXX_FLAGS: ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}")
+      Execute_Process(COMMAND gfortran -print-file-name=libgfortran.dylib
+                      OUTPUT_VARIABLE FORTRAN_LIBDIR
+                     )
+      Get_Filename_Component(FORTRAN_LIBDIR ${FORTRAN_LIBDIR}
+                             PATH
+                            )
+      Message("Fortran libraries found in ${FORTRAN_LIBDIR}")
+      SET(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -flat_namespace -single_module -undefined dynamic_lookup")
 
       # Select flags.
       set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -Wshadow ")
-      set(CMAKE_CXX_FLAGS_NIGHTLY        "-O2 -g -Wshadow -Weffc++")
+      set(CMAKE_CXX_FLAGS_NIGHTLY        "-O2 -g -Wshadow -Weffc++ -Wall -Wextra")
       set(CMAKE_CXX_FLAGS_RELEASE        "-O2 -Wshadow ")
-      set(CMAKE_CXX_FLAGS_DEBUG          "-g -O2 -Wshadow -fno-inline")
+      set(CMAKE_CXX_FLAGS_DEBUG          "-g -O2 -Wshadow  -fno-inline")
       set(CMAKE_CXX_FLAGS_DEBUGFULL      "-g3 -fno-inline -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -fno-check-new -fno-common")
-      set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
+      set(CMAKE_CXX_FLAGS_PROFILE        "-g3 -fno-inline -ftest-coverage -fprofile-arcs -Wall -Wextra")
       set(CMAKE_C_FLAGS_RELWITHDEBINFO   "-O2 -g")
       set(CMAKE_C_FLAGS_RELEASE          "-O2")
-      set(CMAKE_C_FLAGS_DEBUG            "-g -O2 -fno-inline")
+      set(CMAKE_C_FLAGS_DEBUG            "-g -O2  -fno-inline")
       set(CMAKE_C_FLAGS_DEBUGFULL        "-g3 -fno-inline -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
       set(CMAKE_C_FLAGS_PROFILE          "-g3 -fno-inline -ftest-coverage -fprofile-arcs")
+
       
    else (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-      Message("CXX Compiler: ${CMAKE_CXX_COMPILER}")
-      Message("CXX Compiler ABI: ${CMAKE_CXX_COMPILER_ABI}") 
-      Message("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}") 
-      MESSAGE(FATAL_ERROR "This compiler is not known.")    
+        Message("CXX Compiler: ${CMAKE_CXX_COMPILER}")
+        Message("CXX Compiler ABI: ${CMAKE_CXX_COMPILER_ABI}")
+        Message("CXX Compiler ID: ${CMAKE_CXX_COMPILER_ID}")
+        MESSAGE(FATAL_ERROR "This compiler is not known.")   
    endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
 
+
 endif (CMAKE_SYSTEM_NAME MATCHES Darwin)
 
+
+
+#STRING(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
+
 SET (BLA CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER})
 
 MESSAGE("--- Build Type: ${CMAKE_BUILD_TYPE}")
 MESSAGE("--- Compiler Flags: ${CMAKE_CXX_FLAGS} ${${BLA}}")
-MESSAGE("--- Linker Flags: ${CMAKE_MODULE_LINKER_FLAGS}")
 
 ENDMACRO ( Check_Compiler )
diff --git a/cmake/modules/CheckFortran.cmake b/cmake/modules/CheckFortran.cmake
index 76aa0ea..f3bf14a 100644
--- a/cmake/modules/CheckFortran.cmake
+++ b/cmake/modules/CheckFortran.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # FFLAGS depend on the compiler
 get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
 
diff --git a/cmake/modules/FairMacros.cmake b/cmake/modules/FairMacros.cmake
index 2887661..eb20391 100644
--- a/cmake/modules/FairMacros.cmake
+++ b/cmake/modules/FairMacros.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
   ###########################################
   #
   #       Usefull macros
@@ -98,6 +105,7 @@ ENDMACRO (CLEAN_PATH_LIST)
 
 MACRO (CHECK_OUT_OF_SOURCE_BUILD)
 
+
    STRING(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
    IF(insource)
       FILE(REMOVE_RECURSE ${CMAKE_SOURCE_DIR}/Testing)
@@ -107,6 +115,23 @@ MACRO (CHECK_OUT_OF_SOURCE_BUILD)
 
 ENDMACRO (CHECK_OUT_OF_SOURCE_BUILD)
 
+  ##########################################################
+  #
+  # The macro checks if the build directory is different from the
+  # installation directory. In case both are the same
+  # stop the execution of cmake with an error message.
+  #
+  ##########################################################
+
+Macro (CHECK_INSTALL_DIRECTORY)
+
+   String(COMPARE EQUAL "${CMAKE_INSTALL_PREFIX}" "${CMAKE_BINARY_DIR}" _same)
+   If(_same)
+      MESSAGE(FATAL_ERROR "Your build and installation directory is the same one. This option does not work. Please change either your build or your installation directory and rerun cmake.")
+   EndIf(_same)
+
+EndMacro (CHECK_INSTALL_DIRECTORY)
+
 Macro(CHECK_EXTERNAL_PACKAGE_INSTALL_DIR)
   If(IS_DIRECTORY ${SIMPATH}/bin)
     Set(FAIRSOFT_EXTERN TRUE)
@@ -168,32 +193,40 @@ MACRO (GENERATE_TEST_SCRIPT SCRIPT_FULL_NAME)
   get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE)
   set(shell_script_name "${file_name}.sh")
 
-  string(REPLACE ${PROJECT_SOURCE_DIR}
-         ${PROJECT_BINARY_DIR} new_path ${path_name}
-        )
+  if(${ARGC} GREATER 1)
+    set(new_path ${ARGV1})
+  Else()
+    string(REPLACE ${PROJECT_SOURCE_DIR}
+           ${PROJECT_BINARY_DIR} new_path ${path_name}
+          )
+  EndIf()
 
+#  Message("${new_path}/${shell_script_name}")
 #  file(MAKE_DIRECTORY ${new_path}/data)
 
   CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
   set(MY_LD_LIBRARY_PATH ${output})
   set(my_script_name ${SCRIPT_FULL_NAME})
 
-  if(CMAKE_SYSTEM MATCHES Darwin)
-    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/set_env_macos.sh.in
+  IF(FAIRROOT_FOUND)
+    configure_file(${FAIRROOT_CMAKEMOD_DIR}/scripts/set_env.sh.in
                    ${new_path}/${shell_script_name}
                   )
-  else(CMAKE_SYSTEM MATCHES Darwin)
+  ELSE(FAIRROOT_FOUND)
     configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/set_env.sh.in
                    ${new_path}/${shell_script_name}
                   )
-  endif(CMAKE_SYSTEM MATCHES Darwin)
+  ENDIF(FAIRROOT_FOUND)
+
 
+  
   EXEC_PROGRAM(/bin/chmod ARGS "u+x  ${new_path}/${shell_script_name}")
 
 ENDMACRO (GENERATE_TEST_SCRIPT)
 
 Macro(Generate_Exe_Script _Path _ExeName) 
 
+
   Message("PATH: ${_Path}")
   Message("ExeName: ${_ExeName}")
   set(shell_script_name "${_ExeName}.sh")
@@ -214,7 +247,18 @@ Macro(Generate_Exe_Script _Path _ExeName)
 EndMacro(Generate_Exe_Script)
 
 Macro (Generate_Version_Info)
+IF(FAIRROOT_FOUND)
+  
+  Add_Custom_Target(svnheader ALL)
 
+  Add_Custom_Command(TARGET svnheader 
+                     COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${PROJECT_SOURCE_DIR}
+		     -DBINARY_DIR=${CMAKE_BINARY_DIR}	      
+                     -DINCLUDE_OUTPUT_DIRECTORY=${INCLUDE_OUTPUT_DIRECTORY}
+                     -DFAIRROOT=${FAIRROOT_CMAKEMOD_DIR}
+                     -P ${FAIRROOT_CMAKEMOD_DIR}/modules/GenerateVersionInfo.cmake
+                      )
+ELSE(FAIRROOT_FOUND)
   Add_Custom_Target(svnheader ALL)
 
   Add_Custom_Command(TARGET svnheader 
@@ -223,30 +267,68 @@ Macro (Generate_Version_Info)
                      -DINCLUDE_OUTPUT_DIRECTORY=${INCLUDE_OUTPUT_DIRECTORY}
                      -P ${CMAKE_SOURCE_DIR}/cmake/modules/GenerateVersionInfo.cmake
 		     )
+ENDIF(FAIRROOT_FOUND)
 
 EndMacro (Generate_Version_Info)
 
 Macro (SetBasicVariables)
+
+IF(FAIRROOT_FOUND)
+  Set(BASE_INCLUDE_DIRECTORIES 
+    ${FAIRROOT_INCLUDE_DIR}
+  )
+  Set(SYSTEM_INCLUDE_DIRECTORIES
+    ${ROOT_INCLUDE_DIR}
+    ${Boost_INCLUDE_DIRS}
+  )
+  Set(ROOT_INCLUDE_PATH
+      ${FAIRROOT_INCLUDE_DIR}
+     )
+
+ELSE(FAIRROOT_FOUND)
   Set(BASE_INCLUDE_DIRECTORIES
-      ${ROOT_INCLUDE_DIR}
-      ${CMAKE_SOURCE_DIR}/fairtools
-      ${CMAKE_SOURCE_DIR}/geobase
-      ${CMAKE_SOURCE_DIR}/parbase
-      ${CMAKE_SOURCE_DIR}/base
-      ${CMAKE_SOURCE_DIR}/base/steer
-      ${CMAKE_SOURCE_DIR}/base/event
-      ${CMAKE_SOURCE_DIR}/base/field
-      ${CMAKE_SOURCE_DIR}/base/sim
-      ${CMAKE_SOURCE_DIR}/base/source
-      ${CMAKE_SOURCE_DIR}/dbase
-      ${CMAKE_SOURCE_DIR}/dbase/dbInterface
-      ${CMAKE_SOURCE_DIR}/dbase/dbValidation
-      ${CMAKE_SOURCE_DIR}/dbase/dbUtils
-      ${CMAKE_SOURCE_DIR}/input/db
-      ${CMAKE_SOURCE_DIR}/dbase/dbInput
-      
+    ${CMAKE_SOURCE_DIR}/fairtools
+    ${CMAKE_SOURCE_DIR}/geobase
+    ${CMAKE_SOURCE_DIR}/parbase
+    ${CMAKE_SOURCE_DIR}/base/steer
+    ${CMAKE_SOURCE_DIR}/base/event
+    ${CMAKE_SOURCE_DIR}/base/field
+    ${CMAKE_SOURCE_DIR}/base/sim
+    ${CMAKE_SOURCE_DIR}/base/source
+    ${CMAKE_SOURCE_DIR}/dbase
+    ${CMAKE_SOURCE_DIR}/dbase/dbInterface
+    ${CMAKE_SOURCE_DIR}/dbase/dbValidation
+    ${CMAKE_SOURCE_DIR}/dbase/dbUtils
+    ${CMAKE_SOURCE_DIR}/input/db
+    ${CMAKE_SOURCE_DIR}/dbase/dbInput
+    ${CMAKE_SOURCE_DIR}/dbase/dbIO
+  )
+  Set(SYSTEM_INCLUDE_DIRECTORIES
+    ${ROOT_INCLUDE_DIR}
+    ${Boost_INCLUDE_DIRS}
   )  
+  Set(ROOT_INCLUDE_PATH
+      ${BASE_INCLUDE_DIRECTORIES}
+     )
+
+ENDIF(FAIRROOT_FOUND)
+
+Set(BASE_LINK_DIRECTORIES
+    ${ROOT_LIBRARY_DIR}
+    ${Boost_LIBRARY_DIRS}
+)  
+
+IF(FAIRROOT_FOUND)
+
+  Set(FAIRLIBDIR ${FAIRROOT_LIBRARY_DIR})
+
+ELSE(FAIRROOT_FOUND)
+
   Set(FAIRLIBDIR ${CMAKE_BINARY_DIR}/lib)
-  Set(LD_LIBRARY_PATH  ${FAIRLIBDIR} ${LD_LIBRARY_PATH})
+  
+ENDIF(FAIRROOT_FOUND)
+
+Set(LD_LIBRARY_PATH  ${FAIRLIBDIR} ${LD_LIBRARY_PATH})
+
 
 EndMacro (SetBasicVariables)
diff --git a/cmake/modules/FindCERNLIB.cmake b/cmake/modules/FindCERNLIB.cmake
index 970e692..a55d8fc 100644
--- a/cmake/modules/FindCERNLIB.cmake
+++ b/cmake/modules/FindCERNLIB.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find CERNLIB
 # Once done this will define
 #
diff --git a/cmake/modules/FindDDS.cmake b/cmake/modules/FindDDS.cmake
new file mode 100644
index 0000000..50b49e2
--- /dev/null
+++ b/cmake/modules/FindDDS.cmake
@@ -0,0 +1,50 @@
+################################################################################
+#    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+#                                                                              #
+#              This software is distributed under the terms of the             #
+#         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #
+#                  copied verbatim in the file "LICENSE"                       #
+################################################################################
+
+MESSAGE(STATUS "Looking for DDS...")
+
+find_path(DDS_INCLUDE_DIR NAMES dds_intercom.h PATHS
+  ${DDS_PATH}/include
+  ${SIMPATH}/DDS/include
+  NO_DEFAULT_PATH
+)
+
+find_path(DDS_LIBRARY_DIR NAMES libdds_intercom_lib.dylib libdds_intercom_lib.so
+  PATHS ${DDS_PATH}/lib
+  PATHS ${SIMPATH}/DDS/lib
+  NO_DEFAULT_PATH
+)
+
+find_library(DDS_INTERCOM_LIBRARY_SHARED NAMES libdds_intercom_lib.dylib libdds_intercom_lib.so
+  PATHS ${DDS_PATH}/lib
+  PATHS ${SIMPATH}/DDS/lib
+  NO_DEFAULT_PATH
+  DOC "Path to libdds_intercom_lib.dylib libdds_intercom_lib.so."
+)
+
+find_library(DDS_PROTOCOL_LIBRARY_SHARED NAMES libdds_protocol_lib.dylib libdds_protocol_lib.so
+  PATHS ${DDS_PATH}/lib
+  PATHS ${SIMPATH}/DDS/lib
+  NO_DEFAULT_PATH
+  DOC "Path to libdds_protocol_lib.dylib libdds_protocol_lib.so."
+)
+
+find_library(DDS_USER_DEFAULTS_LIBRARY_SHARED NAMES libdds-user-defaults.dylib libdds-user-defaults.so
+  PATHS ${DDS_PATH}/lib
+  PATHS ${SIMPATH}/DDS/lib
+  NO_DEFAULT_PATH
+  DOC "Path to libdds-user-defaults.dylib libdds-user-defaults.so."
+)
+
+if(DDS_INCLUDE_DIR AND DDS_LIBRARY_DIR AND DDS_INTERCOM_LIBRARY_SHARED AND DDS_PROTOCOL_LIBRARY_SHARED AND DDS_USER_DEFAULTS_LIBRARY_SHARED)
+  set(DDS_FOUND TRUE)
+  message(STATUS "Looking for DDS ... found ${DDS_INTERCOM_LIBRARY_SHARED};${DDS_PROTOCOL_LIBRARY_SHARED};${DDS_USER_DEFAULTS_LIBRARY_SHARED}")
+else(DDS_INCLUDE_DIR AND DDS_LIBRARY_DIR AND DDS_INTERCOM_LIBRARY_SHARED AND DDS_PROTOCOL_LIBRARY_SHARED AND DDS_USER_DEFAULTS_LIBRARY_SHARED)
+  set(DDS_FOUND FALSE)
+  message(STATUS "Looking for DDS ... not found.")
+endif(DDS_INCLUDE_DIR AND DDS_LIBRARY_DIR AND DDS_INTERCOM_LIBRARY_SHARED AND DDS_PROTOCOL_LIBRARY_SHARED AND DDS_USER_DEFAULTS_LIBRARY_SHARED)
diff --git a/cmake/modules/FindFairRoot.cmake b/cmake/modules/FindFairRoot.cmake
new file mode 100644
index 0000000..1665c0e
--- /dev/null
+++ b/cmake/modules/FindFairRoot.cmake
@@ -0,0 +1,69 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+# Find FairRoot installation 
+# Check the environment variable "FAIRROOTPATH"
+
+if(FairRoot_DIR)
+  set(FAIRROOTPATH ${FairRoot_DIR})
+else()
+  if(NOT DEFINED ENV{FAIRROOTPATH})
+    set(user_message "You did not define the environment variable FAIRROOTPATH which is needed to find FairRoot.\
+         Please set this variable and execute cmake again." )
+    if(FairRoot_FIND_REQUIRED)
+      MESSAGE(FATAL_ERROR ${user_message})
+    else(FairRoot_FIND_REQUIRED)
+      MESSAGE(WARNING ${user_message})
+      return()
+    endif(FairRoot_FIND_REQUIRED)
+  endif(NOT DEFINED ENV{FAIRROOTPATH})
+
+  set(FAIRROOTPATH $ENV{FAIRROOTPATH})
+endif()
+
+MESSAGE(STATUS "Setting FairRoot environment…")
+
+FIND_PATH(FAIRROOT_INCLUDE_DIR NAMES FairRun.h  PATHS
+  ${FAIRROOTPATH}/include
+  NO_DEFAULT_PATH
+)
+
+FIND_PATH(FAIRROOT_LIBRARY_DIR NAMES libBase.so libBase.dylib PATHS
+   ${FAIRROOTPATH}/lib
+  NO_DEFAULT_PATH
+)
+
+FIND_PATH(FAIRROOT_CMAKEMOD_DIR NAMES CMakeLists.txt  PATHS
+   ${FAIRROOTPATH}/share/fairbase/cmake
+  NO_DEFAULT_PATH
+)
+
+set(FAIRMQ_DEPENDENCIES
+  ${Boost_LOG_LIBRARY}
+  ${Boost_LOG_SETUP_LIBRARY}
+  ${Boost_THREAD_LIBRARY}
+  ${Boost_FILESYSTEM_LIBRARY}
+  ${Boost_SYSTEM_LIBRARY}
+  ${Boost_DATE_TIME_LIBRARY}
+  ${Boost_TIMER_LIBRARY}
+  ${Boost_PROGRAM_OPTIONS_LIBRARY}
+  pthread
+  fairmq_logger
+)
+
+if(FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR)
+   set(FAIRROOT_FOUND TRUE)
+   MESSAGE(STATUS "FairRoot ... - found ${FAIRROOTPATH}")
+   MESSAGE(STATUS "FairRoot Library directory  :     ${FAIRROOT_LIBRARY_DIR}")
+   MESSAGE(STATUS "FairRoot Include path…      :     ${FAIRROOT_INCLUDE_DIR}")
+   MESSAGE(STATUS "FairRoot Cmake Modules      :     ${FAIRROOT_CMAKEMOD_DIR}")
+
+else(FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR)
+   set(FAIRROOT_FOUND FALSE)
+   MESSAGE(FATAL_ERROR "FairRoot installation not found")
+endif (FAIRROOT_INCLUDE_DIR AND FAIRROOT_LIBRARY_DIR)
+
diff --git a/cmake/modules/FindFlatBuffers.cmake b/cmake/modules/FindFlatBuffers.cmake
new file mode 100644
index 0000000..b1de4b6
--- /dev/null
+++ b/cmake/modules/FindFlatBuffers.cmake
@@ -0,0 +1,36 @@
+################################################################################
+#    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+#                                                                              #
+#              This software is distributed under the terms of the             #
+#         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #
+#                  copied verbatim in the file "LICENSE"                       #
+################################################################################
+
+MESSAGE(STATUS "Looking for FlatBuffers...")
+
+find_path(FLATBUFFERS_INCLUDE_DIR NAMES flatbuffers/flatbuffers.h PATHS
+  ${FLATBUFFERS_PATH}/include
+  ${SIMPATH}/include
+  NO_DEFAULT_PATH
+)
+
+find_path(FLATBUFFERS_LIBRARY_DIR NAMES libflatbuffers.a
+  PATHS ${FLATBUFFERS_PATH}/
+  ${SIMPATH}/lib
+  NO_DEFAULT_PATH
+)
+
+find_path(FLATBUFFERS_BINARY_DIR NAMES flatc
+  PATHS ${FLATBUFFERS_PATH}/
+  ${SIMPATH}/bin
+  NO_DEFAULT_PATH
+)
+
+if(FLATBUFFERS_INCLUDE_DIR AND FLATBUFFERS_LIBRARY_DIR AND FLATBUFFERS_BINARY_DIR)
+  set(FLATBUFFERS_FOUND true)
+  message(STATUS "Looking for FlatBuffers ... found at ${FLATBUFFERS_INCLUDE_DIR}")
+else(FLATBUFFERS_INCLUDE_DIR AND FLATBUFFERS_LIBRARY_DIR AND FLATBUFFERS_BINARY_DIR)
+  set(FLATBUFFERS_FOUND false)
+  message(STATUS "Looking for FlatBuffers ... not found.")
+endif(FLATBUFFERS_INCLUDE_DIR AND FLATBUFFERS_LIBRARY_DIR AND FLATBUFFERS_BINARY_DIR)
+
diff --git a/cmake/modules/FindGEANT4DATA.cmake b/cmake/modules/FindGEANT4DATA.cmake
deleted file mode 100644
index 3c93d73..0000000
--- a/cmake/modules/FindGEANT4DATA.cmake
+++ /dev/null
@@ -1,116 +0,0 @@
-# - Try to find GEANT4 data files
-#
-
-
-MESSAGE(STATUS "Looking for GEANT4 DATA files...")
-
-FIND_PATH(GEANT4_DATA NAMES G4PII G4PII1.3 PATHS
-  ${SIMPATH}/share/Geant4/data
-  ${SIMPATH}/transport/data/geant4/
-  ${SIMPATH}/transport/geant4/share/Geant4-9.5.0/data
-  ${SIMPATH}/transport/geant4/share/Geant4/data
-  ${SIMPATH}/share/data/geant4
-  ${SIMPATH}/share/Geant4-9.5.0/data
-  NO_DEFAULT_PATH
-)
-
-FIND_PATH(G4LEDATA NAMES README PATHS
-  ${GEANT4_DATA}/G4EMLOW/
-  ${GEANT4_DATA}/G4EMLOW6.23
-  NO_DEFAULT_PATH
-)
-If (G4LEDATA)
-  Message(STATUS "Found G4EMLOW data")
-  SET(G4LEDATA ${G4LEDATA})
-Else (G4LEDATA)
-  Message(STATUS "NOT Found G4EMLOW data")
-EndIf (G4LEDATA)
-
-FIND_PATH(G4LEVELGAMMADATA  NAMES README-LevelGammaData PATHS
-  ${GEANT4_DATA}/PhotonEvaporation/
-  ${GEANT4_DATA}/PhotonEvaporation2.2
-  NO_DEFAULT_PATH
-)
-If (G4LEVELGAMMADATA)
-  Message(STATUS "Found PhotonEvaporation data")
-  SET(G4LEVELGAMMADATA   ${G4LEVELGAMMADATA})
-Else (G4LEVELGAMMADATA)
-  Message(STATUS "NOT Found PhotonEvaporation data")
-EndIf (G4LEVELGAMMADATA)
-
-
-FIND_PATH(G4NeutronHPCrossSections NAMES README  PATHS
-  ${GEANT4_DATA}/G4NDL/
-  ${GEANT4_DATA}/G4NDL4.0
-  NO_DEFAULT_PATH
-)
-If (G4NeutronHPCrossSections)
-  Message(STATUS "Found G4NDL data")
-  SET(G4NeutronHPCrossSections ${G4NeutronHPCrossSections})
-  SET(G4NEUTRONHPDATA ${G4NeutronHPCrossSections})
-Else (G4NeutronHPCrossSections)
-  Message(STATUS "NOT Found G4NDL data")
-EndIf (G4NeutronHPCrossSections)
-
-
-FIND_PATH(G4NEUTRONXSDATA NAMES cap1  PATHS
-  ${GEANT4_DATA}/G4NEUTRONXS/
-  ${GEANT4_DATA}/G4NEUTRONXS1.1
-  NO_DEFAULT_PATH
-)
-If (G4NEUTRONXSDATA)
-  Message(STATUS "Found G4NEUTRONXS data")
-  SET(G4NEUTRONXSDATA ${G4NEUTRONXSDATA})
-Else (G4NEUTRONXSDATA)
-  Message(STATUS "NOT Found G4NEUTRONXS data")
-EndIf (G4NEUTRONXSDATA)
-
-
-FIND_PATH(G4PIIDATA NAMES PIXE_DataLibrary.pdf documentation.pdf PATHS
-  ${GEANT4_DATA}/G4PII/
-  ${GEANT4_DATA}/G4PII1.3
-  NO_DEFAULT_PATH
-)
-If (G4PIIDATA)
-  Message(STATUS "Found G4PII data")
-  SET(G4PIIDATA ${G4PIIDATA})
-Else (G4PIIDATA)
-  Message(STATUS "NOT Found G4PII data")
-EndIf (G4PIIDATA)
-
-
-FIND_PATH(G4RADIOACTIVEDATA NAMES README_RDM PATHS
-  ${GEANT4_DATA}/RadioactiveDecay/
-  ${GEANT4_DATA}/RadioactiveDecay3.4
-  NO_DEFAULT_PATH
-)
-If (G4RADIOACTIVEDATA)
-  Message(STATUS "Found RadioactiveDecay data")
-  SET(G4RADIOACTIVEDATA ${G4RADIOACTIVEDATA})
-Else (G4RADIOACTIVEDATA)
-  Message(STATUS "NOT Found RadioactiveDecay data")
-EndIf (G4RADIOACTIVEDATA)
-
-
-FIND_PATH(G4REALSURFACEDATA NAMES EtchedTiO.dat PATHS
-  ${GEANT4_DATA}/RealSurface/
-  ${GEANT4_DATA}/RealSurface1.0
-  NO_DEFAULT_PATH
-)
-If (G4REALSURFACEDATA)
-  Message(STATUS "Found RealSurface data")
-  SET(G4REALSURFACEDATA  ${G4REALSURFACEDATA})
-Else (G4REALSURFACEDATA)
-  Message(STATUS "NOT Found RealSurface data")
-EndIf (G4REALSURFACEDATA)
-
-FIND_PATH(G4SAIDXSDATA NAMES README_Eta PATHS
-  ${GEANT4_DATA}/G4SAIDDATA
-  NO_DEFAULT_PATH
-)
-If (G4SAIDXSDATA)
-  Message(STATUS "Found G4SAID data")
-  SET(G4SAIDXSDATA  ${G4SAIDXSDATA})
-Else (G4SAIDXSDATA)
-  Message(STATUS "NOT Found G4SAID data")
-EndIf (G4SAIDXSDATA)
diff --git a/cmake/modules/FindGSL.cmake b/cmake/modules/FindGSL.cmake
index b872f5b..73c0abc 100644
--- a/cmake/modules/FindGSL.cmake
+++ b/cmake/modules/FindGSL.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Try to find gnu scientific library GSL
 # See
 # http://www.gnu.org/software/gsl/  and
diff --git a/cmake/modules/FindGo.cmake b/cmake/modules/FindGo.cmake
new file mode 100644
index 0000000..fba50b7
--- /dev/null
+++ b/cmake/modules/FindGo.cmake
@@ -0,0 +1,54 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# The module defines the following variables:
+#   GO_FOUND - true if the Go was found
+#   GO_EXECUTABLE - path to the executable
+#   GO_VERSION - Go version number
+#   GO_PLATFORM - i.e. linux
+#   GO_ARCH - i.e. amd64
+# Example usage:
+#   find_package(Go 1.2 REQUIRED)
+
+
+MESSAGE(STATUS "Looking for Go...")
+find_program(GO_EXECUTABLE go PATHS ENV GOROOT GOPATH GOBIN PATH_SUFFIXES bin)
+if (GO_EXECUTABLE)
+    execute_process(COMMAND ${GO_EXECUTABLE} version OUTPUT_VARIABLE GO_VERSION_OUTPUT OUTPUT_STRIP_TRAILING_WHITESPACE)
+    if(GO_VERSION_OUTPUT MATCHES "go([0-9]+\\.[0-9]+\\.?[0-9]*)[a-zA-Z0-9]* ([^/]+)/(.*)")
+        set(GO_VERSION ${CMAKE_MATCH_1})
+        set(GO_PLATFORM ${CMAKE_MATCH_2})
+        set(GO_ARCH ${CMAKE_MATCH_3})
+        MESSAGE(STATUS "Looking for Go... found Go ${GO_VERSION}")
+
+    elseif(GO_VERSION_OUTPUT MATCHES "go version devel .* ([^/]+)/(.*)$")
+        set(GO_VERSION "99-devel")
+        set(GO_PLATFORM ${CMAKE_MATCH_1})
+        set(GO_ARCH ${CMAKE_MATCH_2})
+        message("WARNING: Development version of Go being used, can't determine compatibility.")
+    endif()
+endif()
+mark_as_advanced(GO_EXECUTABLE)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Go REQUIRED_VARS GO_EXECUTABLE GO_VERSION GO_PLATFORM GO_ARCH VERSION_VAR GO_VERSION)
+
+# build_go_package build/installs a Go package 'pkg'.
+# if 'gopath' is empty "", the environment variable $GOPATH will be used and passed to
+# 'go get'.
+macro(build_go_package pkg gopath)
+#  message("Building Go Stuff")
+	string(REPLACE "/" "_" tgt ${pkg})
+	if(gopath STREQUAL "")
+		set(gopath $ENV{GOPATH})
+	endif()
+
+  set(workdir "${gopath}/src/${pkg}")
+#  message("Working directory:  ${workdir}")
+  execute_process (COMMAND ${GO_EXECUTABLE} get
+                   WORKING_DIRECTORY ${workdir}
+  )
+
+
+endmacro(build_go_package)
diff --git a/cmake/modules/FindHEPMC.cmake b/cmake/modules/FindHEPMC.cmake
index 765cafa..2822643 100644
--- a/cmake/modules/FindHEPMC.cmake
+++ b/cmake/modules/FindHEPMC.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find HEPMC instalation
 # Once done this will define
 #
@@ -7,11 +14,15 @@
 MESSAGE(STATUS "Looking for HepMC ...")
 
 FIND_PATH(HEPMC_INCLUDE_DIR NAMES HepMC/HepMCDefs.h PATHS
+  ${HEPMC_DIR}/include
+  ${AlFa_DIR}/include
   ${SIMPATH}/include/
   NO_DEFAULT_PATH
 )
 
 FIND_PATH(HEPMC_LIB_DIR  NAMES libHepMC.so PATHS
+  ${HEPMC_DIR}/lib
+  ${AlFa_DIR}/lib
   ${SIMPATH}/lib
   NO_DEFAULT_PATH
 )
diff --git a/cmake/modules/FindIWYU.cmake b/cmake/modules/FindIWYU.cmake
index 7e38207..7949b0d 100644
--- a/cmake/modules/FindIWYU.cmake
+++ b/cmake/modules/FindIWYU.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find the include-what-you-use (IWYU) instalation
 # - This tool is based on llvm and will check the #include statements
 # - Once done this will define
diff --git a/cmake/modules/FindMYSQL.cmake b/cmake/modules/FindMYSQL.cmake
new file mode 100644
index 0000000..db95cce
--- /dev/null
+++ b/cmake/modules/FindMYSQL.cmake
@@ -0,0 +1,46 @@
+# - Find mysqlclient
+# Find the native MySQL includes and library
+#
+#  MYSQL_INCLUDE_DIRS - where to find mysql.h, etc.
+#  MYSQL_LIBRARIES   - mysqlclient library.
+#  MYSQL_FOUND       - True if mysqlclient is found.
+#
+
+# <D.Bertini> : 
+#    Date: 11.08.2014 -- Changes to favor user local installation
+
+
+find_path( MYSQL_INCLUDE_DIR "mysql.h"
+	PATHS
+		"/usr/local/include/mysql"
+        "/usr/local/mysql"
+        "/usr/local/*/include/" 
+		"/usr/include/mysql"
+		"/usr/mysql/include/mysql"
+         )
+
+find_library( MYSQL_LIBRARIES
+	NAMES "mysqlclient" "mysqlclient_r"
+	PATHS
+		"/usr/local/lib/mysql"
+        "/usr/local/mysql/lib"
+        "/usr/local/*/lib"   
+		"/usr/lib/mysql"
+		"/usr/mysql/lib/mysql"
+        )  
+
+get_filename_component( MYSQL_LIBRARY_DIR ${MYSQL_LIBRARIES}  PATH ) 
+
+mark_as_advanced( MYSQL_LIBRARIES  MYSQL_INCLUDE_DIR )
+
+if(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+	    set(MYSQL_FOUND TRUE)
+	    message(STATUS "Found MySQL: ${MYSQL_INCLUDE_DIR}, ${MYSQL_LIBRARY_DIR}, ${MYSQL_LIBRARIES}")
+	    INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR})
+	  else(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+	    set(MYSQL_FOUND FALSE)
+	    message(STATUS "MySQL not found.")
+endif(MYSQL_INCLUDE_DIR AND MYSQL_LIBRARIES)
+	
+mark_as_advanced(MYSQL_INCLUDE_DIR MYSQL_LIBRARIES)
+	
diff --git a/cmake/modules/FindMsgpack.cmake b/cmake/modules/FindMsgpack.cmake
new file mode 100644
index 0000000..9e44eaa
--- /dev/null
+++ b/cmake/modules/FindMsgpack.cmake
@@ -0,0 +1,27 @@
+################################################################################
+#    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+#                                                                              #
+#              This software is distributed under the terms of the             #
+#         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #
+#                  copied verbatim in the file "LICENSE"                       #
+################################################################################
+
+MESSAGE(STATUS "Looking for MessagePack...")
+
+find_path(MSGPACK_INCLUDE_DIR msgpack.hpp PATHS
+  ${SIMPATH}/include
+  NO_DEFAULT_PATH
+)
+
+find_path(MSGPACK_LIBRARY_DIR NAMES libmsgpackc.dylib libmsgpackc.so PATHS
+  ${SIMPATH}/lib
+  NO_DEFAULT_PATH
+)
+
+if(MSGPACK_INCLUDE_DIR AND MSGPACK_LIBRARY_DIR)
+  set(MSGPACK_FOUND true)
+  message(STATUS "Looking for MessagePack ... found at ${MSGPACK_LIBRARY_DIR}")
+else(MSGPACK_INCLUDE_DIR AND MSGPACK_LIBRARY_DIR)
+  set(MSGPACK_FOUND false)
+  message(STATUS "Looking for MessagePack ... not found.")
+endif(MSGPACK_INCLUDE_DIR AND MSGPACK_LIBRARY_DIR)
diff --git a/cmake/modules/FindOracle.cmake b/cmake/modules/FindOracle.cmake
index 155e5c8..56d3e74 100644
--- a/cmake/modules/FindOracle.cmake
+++ b/cmake/modules/FindOracle.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # TOra: Configure Oracle libraries
 #
 # ORACLE_FOUND - system has Oracle OCI
diff --git a/cmake/modules/FindPGSQL.cmake b/cmake/modules/FindPGSQL.cmake
new file mode 100644
index 0000000..19a651e
--- /dev/null
+++ b/cmake/modules/FindPGSQL.cmake
@@ -0,0 +1,59 @@
+# Macro to search for Postgresql installation
+
+#  POSTGRESQL_INCLUDE_DIR - where to find mysql.h, etc.
+#  POSTGRESQL_LIBRARY_DIR   - mysqlclient library directory
+#  POSTGRESQL_LIBRARIES    - mysqlclient library.
+#  POSTGRESQL_FOUND       - True if mysqlclient is found.
+
+
+# <D.Bertini> : 
+#    Date: 05.08.2014 -- Remark: for PgSQL 9.2 on MacOSX the libpq.dylib 
+#                        is named libpd.5.dylib. The following script will
+#                         not find the corresponding soft link to /Library. 
+#                         You need to set the link to libpq.so in /usr/lib.
+#                         Issue solved in PgSQL 9.3   
+#    Date: 11.08.2014 -- Changes to favor user local installation
+	
+
+find_path(POSTGRESQL_INCLUDE_DIR "postgres.h"
+          PATHS 
+               "/usr/local/include/pgsql/server"
+ 	           "/usr/local/include/postgresql/server"
+   	           "/usr/local/include/postgresql/*/server"
+               "/usr/local/pgsql/postgresql/server"
+   	           "/usr/local/pgsql/postgresql/*/server"
+               "/usr/local/*/include/"
+               "/usr/local/*/include/postgresql/"
+               "/usr/local/*/include/postgresql/server"
+               "/usr/include/server"
+    	       "/usr/include/pgsql/server"
+    	       "/usr/include/postgresql/server"
+               "/usr/include/postgresql/*/server"
+	     )
+	
+
+find_library(POSTGRESQL_LIBRARIES 
+             NAMES "pq" "libpq"  
+	         PATHS
+	              "/usr/local/lib/"
+	              "/usr/local/lib64"
+	              "/usr/lib/"
+	              "/usr/lib/postgresql"
+	              "/usr/lib64"
+	              "/usr/lib64/postgresql"
+	       )
+
+get_filename_component( POSTGRESQL_LIBRARY_DIR ${POSTGRESQL_LIBRARIES}  PATH ) 
+
+
+if(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
+	    set(POSTGRESQL_FOUND TRUE)
+	    message(STATUS "Found PostgreSQL: ${POSTGRESQL_INCLUDE_DIR}, ${POSTGRESQL_LIBRARY_DIR}, ${POSTGRESQL_LIBRARIES}")
+	    INCLUDE_DIRECTORIES(${POSTGRESQL_INCLUDE_DIR})
+	  else(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
+	    set(POSTGRESQL_FOUND FALSE)
+	    message(STATUS "PostgreSQL not found.")
+endif(POSTGRESQL_INCLUDE_DIR AND POSTGRESQL_LIBRARIES)
+	
+mark_as_advanced(POSTGRESQL_INCLUDE_DIR POSTGRESQL_LIBRARIES)
+	
diff --git a/cmake/modules/FindPLUTO.cmake b/cmake/modules/FindPLUTO.cmake
index 6cc03ba..b848b9f 100644
--- a/cmake/modules/FindPLUTO.cmake
+++ b/cmake/modules/FindPLUTO.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find PLUTO instalation
 # Once done this will define
 #
@@ -16,6 +23,8 @@ endif (PLUTO_INCLUDE_DIR AND PLUTO_LIBRARIES)
 MESSAGE(STATUS "Looking for Pluto...")
 
 FIND_PATH(PLUTO_INCLUDE_DIR NAMES PParticle.h PATHS
+  ${PLUTO_DIR}/include/pluto
+  ${AlFa_DIR}/include/pluto
   ${SIMPATH}/include/pluto
   ${SIMPATH}/generators/pluto/src
   ${SIMPATH}/generators/pluto
@@ -24,6 +33,8 @@ FIND_PATH(PLUTO_INCLUDE_DIR NAMES PParticle.h PATHS
 )
 
 FIND_PATH(PLUTO_LIBRARY_DIR NAMES libPluto.so PATHS
+  ${PLUTO_DIR}/lib
+  ${AlFa_DIR}/lib
   ${SIMPATH}/lib
   ${SIMPATH}/generators/lib
   ${SIMPATH}/generators/pluto
diff --git a/cmake/modules/FindProtobuf.cmake b/cmake/modules/FindProtobuf.cmake
new file mode 100644
index 0000000..4ea0286
--- /dev/null
+++ b/cmake/modules/FindProtobuf.cmake
@@ -0,0 +1,248 @@
+# Locate and configure the Google Protocol Buffers library.
+#
+# The following variables can be set and are optional:
+#
+#   PROTOBUF_SRC_ROOT_FOLDER - When compiling with MSVC, if this cache variable is set
+#                              the protobuf-default VS project build locations
+#                              (vsprojects/Debug & vsprojects/Release) will be searched
+#                              for libraries and binaries.
+#
+#   PROTOBUF_IMPORT_DIRS     - List of additional directories to be searched for
+#                              imported .proto files. (New in CMake 2.8.8)
+#
+# Defines the following variables:
+#
+#   PROTOBUF_FOUND - Found the Google Protocol Buffers library (libprotobuf & header files)
+#   PROTOBUF_INCLUDE_DIRS - Include directories for Google Protocol Buffers
+#   PROTOBUF_LIBRARIES - The protobuf libraries
+# [New in CMake 2.8.5]
+#   PROTOBUF_PROTOC_LIBRARIES - The protoc libraries
+#   PROTOBUF_LITE_LIBRARIES - The protobuf-lite libraries
+#
+# The following cache variables are also available to set or use:
+#   PROTOBUF_LIBRARY - The protobuf library
+#   PROTOBUF_PROTOC_LIBRARY   - The protoc library
+#   PROTOBUF_INCLUDE_DIR - The include directory for protocol buffers
+#   PROTOBUF_PROTOC_EXECUTABLE - The protoc compiler
+# [New in CMake 2.8.5]
+#   PROTOBUF_LIBRARY_DEBUG - The protobuf library (debug)
+#   PROTOBUF_PROTOC_LIBRARY_DEBUG   - The protoc library (debug)
+#   PROTOBUF_LITE_LIBRARY - The protobuf lite library
+#   PROTOBUF_LITE_LIBRARY_DEBUG - The protobuf lite library (debug)
+#
+#  ====================================================================
+#  Example:
+#
+#   find_package(Protobuf REQUIRED)
+#   include_directories(${PROTOBUF_INCLUDE_DIRS})
+#
+#   include_directories(${CMAKE_CURRENT_BINARY_DIR})
+#   PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS foo.proto)
+#   add_executable(bar bar.cc ${PROTO_SRCS} ${PROTO_HDRS})
+#   target_link_libraries(bar ${PROTOBUF_LIBRARIES})
+#
+# NOTE: You may need to link against pthreads, depending
+#       on the platform.
+#
+# NOTE: The PROTOBUF_GENERATE_CPP macro & add_executable() or add_library()
+#       calls only work properly within the same directory.
+#
+#  ====================================================================
+#
+# PROTOBUF_GENERATE_CPP (public function)
+#   SRCS = Variable to define with autogenerated
+#          source files
+#   HDRS = Variable to define with autogenerated
+#          header files
+#   ARGN = proto files
+#
+#  ====================================================================
+
+
+#=============================================================================
+# Copyright 2009 Kitware, Inc.
+# Copyright 2009-2011 Philip Lowman <philip@yhbt.com>
+# Copyright 2008 Esben Mose Hansen, Ange Optimization ApS
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+#  License text for the above reference.)
+
+MESSAGE(STATUS "Looking for Protobuf...")
+
+function(PROTOBUF_GENERATE_CPP SRCS HDRS)
+  if(NOT ARGN)
+    message(SEND_ERROR "Error: PROTOBUF_GENERATE_CPP() called without any proto files")
+    return()
+  endif()
+
+  if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
+    # Create an include path for each file specified
+    foreach(FIL ${ARGN})
+      get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
+      get_filename_component(ABS_PATH ${ABS_FIL} PATH)
+      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
+      if(${_contains_already} EQUAL -1)
+          list(APPEND _protobuf_include_path -I ${ABS_PATH})
+      endif()
+    endforeach()
+  else()
+    set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
+  endif()
+
+  if(DEFINED PROTOBUF_IMPORT_DIRS)
+    foreach(DIR ${PROTOBUF_IMPORT_DIRS})
+      get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
+      list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
+      if(${_contains_already} EQUAL -1)
+          list(APPEND _protobuf_include_path -I ${ABS_PATH})
+      endif()
+    endforeach()
+  endif()
+
+  set(${SRCS})
+  set(${HDRS})
+  foreach(FIL ${ARGN})
+    get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
+    get_filename_component(FIL_WE ${FIL} NAME_WE)
+
+    list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
+    list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
+
+    add_custom_command(
+      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
+             "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
+      COMMAND  ${PROTOBUF_PROTOC_EXECUTABLE}
+      ARGS --cpp_out  ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
+      DEPENDS ${ABS_FIL}
+      COMMENT "Running C++ protocol buffer compiler on ${FIL}"
+      VERBATIM )
+  endforeach()
+
+  set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
+  set(${SRCS} ${${SRCS}} PARENT_SCOPE)
+  set(${HDRS} ${${HDRS}} PARENT_SCOPE)
+endfunction()
+
+# Internal function: search for normal library as well as a debug one
+#    if the debug one is specified also include debug/optimized keywords
+#    in *_LIBRARIES variable
+function(_protobuf_find_libraries name filename)
+   find_library(${name}_LIBRARY
+       NAMES ${filename}
+       PATHS ${SIMPATH}/lib ${ProtoBuf_DIR}/lib
+       NO_DEFAULT_PATH
+       NO_CMAKE_SYSTEM_PATH
+   )
+   mark_as_advanced(${name}_LIBRARY)
+
+   find_library(${name}_LIBRARY_DEBUG
+       NAMES ${filename}
+       PATHS ${SIMPATH}/lib ${ProtoBuf_DIR}/lib
+       NO_DEFAULT_PATH
+       NO_CMAKE_SYSTEM_PATH
+   )
+   mark_as_advanced(${name}_LIBRARY_DEBUG)
+
+   if(NOT ${name}_LIBRARY_DEBUG)
+      # There is no debug library
+      set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
+      set(${name}_LIBRARIES     ${${name}_LIBRARY} PARENT_SCOPE)
+   else()
+      # There IS a debug library
+      set(${name}_LIBRARIES
+          optimized ${${name}_LIBRARY}
+          debug     ${${name}_LIBRARY_DEBUG}
+          PARENT_SCOPE
+      )
+   endif()
+endfunction()
+
+# Internal function: find threads library
+function(_protobuf_find_threads)
+    set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+    find_package(Threads)
+    if(Threads_FOUND)
+        list(APPEND PROTOBUF_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+        set(PROTOBUF_LIBRARIES "${PROTOBUF_LIBRARIES}" PARENT_SCOPE)
+    endif()
+endfunction()
+
+#
+# Main.
+#
+
+# By default have PROTOBUF_GENERATE_CPP macro pass -I to protoc
+# for each directory where a proto file is referenced.
+if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH)
+  set(PROTOBUF_GENERATE_CPP_APPEND_PATH TRUE)
+endif()
+
+
+# Google's provided vcproj files generate libraries with a "lib"
+# prefix on Windows
+if(MSVC)
+    set(PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
+    set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "")
+
+    find_path(PROTOBUF_SRC_ROOT_FOLDER protobuf.pc.in)
+endif()
+
+# The Protobuf library
+_protobuf_find_libraries(PROTOBUF protobuf)
+#DOC "The Google Protocol Buffers RELEASE Library"
+
+_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite)
+
+# The Protobuf Protoc Library
+_protobuf_find_libraries(PROTOBUF_PROTOC protoc)
+
+# Restore original find library prefixes
+if(MSVC)
+    set(CMAKE_FIND_LIBRARY_PREFIXES "${PROTOBUF_ORIG_FIND_LIBRARY_PREFIXES}")
+endif()
+
+if(UNIX)
+    _protobuf_find_threads()
+endif()
+
+# Find the include directory
+find_path(PROTOBUF_INCLUDE_DIR
+    google/protobuf/service.h
+    PATHS
+    ${PROTOBUF_SRC_ROOT_FOLDER}/src
+    ${SIMPATH}/include
+    ${ProtoBuf_DIR}/include
+    NO_DEFAULT_PATH
+    NO_CMAKE_SYSTEM_PATH
+)
+mark_as_advanced(PROTOBUF_INCLUDE_DIR)
+
+# Find the protoc Executable
+find_program(PROTOBUF_PROTOC_EXECUTABLE
+    NAMES protoc
+    DOC "The Google Protocol Buffers Compiler"
+    PATHS
+    ${SIMPATH}/bin
+    ${ProtoBuf_DIR}/bin
+    NO_DEFAULT_PATH
+    NO_CMAKE_SYSTEM_PATH
+)
+mark_as_advanced(PROTOBUF_PROTOC_EXECUTABLE)
+
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG
+    PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
+
+if(PROTOBUF_FOUND)
+    set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
+    message(STATUS "Looking for Protobuf... - found ${PROTOBUF_LIBRARIES}")
+    add_definitions(-DPROTOBUF)
+endif()
diff --git a/cmake/modules/FindPythia6.cmake b/cmake/modules/FindPythia6.cmake
new file mode 100644
index 0000000..413969a
--- /dev/null
+++ b/cmake/modules/FindPythia6.cmake
@@ -0,0 +1,44 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+# - Try to find PLUTO instalation
+# Once done this will define
+#
+#  Pythia6_FOUND - system has Pythia6
+#  Pythia6_LIBRARY_DIR - The libraries directory for Pythia6
+#
+
+if (Pythia6_LIBRARY_DIR)
+  SET (Pythia6_LIBRARY_DIR Pythia6_LIBRARY_DIR-NOTFOUND)
+endif (Pythia6_LIBRARY_DIR)
+
+MESSAGE(STATUS "Looking for Pythia6...")
+
+FIND_PATH(Pythia6_LIBRARY_DIR NAMES libPythia6.so PATHS
+  ${Pythia6_DIR}/lib
+  ${AlFa_DIR}/lib
+  ${SIMPATH}/lib
+  ${SIMPATH}/generators/lib
+  NO_DEFAULT_PATH
+)
+
+if (Pythia6_LIBRARY_DIR)
+  set(Pythia6_FOUND TRUE)
+  Set(PYTHIA6_LIBRARY_DIR ${Pythia6_LIBRARY_DIR})
+endif(Pythia6_LIBRARY_DIR)
+
+if (Pythia6_FOUND)
+  if (NOT Pythia6_FIND_QUIETLY)     
+    MESSAGE(STATUS "Looking for Pythia6... - found ${Pythia6_LIBRARY_DIR}")
+    SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${Pythia6_LIBRARY_DIR})
+  endif (NOT Pythia6_FIND_QUIETLY)
+else (Pythia6_FOUND)
+  if (Pythia6_FIND_REQUIRED)
+    message(FATAL_ERROR "Looking for Pythia6... - Not found")
+  endif (Pythia6_FIND_REQUIRED)
+endif (Pythia6_FOUND)
+
diff --git a/cmake/modules/FindPythia8.cmake b/cmake/modules/FindPythia8.cmake
index 39fec35..3002365 100644
--- a/cmake/modules/FindPythia8.cmake
+++ b/cmake/modules/FindPythia8.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find PYTHIA8 instalation
 # Once done this will define
 #
@@ -5,6 +12,9 @@
 MESSAGE(STATUS "Looking for PYTHIA8 ...")
 
 FIND_PATH(PYTHIA8_INCLUDE_DIR NAMES Pythia.h PATHS
+  ${PYTHIA8_DIR}/include/Pythia8
+  ${AlFa_DIR}/include/Pythia8
+  ${SIMPATH}/include/Pythia8
   ${SIMPATH}/include/pythia8  
   ${SIMPATH}/generators/include/pythia8  
   ${SIMPATH}/generators/pythia8/include  
@@ -12,11 +22,21 @@ FIND_PATH(PYTHIA8_INCLUDE_DIR NAMES Pythia.h PATHS
 )
 
 FIND_PATH(PYTHIA8_LIB_DIR  NAMES libpythia8.so PATHS
+  ${PYTHIA8_DIR}/lib
+  ${AlFa_DIR}/lib
   ${SIMPATH}/lib
   ${SIMPATH}/generators/lib
   NO_DEFAULT_PATH
 )
 
+Find_Path(PYTHIA8DATA NAMES MainProgramSettings.xml PATHS
+  ${SIMPATH}/share/pythia8/xmldoc
+)
+
+If(NOT PYTHIA8DATA)
+  Message(STATUS "Could not find Pythia8 data files")
+EndIf()
+
 if (PYTHIA8_INCLUDE_DIR AND PYTHIA8_LIB_DIR)
    set(PYTHIA8_FOUND TRUE)
 endif (PYTHIA8_INCLUDE_DIR AND PYTHIA8_LIB_DIR)
diff --git a/cmake/modules/FindROOT.cmake b/cmake/modules/FindROOT.cmake
index f89730b..51b56ab 100644
--- a/cmake/modules/FindROOT.cmake
+++ b/cmake/modules/FindROOT.cmake
@@ -1,138 +1,146 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Find ROOT instalation
 # This module tries to find the ROOT installation on your system.
-# It tries to find the root-config script which gives you all the needed information.
+# It tries to find the root-config script which gives you all the needed 
+# information.
 # If the system variable ROOTSYS is set this is straight forward.
 # If not the module uses the pathes given in ROOT_CONFIG_SEARCHPATH.
 # If you need an other path you should add this path to this varaible.  
 # The root-config script is then used to detect basically everything else.
 # This module defines a number of key variables and macros.
-
-
-MESSAGE(STATUS "Looking for Root...")
-
-SET(ROOT_CONFIG_SEARCHPATH
-  ${SIMPATH}/tools/root/bin
+#
+# Variables defined by this module:
+#
+#   ROOT_FOUND               System has ROOT, this means the root-config 
+#                            executable was found.
+#
+#   ROOT_INCLUDE_DIR         ROOT include directories: not cached
+#
+#   ROOT_INCLUDES            Same as above,
+#
+#   ROOT_LIBRARIES           Link to these to use the ROOT libraries, not cached
+#
+#   ROOT_LIBRARY_DIR         The path to where the ROOT library files are.
+#
+#   ROOT_VERSION_STRING      The version string of the ROOT libraries which
+#                            is reported by root-config
+#
+#   ROOT_VERSION_MAJOR       Major version number of ROOT
+#   ROOT_VERSION_MINOR       Minor version number of ROOT
+#   ROOT_VERSION_PATCH       Patch version number of ROOT
+#
+#   ROOT_VERSION_NUMBER      A unique version number which is calculated from 
+#                            major, minor and patch version found
+#
+#   ROOT_CINT_EXECUTABLE     The rootcint executable.
+#
+#   RLIBMAP_EXECUTABLE       The rlibmap executable.
+
+Message(STATUS "Looking for Root...")
+
+Set(ROOT_CONFIG_SEARCHPATH
+  ${ROOT_DIR}/bin
   ${SIMPATH}/bin
+  ${SIMPATH}/tools/root/bin
   $ENV{ROOTSYS}/bin
 )
 
-SET(ROOT_DEFINITIONS "")
-
-SET(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
-
-SET(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
-
-FIND_PROGRAM(ROOT_CONFIG_EXECUTABLE NAMES root-config PATHS
-   ${ROOT_CONFIG_SEARCHPATH}
-   NO_DEFAULT_PATH)
-    
-IF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  MESSAGE( FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please
- set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the
- subdirectory cmake/modules.")
-ELSE (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")
-  STRING(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) 
-  SET( ENV{ROOTSYS} ${test})
-  set( ROOTSYS ${test})
-ENDIF (${ROOT_CONFIG_EXECUTABLE} MATCHES "ROOT_CONFIG_EXECUTABLE-NOTFOUND")  
-
- 
-IF (ROOT_CONFIG_EXECUTABLE)
+Set(ROOT_FOUND FALSE)
+Set(ROOT_DEFINITIONS "")
+Set(ROOT_INSTALLED_VERSION_TOO_OLD FALSE)
+Set(ROOT_CONFIG_EXECUTABLE ROOT_CONFIG_EXECUTABLE-NOTFOUND)
+
+Find_Program(ROOT_CONFIG_EXECUTABLE NAMES root-config 
+             PATHS ${ROOT_CONFIG_SEARCHPATH}
+             NO_DEFAULT_PATH
+            )
+     
+If(ROOT_CONFIG_EXECUTABLE)
    
-  SET(ROOT_FOUND FALSE)
-
-  EXECUTE_PROCESS(COMMAND ${ROOT_CONFIG_EXECUTABLE} --version OUTPUT_VARIABLE ROOTVERSION)
-  EXECUTE_PROCESS( COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
-    OUTPUT_VARIABLE ROOT_INSTALL_DIR)
-  String(STRIP ${ROOTVERSION} ROOTVERSION)
+  String(REGEX REPLACE "(^.*)/bin/root-config" "\\1" test ${ROOT_CONFIG_EXECUTABLE}) 
+  Set(ENV{ROOTSYS} ${test})
+  Set(ROOTSYS ${test})
+
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --version 
+                  OUTPUT_VARIABLE ROOT_VERSION_STRING
+                 )
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix
+                  OUTPUT_VARIABLE ROOT_INSTALL_DIR
+                 )
+  String(STRIP ${ROOT_VERSION_STRING} ROOT_VERSION_STRING)
   String(STRIP ${ROOT_INSTALL_DIR} ROOT_INSTALL_DIR)
 
-  MESSAGE(STATUS "Looking for Root... - Found ${ROOT_INSTALL_DIR}/bin/root")
-  MESSAGE(STATUS "Looking for Root... - version ${ROOTVERSION} ")   
 
-  # we need at least version 5.00/00
-  IF (NOT ROOT_MIN_VERSION)
-    SET(ROOT_MIN_VERSION "5.00/00")
-  ENDIF (NOT ROOT_MIN_VERSION)
-   
-  # now parse the parts of the user given version string into variables
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+" "\\1" req_root_major_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" req_root_minor_vers "${ROOT_MIN_VERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+)" "\\1" req_root_patch_vers "${ROOT_MIN_VERSION}")
+  MESSAGE(STATUS "Looking for Root... - Found ${ROOT_INSTALL_DIR}/bin/root")
+  MESSAGE(STATUS "Looking for Root... - Found version is ${ROOT_VERSION_STRING} ")   
    
-  # and now the version string given by qmake
-  STRING(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" found_root_major_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" found_root_minor_vers "${ROOTVERSION}")
-  STRING(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" found_root_patch_vers "${ROOTVERSION}")
+  # extract major, minor, and patch versions from
+  # the version string given by root-config
+  String(REGEX REPLACE "^([0-9]+)\\.[0-9][0-9]+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MAJOR "${ROOT_VERSION_STRING}")
+  String(REGEX REPLACE "^[0-9]+\\.([0-9][0-9])+\\/[0-9][0-9]+.*" "\\1" ROOT_VERSION_MINOR "${ROOT_VERSION_STRING}")
+  String(REGEX REPLACE "^[0-9]+\\.[0-9][0-9]+\\/([0-9][0-9]+).*" "\\1" ROOT_VERSION_PATCH "${ROOT_VERSION_STRING}")
 
-  IF (found_root_major_vers LESS 5)
-    MESSAGE( FATAL_ERROR "Invalid ROOT version \"${ROOTERSION}\", at least major version 4 is required, e.g. \"5.00/00\"")
-  ENDIF (found_root_major_vers LESS 5)
+  # compute overall version numbers which can be compared at once
+  Math(EXPR req_vers "${ROOT_FIND_VERSION_MAJOR}*10000 + ${ROOT_FIND_VERSION_MINOR}*100 + ${ROOT_FIND_VERSION_PATCH}")
+  Math(EXPR found_vers "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}")
+  Math(EXPR ROOT_FOUND_VERSION "${ROOT_VERSION_MAJOR}*10000 + ${ROOT_VERSION_MINOR}*100 + ${ROOT_VERSION_PATCH}")
 
-  # compute an overall version number which can be compared at once
-  MATH(EXPR req_vers "${req_root_major_vers}*10000 + ${req_root_minor_vers}*100 + ${req_root_patch_vers}")
-  MATH(EXPR found_vers "${found_root_major_vers}*10000 + ${found_root_minor_vers}*100 + ${found_root_patch_vers}")
-   
   Set(ROOT_Version ${found_vers})
+  Set(ROOT_VERSION_NUMBER ${found_vers})
 
-  IF (found_vers LESS req_vers)
-    SET(ROOT_FOUND FALSE)
-    SET(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
-  ELSE (found_vers LESS req_vers)
-    SET(ROOT_FOUND TRUE)
-  ENDIF (found_vers LESS req_vers)
+  If(found_vers LESS req_vers)
+    Set(ROOT_FOUND FALSE)
+    Set(ROOT_INSTALLED_VERSION_TOO_OLD TRUE)
+  Else(found_vers LESS req_vers)
+    Set(ROOT_FOUND TRUE)
+  EndIf(found_vers LESS req_vers)
 
-ENDIF (ROOT_CONFIG_EXECUTABLE)
+Else(ROOT_CONFIG_EXECUTABLE)
+  Message(STATUS "Looking for Root... - Not found")
+  Message(FATAL_ERROR "ROOT not installed in the searchpath and ROOTSYS is not set. Please set ROOTSYS or add the path to your ROOT installation in the Macro FindROOT.cmake in the subdirectory cmake/modules.")
+Endif(ROOT_CONFIG_EXECUTABLE)
 
 
-IF (ROOT_FOUND)
+If(ROOT_FOUND)
 
   # ask root-config for the library dir
   # Set ROOT_LIBRARY_DIR
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --libdir
+                  OUTPUT_VARIABLE ROOT_LIBRARY_DIR
+                 )
+  String(STRIP ${ROOT_LIBRARY_DIR} ROOT_LIBRARY_DIR)
 
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--libdir"
-    OUTPUT_VARIABLE ROOT_LIBRARY_DIR_TMP )
-
-  IF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    SET(ROOT_LIBRARY_DIR ${ROOT_LIBRARY_DIR_TMP} )
-  ELSE(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    MESSAGE("Warning: ROOT_CONFIG_EXECUTABLE reported ${ROOT_LIBRARY_DIR_TMP} as library path,")
-    MESSAGE("Warning: but ${ROOT_LIBRARY_DIR_TMP} does NOT exist, ROOT must NOT be installed correctly.")
-  ENDIF(EXISTS "${ROOT_LIBRARY_DIR_TMP}")
-    
   # ask root-config for the binary dir
-  EXEC_PROGRAM(${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--bindir"
-    OUTPUT_VARIABLE root_bins )
-  SET(ROOT_BINARY_DIR ${root_bins})
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --bindir
+                  OUTPUT_VARIABLE ROOT_BINARY_DIR
+                 )
+  String(STRIP ${ROOT_BINARY_DIR} ROOT_BINARY_DIR)
 
   # ask root-config for the include dir
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-    ARGS "--incdir" 
-    OUTPUT_VARIABLE root_headers )
-  SET(ROOT_INCLUDE_DIR ${root_headers})
-      # CACHE INTERNAL "")
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir
+                  OUTPUT_VARIABLE ROOT_INCLUDE_DIR
+                 )
+  String(STRIP ${ROOT_INCLUDE_DIR} ROOT_INCLUDE_DIR)
 
   # ask root-config for the library varaibles
-  EXEC_PROGRAM( ${ROOT_CONFIG_EXECUTABLE}
-#    ARGS "--noldflags --noauxlibs --libs" 
-    ARGS "--glibs" 
-    OUTPUT_VARIABLE root_flags )
-
-#  STRING(REGEX MATCHALL "([^ ])+"  root_libs_all ${root_flags})
-#  STRING(REGEX MATCHALL "-L([^ ])+"  root_library ${root_flags})
-#  REMOVE_FROM_LIST(root_flags "${root_libs_all}" "${root_library}")
-
-  SET(ROOT_LIBRARIES ${root_flags})
+  Execute_Process(COMMAND ${ROOT_CONFIG_EXECUTABLE} --glibs
+                  OUTPUT_VARIABLE ROOT_LIBRARIES
+                 )
+  String(STRIP ${ROOT_LIBRARIES} ROOT_LIBRARIES)
 
   # Make variables changeble to the advanced user
-  MARK_AS_ADVANCED( ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
+  Mark_As_Advanced(ROOT_LIBRARY_DIR ROOT_INCLUDE_DIR ROOT_DEFINITIONS)
 
   # Set ROOT_INCLUDES
-  SET( ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
+  Set(ROOT_INCLUDES ${ROOT_INCLUDE_DIR})
 
-  SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
+  Set(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${ROOT_LIBRARY_DIR})
 
   #######################################
   #
@@ -141,265 +149,26 @@ IF (ROOT_FOUND)
   #
   #######################################
 
-  FIND_PROGRAM(ROOT_CINT_EXECUTABLE
+  Find_Program(ROOT_CINT_EXECUTABLE
     NAMES rootcint
     PATHS ${ROOT_BINARY_DIR}
     NO_DEFAULT_PATH
     )
 
-  FIND_PROGRAM(RLIBMAP_EXECUTABLE
+  Find_Program(RLIBMAP_EXECUTABLE
     NAMES rlibmap
     PATHS ${ROOT_BINARY_DIR}
     NO_DEFAULT_PATH
     )
 
-ENDIF (ROOT_FOUND)
-
-
-
-function(Format _output input prefix suffix)
-
-# DevNotes - input should be put in quotes or the complete list does not get passed to the function
-  set(format)
-  foreach(arg ${input})
-    set(item ${arg})
-    if(prefix)
-      string(REGEX MATCH "^${prefix}" pre ${arg})
-    endif(prefix)
-    if(suffix)
-      string(REGEX MATCH "${suffix}$" suf ${arg})
-    endif(suffix)
-    if(NOT pre)
-      set(item "${prefix}${item}")
-    endif(NOT pre)
-    if(NOT suf)
-      set(item "${item}${suffix}")
-    endif(NOT suf)
-    list(APPEND format ${item})
-  endforeach(arg)
-  set(${_output} ${format} PARENT_SCOPE)
-
-endfunction(Format)
-
-
-  ###########################################
-  #
-  #       Macros for building ROOT dictionary
-  #
-  ###########################################
-Macro(ROOT_GENERATE_DICTIONARY)
-
-  # Macro to switch between the old implementation with parameters
-  # and the new implementation without parameters.
-  # For the new implementation some CMake variables has to be defined
-  # before calling the macro.
-
-  If(${ARGC} EQUAL 0)
-#    Message("New Version")
-    ROOT_GENERATE_DICTIONARY_NEW()
-  Else(${ARGC} EQUAL 0)
-    If(${ARGC} EQUAL 4)
-#      Message("Old Version")
-      ROOT_GENERATE_DICTIONARY_OLD("${ARGV0}" "${ARGV1}" "${ARGV2}" "${ARGV3}")
-    Else(${ARGC} EQUAL 4)
-      Message(FATAL_ERROR "Has to be implemented")  
-    EndIf(${ARGC} EQUAL 4)
-  EndIf(${ARGC} EQUAL 0)
- 
-EndMacro(ROOT_GENERATE_DICTIONARY)
-
-Macro(ROOT_GENERATE_DICTIONARY_NEW)
-
-  # All Arguments needed for this new version of the macro are defined
-  # in the parent scope, namely in the CMakeLists.txt of the submodule 
-  set(Int_LINKDEF ${LINKDEF})
-  set(Int_DICTIONARY ${DICTIONARY})
-
-#  Message("DEFINITIONS: ${DEFINITIONS}")
-  set(Int_INC ${INCLUDE_DIRECTORIES})
-  set(Int_HDRS ${HDRS})
-  set(Int_DEF ${DEFINITIONS})
-
-  # Convert the values of the variable to a semi-colon separated list
-  separate_arguments(Int_INC)
-  separate_arguments(Int_HDRS)
-  separate_arguments(Int_DEF)
-
-  # Format neccesary arguments
-  # Add -I and -D to include directories and definitions
-  Format(Int_INC "${Int_INC}" "-I" "")
-  Format(Int_DEF "${Int_DEF}" "-D" "")
-
-  set_source_files_properties(${Int_DICTIONARY} PROPERTIES GENERATED TRUE)
-  If (CMAKE_SYSTEM_NAME MATCHES Linux)
-    add_custom_command(OUTPUT  ${Int_DICTIONARY}
-                       COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} -f ${Int_DICTIONARY} -c -p ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF}
-                       DEPENDS ${Int_HDRS} ${Int_LINKDEF}
-                       )
-  Else (CMAKE_SYSTEM_NAME MATCHES Linux)
-    If (CMAKE_SYSTEM_NAME MATCHES Darwin)
-      add_custom_command(OUTPUT  ${Int_DICTIONARY}
-                         COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} -f ${Int_DICTIONARY} -c -p ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF}
-                         DEPENDS ${Int_HDRS} ${Int_LINKDEF}
-                         )
-    EndIf (CMAKE_SYSTEM_NAME MATCHES Darwin)
-  EndIf (CMAKE_SYSTEM_NAME MATCHES Linux)
-
-
-endmacro(ROOT_GENERATE_DICTIONARY_NEW)
-
-
-MACRO (ROOT_GENERATE_DICTIONARY_OLD INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
- 
-  set(INCLUDE_DIRS)
-
-  foreach (_current_FILE ${INCLUDE_DIRS_IN})
-    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
-  endforeach (_current_FILE ${INCLUDE_DIRS_IN})
- 
-#  Message("Definitions: ${DEFINITIONS}")
-#  MESSAGE("INFILES: ${INFILES}")
-#  MESSAGE("OutFILE: ${OUTFILE}")
-#  MESSAGE("LINKDEF_FILE: ${LINKDEF_FILE}")
-#  MESSAGE("INCLUDE_DIRS: ${INCLUDE_DIRS}")
-
-  STRING(REGEX REPLACE "^(.*)\\.(.*)$" "\\1.h" bla "${OUTFILE}")
-#  MESSAGE("BLA: ${bla}")
-  SET (OUTFILES ${OUTFILE} ${bla})
-
-
-  if (CMAKE_SYSTEM_NAME MATCHES Linux)
-    ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
-       COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE}
-       ARGS -f ${OUTFILE} -c -p -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE})
-  else (CMAKE_SYSTEM_NAME MATCHES Linux)
-    if (CMAKE_SYSTEM_NAME MATCHES Darwin)
-      ADD_CUSTOM_COMMAND(OUTPUT ${OUTFILES}
-       COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE}
-       ARGS -f ${OUTFILE} -c -p -DHAVE_CONFIG_H ${INCLUDE_DIRS} ${INFILES} ${LINKDEF_FILE} DEPENDS ${INFILES} ${LINKDEF_FILE})
-    endif (CMAKE_SYSTEM_NAME MATCHES Darwin)
-  endif (CMAKE_SYSTEM_NAME MATCHES Linux)
-
-ENDMACRO (ROOT_GENERATE_DICTIONARY_OLD)
-
-MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME)
-
-  get_filename_component(path_name ${SCRIPT_FULL_NAME} PATH)
-  get_filename_component(file_extension ${SCRIPT_FULL_NAME} EXT)
-  get_filename_component(file_name ${SCRIPT_FULL_NAME} NAME_WE)
-  set(shell_script_name "${file_name}.sh")
-
-  #MESSAGE("PATH: ${path_name}")
-  #MESSAGE("Ext: ${file_extension}")
-  #MESSAGE("Name: ${file_name}")
-  #MESSAGE("Shell Name: ${shell_script_name}")
-
-  string(REPLACE ${PROJECT_SOURCE_DIR} 
-         ${PROJECT_BINARY_DIR} new_path ${path_name}
-        )
-
-  #MESSAGE("New PATH: ${new_path}")
-
-  file(MAKE_DIRECTORY ${new_path}/data)
-
-  CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
-  set(MY_LD_LIBRARY_PATH ${output})
-  set(my_script_name ${SCRIPT_FULL_NAME})
-
-  configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in
-                 ${new_path}/${shell_script_name}
-                )
-
-  EXEC_PROGRAM(/bin/chmod ARGS "u+x  ${new_path}/${shell_script_name}")
-
-ENDMACRO (GENERATE_ROOT_TEST_SCRIPT)
-
-
-Macro(ROOT_GENERATE_ROOTMAP)
-
-  # All Arguments needed for this new version of the macro are defined
-  # in the parent scope, namely in the CMakeLists.txt of the submodule
-  If( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${LINKDEF})
-  Else( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF})
-  EndIf( IS_ABSOLUTE ${LINKDEF})
-
-  foreach(d ${DEPENDENCIES})
-    get_filename_component(_ext ${d} EXT)
-    if(_ext)
-      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d})
-    else()
-      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} lib${d}.so)
-    endif()
-  endforeach()
-
-  set(Int_LIB ${LIBRARY_NAME})
-  set(Int_OUTFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap)
-
-
-  add_custom_command(OUTPUT ${Int_OUTFILE}
-                     COMMAND ${RLIBMAP_EXECUTABLE} -o ${Int_OUTFILE} -l ${Int_LIB} 
-                             -d ${Int_DEPENDENCIES} -c ${Int_LINKDEF}
-                     DEPENDS ${Int_LINKDEF} ${RLIBMAP_EXECUTABLE} )
-  add_custom_target( lib${Int_LIB}.rootmap ALL DEPENDS  ${Int_OUTFILE})
-  set_target_properties(lib${Int_LIB}.rootmap PROPERTIES FOLDER RootMaps )
-  #---Install the rootmap file------------------------------------
-  install(FILES ${Int_OUTFILE} DESTINATION lib COMPONENT libraries)
-EndMacro(ROOT_GENERATE_ROOTMAP)
-
-Macro(GENERATE_LIBRARY)
-
-  set(Int_LIB ${LIBRARY_NAME})
-
-  Set(RuleName "${Int_LIB}_RULES")
-  Set(DictName "G__${Int_LIB}Dict.cxx")
-
-  If(NOT DICTIONARY)
-    Set(DICTIONARY ${CMAKE_CURRENT_BINARY_DIR}/${DictName})
-  EndIf(NOT DICTIONARY)
-
-  If( IS_ABSOLUTE ${DICTIONARY})
-    Set(DICTIONARY ${DICTIONARY})
-  Else( IS_ABSOLUTE ${DICTIONARY})
-    Set(Int_DICTIONARY ${CMAKE_CURRENT_SOURCE_DIR}/${DICTIONARY})
-  EndIf( IS_ABSOLUTE ${DICTIONARY})
-  
-  If( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${LINKDEF})
-  Else( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF})
-  EndIf( IS_ABSOLUTE ${LINKDEF})
-
-  Set(Int_SRCS ${SRCS})
-
-  If(HEADERS)
-    Set(HDRS ${HEADERS})
-  Else(HEADERS)
-    CHANGE_FILE_EXTENSION(*.cxx *.h HDRS "${SRCS}")
-#  Message("HEADERS: ${HEADERS}")  
-#  Message("HDRS: ${HDRS}")  
-#  Message("HDRS: ${HDRS}")  
-  EndIf(HEADERS)
-
-#  Message("RuleName: ${RuleName}")
-  If(RULE_CHECKER_FOUND)
-    CHECK_RULES("${Int_SRCS}" "${INCLUDE_DIRECTORIES}" ${RuleName})
-  EndIf(RULE_CHECKER_FOUND)
-
-  ROOT_GENERATE_DICTIONARY()
-  SET(Int_SRCS ${Int_SRCS} ${DICTIONARY})
- 
-#  ROOT_GENERATE_ROOTMAP()  
- 
-  ############### build the library #####################
-  Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS})
-  target_link_libraries(${Int_LIB})
-  set_target_properties(${Int_LIB} PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES})
-
-  ############### install the library ###################
-  install(TARGETS ${Int_LIB} DESTINATION ${CMAKE_BINARY_DIR}/lib)
+    Include(ROOTMacros)
 
-EndMacro(GENERATE_LIBRARY)
+Else(ROOT_FOUND)
 
+  If(ROOT_FIND_REQUIRED)
+    Message(STATUS "Looking for ROOT... - Found version to old.")
+    Message(STATUS "Looking for ROOT... - Minimum required version is ${ROOT_FIND_VERSION}")
+    Message(FATAL_ERROR "Stop here because of a wrong Root version.")
+  EndIf(ROOT_FIND_REQUIRED)
 
+Endif(ROOT_FOUND)
diff --git a/cmake/modules/FindSQLITE.cmake b/cmake/modules/FindSQLITE.cmake
new file mode 100644
index 0000000..3a6b98e
--- /dev/null
+++ b/cmake/modules/FindSQLITE.cmake
@@ -0,0 +1,39 @@
+# - Try to find the sqlite library
+# Once done this will define
+#
+#  SQLITE_FOUND - system has sqlite
+#  SQLITE_INCLUDE_DIR - the sqlite include directory
+#  SQLITE_LIBRARY_DIR
+#  SQLITE_LIBRARIES - Link these to use sqlite
+#
+
+# <D.Bertini> : 
+#    Date: 11.08.2014 -- Changes to favor user local installation
+
+
+
+	find_path(SQLITE_INCLUDE_DIR sqlite3.h
+              PATHS
+              /usr/local/include
+              /usr/include
+              )
+	find_library(SQLITE_LIBRARIES sqlite3 
+                NAMES sqlite3
+                PATHS
+                /usr/local/lib
+                /usr/lib
+              )
+get_filename_component( SQLITE_LIBRARY_DIR ${SQLITE_LIBRARIES}  PATH )
+
+if(SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
+	    set(SQLITE_FOUND TRUE)
+	    message(STATUS "Found SQLite: ${SQLITE_INCLUDE_DIR}, ${SQLITE_LIBRARY_DIR}, ${SQLITE_LIBRARIES}")
+	    INCLUDE_DIRECTORIES(${SQLITE_INCLUDE_DIR})
+	  else(SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
+	    set(SQLITE_FOUND FALSE)
+	    message(STATUS "SQLite not found.")
+endif(SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
+
+
+
+MARK_AS_ADVANCED(SQLITE_LIBRARIES SQLITE_INCLUDE_DIR)
diff --git a/cmake/modules/FindSSE.cmake b/cmake/modules/FindSSE.cmake
index f18af1c..1d6e8b5 100644
--- a/cmake/modules/FindSSE.cmake
+++ b/cmake/modules/FindSSE.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Check if SSE instructions are available on the machine where 
 # the project is compiled.
 
diff --git a/cmake/modules/FindTBB.cmake b/cmake/modules/FindTBB.cmake
index 9351210..ac577cd 100644
--- a/cmake/modules/FindTBB.cmake
+++ b/cmake/modules/FindTBB.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Locate Intel Threading Building Blocks include paths and libraries
 # TBB can be found at http://www.threadingbuildingblocks.org/ 
 # Written by Hannes Hofmann, hannes.hofmann _at_ informatik.uni-erlangen.de
diff --git a/cmake/modules/FindTDAQ.cmake b/cmake/modules/FindTDAQ.cmake
new file mode 100644
index 0000000..6a8ab7a
--- /dev/null
+++ b/cmake/modules/FindTDAQ.cmake
@@ -0,0 +1,63 @@
+# Searching for TDAQ installation
+# Once done this will define
+#  TDAQ_FOUND - system has TDAQ framework
+#  TDAQ_INCLUDE_PATH - the TDAQ include directory
+#  TDAQ_LIBRARY_PATH - the TDAQ library directory
+
+if (NOT TDAQ_SW)
+  FIND_PATH(TDAQ_SW NAMES ipc_root.ref PATHS
+    /tdaq/tdaq_sw
+    NO_DEFAULT_PATH
+  )
+endif (NOT TDAQ_SW)
+
+if (NOT TDAQ_LIBRARY_PATH)
+  FIND_PATH(TDAQ_EMON_LIBRARY_DIR NAMES libemon.so PATHS
+    ${TDAQ_SW_DIR}/emon/lib
+    /tdaq/tdaq_sw/emon/lib
+    NO_DEFAULT_PATH
+  )
+  FIND_PATH(TDAQ_IS_LIBRARY_DIR NAMES libXm.so PATHS
+    ${TDAQ_SW_DIR}/is/lib
+    /tdaq/tdaq_sw/is/lib
+    NO_DEFAULT_PATH
+  )
+
+  if (TDAQ_EMON_LIBRARY_DIR AND TDAQ_IS_LIBRARY_DIR)
+    set(TDAQ_LIBRARY_PATH ${TDAQ_EMON_LIBRARY_DIR} ${TDAQ_IS_LIBRARY_DIR})
+  endif (TDAQ_EMON_LIBRARY_DIR AND TDAQ_IS_LIBRARY_DIR)
+endif (NOT TDAQ_LIBRARY_PATH)
+
+FIND_PATH(TDAQ_SW_INCLUDE_DIR NAMES ers/ers.h PATHS
+  ${TDAQ_SW_DIR}/include
+  /tdaq/tdaq_sw/include
+  NO_DEFAULT_PATH
+)
+FIND_PATH(TDAQ_EMON_INCLUDE_DIR NAMES emon/emon.hh PATHS
+  ${TDAQ_SW_DIR}/emon/include
+  /tdaq/tdaq_sw/emon/include
+  NO_DEFAULT_PATH
+)
+FIND_PATH(TDAQ_IS_INCLUDE_DIR NAMES is/is.hh PATHS
+  ${TDAQ_SW_DIR}/is/include
+  /tdaq/tdaq_sw/is/include
+  NO_DEFAULT_PATH
+)
+
+if (TDAQ_SW_INCLUDE_DIR AND TDAQ_EMON_INCLUDE_DIR AND TDAQ_IS_INCLUDE_DIR)
+  set(TDAQ_INCLUDE_PATH ${TDAQ_SW_INCLUDE_DIR} ${TDAQ_EMON_INCLUDE_DIR} ${TDAQ_IS_INCLUDE_DIR})
+endif (TDAQ_SW_INCLUDE_DIR AND TDAQ_EMON_INCLUDE_DIR AND TDAQ_IS_INCLUDE_DIR)
+
+
+if (TDAQ_SW AND TDAQ_INCLUDE_PATH AND TDAQ_LIBRARY_PATH)
+  set(TDAQ_FOUND TRUE)
+  
+  if (NOT TDAQ_FIND_QUIETLY)
+    MESSAGE(STATUS "Looking for ATLAS TDAQ... found ${TDAQ_SW}")
+    SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${TDAQ_LIBRARY_PATH})
+  endif (NOT TDAQ_FIND_QUIETLY)
+else (TDAQ_SW AND TDAQ_INCLUDE_PATH AND TDAQ_LIBRARY_PATH)
+  if (TDAQ_FIND_REQUIRED)
+    message(FATAL_ERROR "Looking for ATLAS TDAQ... - Not found")
+  endif (TDAQ_FIND_REQUIRED)
+endif (TDAQ_SW AND TDAQ_INCLUDE_PATH AND TDAQ_LIBRARY_PATH)
diff --git a/cmake/modules/FindXML2.cmake b/cmake/modules/FindXML2.cmake
new file mode 100644
index 0000000..9077a26
--- /dev/null
+++ b/cmake/modules/FindXML2.cmake
@@ -0,0 +1,34 @@
+# Searching libxml2 installation
+# Once done this will define
+#  XML2_FOUND - system has libxml2
+#  XML2_INCLUDE_DIR - the libxml2 include directory
+#  XML2_LIBRARY_DIR - the libxml2 library directory
+#  XML2_LIBRARIES - the libraries needed to use libxml2
+
+if (XML2_INCLUDE_DIR OR XML2_LIBRARIES)
+  SET (XML2_INCLUDE_DIR XML2_INCLUDE_DIR-NOTFOUND)
+  SET (XML2_LIBRARIES XML2_LIBRARIES-NOTFOUND)
+endif (XML2_INCLUDE_DIR OR XML2_LIBRARIES)
+
+MESSAGE(STATUS "Looking for libxml2...")
+
+FIND_PATH(XML2_INCLUDE_DIR NAMES libxml/xmlversion.h PATHS /usr/include/libxml2)
+
+FIND_LIBRARY(XML2_LIBRARIES NAMES xml2)
+
+if (XML2_INCLUDE_DIR AND XML2_LIBRARIES)
+   set(XML2_FOUND TRUE)
+   get_filename_component(XML2_LIBRARY_DIR ${XML2_LIBRARIES} DIRECTORY)
+endif (XML2_INCLUDE_DIR AND XML2_LIBRARIES)
+
+if (XML2_FOUND)
+  if (NOT XML2_FIND_QUIETLY)
+    MESSAGE(STATUS "Looking for libxml2... - found ${XML2_LIBRARIES}")
+    SET(LD_LIBRARY_PATH ${LD_LIBRARY_PATH} ${XML2_LIBRARY_DIR})
+  endif (NOT XML2_FIND_QUIETLY)
+else (XML2_FOUND)
+  if (XML2_FIND_REQUIRED)
+    message(FATAL_ERROR "Looking for libxml2... - Not found")
+  endif (XML2_FIND_REQUIRED)
+endif (XML2_FOUND)
+
diff --git a/cmake/modules/FindZeroMQ.cmake b/cmake/modules/FindZeroMQ.cmake
index 29786eb..d0677cc 100644
--- a/cmake/modules/FindZeroMQ.cmake
+++ b/cmake/modules/FindZeroMQ.cmake
@@ -1,44 +1,97 @@
-message(STATUS "Looking for ZeroMQ...")
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 
-set(ZMQ_H zmq.h)
-set(ZMQ_UTILS_H zmq_utils.h)
-set(LIBZMQ_SHARED libzmq.so)
-set(LIBZMQ_STATIC libzmq.a)
+if(NOT ZeroMQ_FIND_QUIETLY)
+  message(STATUS "Looking for ZeroMQ...")
+endif(NOT ZeroMQ_FIND_QUIETLY)
 
-find_path(ZMQ_INCLUDE_DIR NAMES ${ZMQ_H} ${ZMQ_UTILS_H}
+find_path(ZMQ_INCLUDE_DIR NAMES zmq.hpp zmq_utils.h
+  PATHS ${ZMQ_DIR}/include
+  PATHS ${AlFa_DIR}/include
   PATHS ${SIMPATH}/include
+  NO_DEFAULT_PATH
   DOC   "Path to ZeroMQ include header files."
 )
 
-find_library(ZMQ_LIBRARY_SHARED NAMES ${LIBZMQ_SHARED}
+find_path(ZMQ_INCLUDE_DIR NAMES zmq.hpp zmq_utils.h
+  DOC   "Path to ZeroMQ include header files."
+)
+
+find_library(ZMQ_LIBRARY_SHARED NAMES libzmq.dylib libzmq.so
+  PATHS ${ZMQ_DIR}/lib
+  PATHS ${AlFa_DIR}/lib
   PATHS ${SIMPATH}/lib
-  DOC   "Path to ${LIBZMQ_SHARED}."
+  NO_DEFAULT_PATH
+  DOC   "Path to libzmq.dylib libzmq.so."
 )
 
-find_library(ZMQ_LIBRARY_STATIC NAMES ${LIBZMQ_STATIC}
+find_library(ZMQ_LIBRARY_SHARED NAMES libzmq.dylib libzmq.so
+  DOC   "Path to libzmq.dylib libzmq.so."
+)
+
+find_library(ZMQ_LIBRARY_STATIC NAMES libzmq.a
+  PATHS ${ZMQ_DIR}/lib
+  PATHS ${AlFa_DIR}/lib
   PATHS ${SIMPATH}/lib
-  DOC   "Path to ${LIBZMQ_STATIC}."
+  NO_DEFAULT_PATH
+  DOC   "Path to libzmq.a."
 )
 
+find_library(ZMQ_LIBRARY_STATIC NAMES libzmq.a
+  DOC   "Path to libzmq.a."
+)
+
+
 IF(ZMQ_INCLUDE_DIR AND ZMQ_LIBRARY_SHARED AND ZMQ_LIBRARY_STATIC)
   SET(ZMQ_FOUND TRUE)
 ELSE(ZMQ_INCLUDE_DIR AND ZMQ_LIBRARY_SHARED AND ZMQ_LIBRARY_STATIC)
   SET(ZMQ_FOUND FALSE)
 ENDIF(ZMQ_INCLUDE_DIR AND ZMQ_LIBRARY_SHARED AND ZMQ_LIBRARY_STATIC)
 
+set(ERROR_STRING "Looking for ZeroMQ... - Not found")
+
+if(ZMQ_FOUND)
+  FIND_FILE(ZMQ_HEADER_FILE zmq.h
+    ${ZMQ_INCLUDE_DIR}
+    NO_DEFAULT_PATH
+    )
+  IF (DEFINED ZMQ_HEADER_FILE)
+    FILE(READ "${ZMQ_HEADER_FILE}" _ZMQ_HEADER_FILE_CONTENT)
+    STRING(REGEX MATCH "#define ZMQ_VERSION_MAJOR ([0-9])" _MATCH "${_ZMQ_HEADER_FILE_CONTENT}")
+    SET(ZMQ_VERSION_MAJOR ${CMAKE_MATCH_1})
+    STRING(REGEX MATCH "#define ZMQ_VERSION_MINOR ([0-9])" _MATCH "${_ZMQ_HEADER_FILE_CONTENT}")
+    SET(ZMQ_VERSION_MINOR ${CMAKE_MATCH_1})
+    STRING(REGEX MATCH "#define ZMQ_VERSION_PATCH ([0-9])" _MATCH "${_ZMQ_HEADER_FILE_CONTENT}")
+    SET(ZMQ_VERSION_PATCH ${CMAKE_MATCH_1})
+    set (ZMQ_VERSION "${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}")
+    IF (DEFINED ZeroMQ_FIND_VERSION AND ZMQ_VERSION VERSION_LESS ZeroMQ_FIND_VERSION)
+      SET(ZMQ_FOUND FALSE)
+      SET(ERROR_STRING "Installed version ${ZMQ_VERSION} of ZeroMQ does not meet the minimum required version ${ZeroMQ_FIND_VERSION}")
+    endif ()
+  endif ()
+endif()
+
 if(ZMQ_FOUND)
   set(ZMQ_LIBRARIES "${ZMQ_LIBRARY_STATIC};${ZMQ_LIBRARY_SHARED}")
-  if(NOT ZMQ_FIND_QUIETLY)
-    message(STATUS "Looking for ZeroMQ... - found ${ZMQ_LIBRARIES}")
-  endif(NOT ZMQ_FIND_QUIETLY)
+  if(NOT ZeroMQ_FIND_QUIETLY)
+    message(STATUS "Looking for ZeroMQ... - found ${ZMQ_LIBRARIES} ${ZMQ_VERSION}")
+  endif(NOT ZeroMQ_FIND_QUIETLY)
 else(ZMQ_FOUND)
-  if(NOT ZMQ_FIND_QUIETLY)
-    if(ZMQ_FIND_REQUIRED)
-      message(FATAL_ERROR "Looking for ZeroMQ... - Not found")
-    else(ZMQ_FIND_REQUIRED)
-      message(STATUS "Looking for ZeroMQ... - Not found")
-    endif(ZMQ_FIND_REQUIRED)
-  endif(NOT ZMQ_FIND_QUIETLY)
+  unset(ZMQ_INCLUDE_DIR)
+  unset(ZMQ_LIBRARY_SHARED)
+  unset(ZMQ_LIBRARY_STATIC)
+  if(ZeroMQ_FIND_REQUIRED)
+    message(FATAL_ERROR "${ERROR_STRING}")
+  else(ZeroMQ_FIND_REQUIRED)
+    if(NOT ZeroMQ_FIND_QUIETLY)
+      message(STATUS "${ERROR_STRING}")
+    endif(NOT ZeroMQ_FIND_QUIETLY)
+  endif(ZeroMQ_FIND_REQUIRED)
 endif(ZMQ_FOUND)
 
 mark_as_advanced(ZMQ_INCLUDE_DIR ZMQ_LIBRARIES ZMQ_LIBRARY_SHARED ZMQ_LIBRARY_STATIC)
diff --git a/cmake/modules/Findglpk.cmake b/cmake/modules/Findglpk.cmake
index bf318ca..da49995 100644
--- a/cmake/modules/Findglpk.cmake
+++ b/cmake/modules/Findglpk.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find GLPK instalation
 # Once done this will define
 #
diff --git a/cmake/modules/Findnanomsg.cmake b/cmake/modules/Findnanomsg.cmake
new file mode 100644
index 0000000..7af5a87
--- /dev/null
+++ b/cmake/modules/Findnanomsg.cmake
@@ -0,0 +1,48 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+
+MESSAGE(STATUS "Looking for nanomsg...")
+
+find_path(NANOMSG_INCLUDE_DIR NAMES nanomsg/nn.h
+  PATHS ${NANOMSG_DIR}/include
+  PATHS ${AlFa_DIR}/include
+  PATHS ${SIMPATH}/include
+  NO_DEFAULT_PATH
+  DOC   "Path to nanomsg include header files."
+)
+
+find_library(NANOMSG_LIBRARY_SHARED NAMES libnanomsg.dylib libnanomsg.so
+  PATHS ${NANOMSG_DIR}/lib
+  PATHS ${AlFa_DIR}/lib
+  PATHS ${SIMPATH}/lib
+  NO_DEFAULT_PATH
+  DOC   "Path to libnanomsg.dylib libnanomsg.so."
+)
+
+if(NANOMSG_INCLUDE_DIR AND NANOMSG_LIBRARY_SHARED)
+  set(NANOMSG_FOUND true)
+else(NANOMSG_INCLUDE_DIR AND NANOMSG_LIBRARY_SHARED)
+  set(NANOMSG_FOUND false)
+endif(NANOMSG_INCLUDE_DIR AND NANOMSG_LIBRARY_SHARED)
+
+if(NANOMSG_FOUND)
+  set(NANOMSG_LIBRARIES "${NANOMSG_LIBRARY_SHARED}")
+  if(NOT NANOMSG_FIND_QUIETLY)
+    message(STATUS "Looking for nanomsg... - found ${NANOMSG_LIBRARIES}")
+  endif(NOT NANOMSG_FIND_QUIETLY)
+else(NANOMSG_FOUND)
+  if(NOT NANOMSG_FIND_QUIETLY)
+    if(NANOMSG_FIND_REQUIRED)
+      message(FATAL_ERROR "Looking for nanomsg... - Not found")
+    else(NANOMSG_FIND_REQUIRED)
+      message(STATUS "Looking for nanomsg... - Not found")
+    endif(NANOMSG_FIND_REQUIRED)
+  endif(NOT NANOMSG_FIND_QUIETLY)
+endif(NANOMSG_FOUND)
+
+mark_as_advanced(NANOMSG_INCLUDE_DIR NANOMSG_LIBRARIES NANOMSG_LIBRARY_SHARED)
diff --git a/cmake/modules/GenerateVersionInfo.cmake b/cmake/modules/GenerateVersionInfo.cmake
index 36076a5..5efcd8d 100644
--- a/cmake/modules/GenerateVersionInfo.cmake
+++ b/cmake/modules/GenerateVersionInfo.cmake
@@ -1,19 +1,38 @@
-  # Configure FairVersion.h
-  # ------------------------------
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+ # Configure FairVersion.h
+ # ------------------------------
 
-  Find_Package(Subversion)
+ Find_Package(Git)
 
-  If(Subversion_FOUND AND EXISTS ${SOURCE_DIR}/.svn/ )
-    Subversion_WC_INFO(${SOURCE_DIR} PROJECT)
-    Set(FAIRROOT_SVN_REVISION ${PROJECT_WC_REVISION})
-    Set(FAIRROOT_SVN_BRANCH ${PROJECT_WC_URL})
-    Set(FAIRROOT_SVN_DATE ${PROJECT_WC_LAST_CHANGED_DATE})
-#    String(REGEX MATCH "[^/]+$" FAIRROOT_SVN_BRANCH ${FAIRROOT_SVN_BRANCH})
-    Message(STATUS "FairRoot Revision - ${FAIRROOT_SVN_REVISION} Branch - ${FAIRROOT_SVN_BRANCH}")
-    Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.tmp ${BINARY_DIR}/FairVersion.h @ONLY)
-  Else(Subversion_FOUND AND EXISTS ${SOURCE_DIR}/.svn/ )
-    Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.default ${BINARY_DIR}/FairVersion.h COPYONLY)
-  EndIf(Subversion_FOUND AND EXISTS ${SOURCE_DIR}/.svn/ )
+ If(GIT_FOUND AND EXISTS "${SOURCE_DIR}/.git")
+   Execute_Process(COMMAND ${GIT_EXECUTABLE} describe
+                   OUTPUT_VARIABLE FAIRROOT_GIT_VERSION
+                   OUTPUT_STRIP_TRAILING_WHITESPACE
+                   WORKING_DIRECTORY ${SOURCE_DIR}
+                  )
+   Execute_Process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%cd
+                   OUTPUT_VARIABLE FAIRROOT_GIT_DATE
+                   OUTPUT_STRIP_TRAILING_WHITESPACE
+                   WORKING_DIRECTORY ${SOURCE_DIR}
+                  )
+   Message(STATUS "FairRoot Version - ${FAIRROOT_GIT_VERSION} from - ${FAIRROOT_GIT_DATE}")
+   if(FAIRROOT)
+     Configure_File(${FAIRROOT}/scripts/FairVersion.h.tmp ${BINARY_DIR}/FairVersion.h @ONLY)
+   else(FAIRROOT)  
+     Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.tmp ${BINARY_DIR}/FairVersion.h @ONLY)
+   endif(FAIRROOT)
+  
+ Else()
+   if(FAIRROOT)
+     Configure_File(${FAIRROOT}/scripts/FairVersion.h.default ${BINARY_DIR}/FairVersion.h COPYONLY)
+   else(FAIRROOT) 
+     Configure_File(${SOURCE_DIR}/cmake/scripts/FairVersion.h.default ${BINARY_DIR}/FairVersion.h COPYONLY)
+   endif(FAIRROOT)
+ EndIf()
 
-  Execute_Process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
-       ${BINARY_DIR}/FairVersion.h ${INCLUDE_OUTPUT_DIRECTORY}/FairVersion.h)
diff --git a/cmake/modules/ROOTMacros.cmake b/cmake/modules/ROOTMacros.cmake
index 4ab714f..b81f4a6 100644
--- a/cmake/modules/ROOTMacros.cmake
+++ b/cmake/modules/ROOTMacros.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             #
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 Function(Format _output input prefix suffix)
 
 # DevNotes - input should be put in quotes or the complete list does not get passed to the function
@@ -43,21 +50,21 @@ Macro(ROOT_GENERATE_DICTIONARY)
 #      Message("Old Version")
       ROOT_GENERATE_DICTIONARY_OLD("${ARGV0}" "${ARGV1}" "${ARGV2}" "${ARGV3}")
     Else(${ARGC} EQUAL 4)
-      Message(FATAL_ERROR "Has to be implemented")  
+      Message(FATAL_ERROR "Has to be implemented")
     EndIf(${ARGC} EQUAL 4)
   EndIf(${ARGC} EQUAL 0)
- 
+
 EndMacro(ROOT_GENERATE_DICTIONARY)
 
 Macro(ROOT_GENERATE_DICTIONARY_NEW)
 
   # All Arguments needed for this new version of the macro are defined
-  # in the parent scope, namely in the CMakeLists.txt of the submodule 
+  # in the parent scope, namely in the CMakeLists.txt of the submodule
   set(Int_LINKDEF ${LINKDEF})
   set(Int_DICTIONARY ${DICTIONARY})
+  set(Int_LIB ${LIBRARY_NAME})
 
-#  Message("DEFINITIONS: ${DEFINITIONS}")
-  set(Int_INC ${INCLUDE_DIRECTORIES})
+  set(Int_INC ${INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES})
   set(Int_HDRS ${HDRS})
   set(Int_DEF ${DEFINITIONS})
 
@@ -71,33 +78,75 @@ Macro(ROOT_GENERATE_DICTIONARY_NEW)
   Format(Int_INC "${Int_INC}" "-I" "")
   Format(Int_DEF "${Int_DEF}" "-D" "")
 
-  set_source_files_properties(${Int_DICTIONARY} PROPERTIES GENERATED TRUE)
+  #---call rootcint / cling --------------------------------
+  set(OUTPUT_FILES ${Int_DICTIONARY})
+
   If (CMAKE_SYSTEM_NAME MATCHES Linux)
-    add_custom_command(OUTPUT  ${Int_DICTIONARY}
-                       COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}:${_intel_lib_dirs} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} -f ${Int_DICTIONARY} -c  -p ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF}
+    Set(MY_LD_LIBRARY_PATH ${ROOT_LIBRARY_DIR}:${_intel_lib_dirs}:$ENV{LD_LIBRARY_PATH})
+  ElseIf(CMAKE_SYSTEM_NAME MATCHES Darwin)
+    Set(MY_LD_LIBRARY_PATH ${ROOT_LIBRARY_DIR}:$ENV{DYLD_LIBRARY_PATH})
+  EndIf()
+
+  get_filename_component(script_name ${Int_DICTIONARY} NAME_WE)
+  String(REPLACE ";" " " Int_DEF_STR "${Int_DEF}")
+  String(REPLACE ";" " " Int_INC_STR "${Int_INC}")
+  String(REPLACE ";" " " Int_HDRS_STR "${Int_HDRS}")
+
+  Set(EXTRA_DICT_PARAMETERS "")
+  If (ROOT_FOUND_VERSION GREATER 59999)
+
+    Set(Int_ROOTMAPFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap)
+    Set(Int_PCMFILE G__${Int_LIB}Dict_rdict.pcm)
+    Set(OUTPUT_FILES ${OUTPUT_FILES} ${Int_PCMFILE} ${Int_ROOTMAPFILE})
+    Set(EXTRA_DICT_PARAMETERS ${EXTRA_DICT_PARAMETERS}
+        -inlineInputHeader -rmf ${Int_ROOTMAPFILE} 
+        -rml ${Int_LIB}${CMAKE_SHARED_LIBRARY_SUFFIX})
+    Set_Source_Files_Properties(${OUTPUT_FILES} PROPERTIES GENERATED TRUE)
+    String(REPLACE ";" " " EXTRA_DICT_PARAMETERS_STR "${EXTRA_DICT_PARAMETERS}")
+
+  EndIf()
+
+  # We need some environment variables which are present when running cmake at the
+  # time we run make. To pass the variables a script is created containing the
+  # correct values for the needed variables
+
+  IF(FAIRROOTPATH)
+    Configure_File(${FAIRROOTPATH}/share/fairbase/cmake/scripts/generate_dictionary_root.sh.in
+                   ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh
+                  )
+    EXEC_PROGRAM(/bin/chmod ARGS "u+x ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh")
+  ELSE(FAIRROOTPATH)
+    Configure_File(${PROJECT_SOURCE_DIR}/cmake/scripts/generate_dictionary_root.sh.in
+                   ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh
+                  )
+  ENDIF(FAIRROOTPATH)
+
+
+  If (ROOT_FOUND_VERSION GREATER 59999)
+    Add_Custom_Command(OUTPUT  ${OUTPUT_FILES}
+                       COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh
+                       COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${Int_PCMFILE} ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE}
                        DEPENDS ${Int_HDRS} ${Int_LINKDEF}
-                       )
-  Else (CMAKE_SYSTEM_NAME MATCHES Linux)
-    If (CMAKE_SYSTEM_NAME MATCHES Darwin)
-      add_custom_command(OUTPUT  ${Int_DICTIONARY}
-                         COMMAND DYLD_LIBRARY_PATH=${ROOT_LIBRARY_DIR} ROOTSYS=${ROOTSYS} ${ROOT_CINT_EXECUTABLE} -f ${Int_DICTIONARY} -c  ${Int_DEF} ${Int_INC} ${Int_HDRS} ${Int_LINKDEF}
-                         DEPENDS ${Int_HDRS} ${Int_LINKDEF}
-                         )
-    EndIf (CMAKE_SYSTEM_NAME MATCHES Darwin)
-  EndIf (CMAKE_SYSTEM_NAME MATCHES Linux)
-
+                      )
+    Install(FILES ${LIBRARY_OUTPUT_PATH}/${Int_PCMFILE} ${Int_ROOTMAPFILE} DESTINATION lib)
+  Else()
+    Add_Custom_Command(OUTPUT  ${OUTPUT_FILES}
+                       COMMAND ${CMAKE_CURRENT_BINARY_DIR}/generate_dictionary_${script_name}.sh
+                       DEPENDS ${Int_HDRS} ${Int_LINKDEF}
+                      )
+  EndIf()
 
 endmacro(ROOT_GENERATE_DICTIONARY_NEW)
 
 
 MACRO (ROOT_GENERATE_DICTIONARY_OLD INFILES LINKDEF_FILE OUTFILE INCLUDE_DIRS_IN)
- 
+
   set(INCLUDE_DIRS)
 
   foreach (_current_FILE ${INCLUDE_DIRS_IN})
-    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})   
+    set(INCLUDE_DIRS ${INCLUDE_DIRS} -I${_current_FILE})
   endforeach (_current_FILE ${INCLUDE_DIRS_IN})
- 
+
 #  Message("Definitions: ${DEFINITIONS}")
 #  MESSAGE("INFILES: ${INFILES}")
 #  MESSAGE("OutFILE: ${OUTFILE}")
@@ -135,7 +184,7 @@ MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME)
   #MESSAGE("Name: ${file_name}")
   #MESSAGE("Shell Name: ${shell_script_name}")
 
-  string(REPLACE ${PROJECT_SOURCE_DIR} 
+  string(REPLACE ${PROJECT_SOURCE_DIR}
          ${PROJECT_BINARY_DIR} new_path ${path_name}
         )
 
@@ -145,11 +194,21 @@ MACRO (GENERATE_ROOT_TEST_SCRIPT SCRIPT_FULL_NAME)
 
   CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
   set(MY_LD_LIBRARY_PATH ${output})
+
+  CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_PATH})
+  set(MY_ROOT_INCLUDE_PATH ${output})
+
   set(my_script_name ${SCRIPT_FULL_NAME})
 
-  configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in
-                 ${new_path}/${shell_script_name}
-                )
+  IF(FAIRROOTPATH)
+    configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/root_macro.sh.in
+                   ${new_path}/${shell_script_name}
+                  )
+  ELSE(FAIRROOTPATH)
+    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/root_macro.sh.in
+                   ${new_path}/${shell_script_name}
+                  )
+  ENDIF(FAIRROOTPATH)
 
   EXEC_PROGRAM(/bin/chmod ARGS "u+x  ${new_path}/${shell_script_name}")
 
@@ -160,40 +219,49 @@ Macro(ROOT_GENERATE_ROOTMAP)
 
   # All Arguments needed for this new version of the macro are defined
   # in the parent scope, namely in the CMakeLists.txt of the submodule
-  If( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${LINKDEF})
-  Else( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF})
-  EndIf( IS_ABSOLUTE ${LINKDEF})
-
-  foreach(d ${DEPENDENCIES})
-    get_filename_component(_ext ${d} EXT)
-    if(_ext)
-      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d})
-    else()
-      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} lib${d}.so)
-    endif()
-  endforeach()
-
-  set(Int_LIB ${LIBRARY_NAME})
-  set(Int_OUTFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap)
-
-
-  add_custom_command(OUTPUT ${Int_OUTFILE}
-                     COMMAND ${RLIBMAP_EXECUTABLE} -o ${Int_OUTFILE} -l ${Int_LIB} 
-                             -d ${Int_DEPENDENCIES} -c ${Int_LINKDEF}
-                     DEPENDS ${Int_LINKDEF} ${RLIBMAP_EXECUTABLE} )
-  add_custom_target( lib${Int_LIB}.rootmap ALL DEPENDS  ${Int_OUTFILE})
-  set_target_properties(lib${Int_LIB}.rootmap PROPERTIES FOLDER RootMaps )
-  #---Install the rootmap file------------------------------------
-  install(FILES ${Int_OUTFILE} DESTINATION lib COMPONENT libraries)
+  if (DEFINED LINKDEF)
+    foreach(l ${LINKDEF})
+      If( IS_ABSOLUTE ${l})
+        Set(Int_LINKDEF ${Int_LINKDEF} ${l})
+      Else( IS_ABSOLUTE ${l})
+        #KG
+        #Set(Int_LINKDEF ${Int_LINKDEF} ${CMAKE_CURRENT_SOURCE_DIR}/${l})
+        Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${l})
+      EndIf( IS_ABSOLUTE ${l})
+    endforeach()
+
+    foreach(d ${DEPENDENCIES})
+      get_filename_component(_ext ${d} EXT)
+      If(NOT _ext MATCHES a$)
+        if(_ext)
+          set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d})
+        else()
+          set(Int_DEPENDENCIES ${Int_DEPENDENCIES} lib${d}.so)
+        endif()
+      Else()
+        Message("Found Static library with extension ${_ext}")
+      EndIf()
+    endforeach()
+
+    set(Int_LIB ${LIBRARY_NAME})
+    set(Int_OUTFILE ${LIBRARY_OUTPUT_PATH}/lib${Int_LIB}.rootmap)
+
+    add_custom_command(OUTPUT ${Int_OUTFILE}
+                       COMMAND ${RLIBMAP_EXECUTABLE} -o ${Int_OUTFILE} -l ${Int_LIB}
+                               -d ${Int_DEPENDENCIES} -c ${Int_LINKDEF}
+                       DEPENDS ${Int_LINKDEF} ${RLIBMAP_EXECUTABLE} )
+    add_custom_target( lib${Int_LIB}.rootmap ALL DEPENDS  ${Int_OUTFILE})
+    set_target_properties(lib${Int_LIB}.rootmap PROPERTIES FOLDER RootMaps )
+    #---Install the rootmap file------------------------------------
+    #install(FILES ${Int_OUTFILE} DESTINATION lib COMPONENT libraries)
+    install(FILES ${Int_OUTFILE} DESTINATION lib)
+  endif(DEFINED LINKDEF)
 EndMacro(ROOT_GENERATE_ROOTMAP)
 
 Macro(GENERATE_LIBRARY)
 
   set(Int_LIB ${LIBRARY_NAME})
 
-  Set(RuleName "${Int_LIB}_RULES")
   Set(HeaderRuleName "${Int_LIB}_HEADER_RULES")
   Set(DictName "G__${Int_LIB}Dict.cxx")
 
@@ -206,12 +274,6 @@ Macro(GENERATE_LIBRARY)
   Else( IS_ABSOLUTE ${DICTIONARY})
     Set(Int_DICTIONARY ${CMAKE_CURRENT_SOURCE_DIR}/${DICTIONARY})
   EndIf( IS_ABSOLUTE ${DICTIONARY})
-  
-  If( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${LINKDEF})
-  Else( IS_ABSOLUTE ${LINKDEF})
-    Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF})
-  EndIf( IS_ABSOLUTE ${LINKDEF})
 
   Set(Int_SRCS ${SRCS})
 
@@ -219,32 +281,89 @@ Macro(GENERATE_LIBRARY)
     Set(HDRS ${HEADERS})
   Else(HEADERS)
     CHANGE_FILE_EXTENSION(*.cxx *.h HDRS "${SRCS}")
-#  Message("HEADERS: ${HEADERS}")  
-#  Message("HDRS: ${HDRS}")  
-#  Message("HDRS: ${HDRS}")  
   EndIf(HEADERS)
 
-#  Message("RuleName: ${RuleName}")
-  If(RULE_CHECKER_FOUND)
-    CHECK_RULES("${Int_SRCS}" "${INCLUDE_DIRECTORIES}" ${RuleName})
-  EndIf(RULE_CHECKER_FOUND)
-
   If(IWYU_FOUND)
-    CHECK_HEADERS("${Int_SRCS}" "${INCLUDE_DIRECTORIES}" ${HeaderRuleName})
+    Set(_INCLUDE_DIRS ${INCLUDE_DIRECTORIES} ${SYSTEM_INCLUDE_DIRECTORIES})
+    CHECK_HEADERS("${Int_SRCS}" "${_INCLUDE_DIRS}" ${HeaderRuleName})
   EndIf(IWYU_FOUND)
 
-  ROOT_GENERATE_DICTIONARY()
-  SET(Int_SRCS ${Int_SRCS} ${DICTIONARY})
- 
-  ROOT_GENERATE_ROOTMAP()  
+  install(FILES ${HDRS} DESTINATION include)
+
+  If(LINKDEF)
+    If( IS_ABSOLUTE ${LINKDEF})
+      Set(Int_LINKDEF ${LINKDEF})
+    Else( IS_ABSOLUTE ${LINKDEF})
+      Set(Int_LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/${LINKDEF})
+    EndIf( IS_ABSOLUTE ${LINKDEF})
+    ROOT_GENERATE_DICTIONARY()
+    SET(Int_SRCS ${Int_SRCS} ${DICTIONARY})
+    SET_SOURCE_FILES_PROPERTIES(${DICTIONARY}
+       PROPERTIES COMPILE_FLAGS "-Wno-old-style-cast"
+    )
+  EndIf(LINKDEF)
+
+
+  If (ROOT_FOUND_VERSION LESS 59999)
+    ROOT_GENERATE_ROOTMAP()
+  EndIf()
+
+  set(Int_DEPENDENCIES)
+  foreach(d ${DEPENDENCIES})
+    get_filename_component(_ext ${d} EXT)
+    If(NOT _ext MATCHES a$)
+      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${d})
+    Else()      
+      Message("Found Static library with extension ${_ext}")
+      get_filename_component(_lib ${d} NAME_WE)
+      set(Int_DEPENDENCIES ${Int_DEPENDENCIES} ${_lib})
+    EndIf()
+  endforeach()
  
   ############### build the library #####################
-  Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS})
-  target_link_libraries(${Int_LIB} ${DEPENDENCIES})
+  If(${CMAKE_GENERATOR} MATCHES Xcode)
+    Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${HDRS} ${LINKDEF})
+  Else()
+    Add_Library(${Int_LIB} SHARED ${Int_SRCS} ${NO_DICT_SRCS} ${LINKDEF})
+  EndIf()
+  target_link_libraries(${Int_LIB} ${Int_DEPENDENCIES})
   set_target_properties(${Int_LIB} PROPERTIES ${FAIRROOT_LIBRARY_PROPERTIES})
 
   ############### install the library ###################
-  install(TARGETS ${Int_LIB} DESTINATION ${CMAKE_BINARY_DIR}/lib)
+  install(TARGETS ${Int_LIB} DESTINATION lib)
+
+  Set(LIBRARY_NAME)
+  Set(DICTIONARY)
+  Set(LINKDEF)
+  Set(SRCS)
+  Set(HEADERS)
+  Set(NO_DICT_SRCS)
+  Set(DEPENDENCIES)
 
 EndMacro(GENERATE_LIBRARY)
 
+
+Macro(GENERATE_EXECUTABLE)
+
+#  If(IWYU_FOUND)
+#    Set(HeaderRuleName "${EXE_NAME}_HEADER_RULES")
+#    CHECK_HEADERS("${SRCS}" "${INCLUDE_DIRECTORIES}" ${HeaderRuleName})
+#  EndIf(IWYU_FOUND)
+
+  ############### build the library #####################
+  Add_Executable(${EXE_NAME} ${SRCS})
+  target_link_libraries(${EXE_NAME} ${DEPENDENCIES})
+
+  ############### install the library ###################
+  if(DEFINED BIN_DESTINATION)
+    install(TARGETS ${EXE_NAME} DESTINATION ${BIN_DESTINATION})
+  else(DEFINED BIN_DESTINATION)
+    install(TARGETS ${EXE_NAME} DESTINATION bin)
+  endif(DEFINED BIN_DESTINATION)
+
+  Set(EXE_NAME)
+  Set(SRCS)
+  Set(DEPENDENCIES)
+
+EndMacro(GENERATE_EXECUTABLE)
+
diff --git a/cmake/modules/WriteConfigFile.cmake b/cmake/modules/WriteConfigFile.cmake
index 0327ebb..08ad2b5 100644
--- a/cmake/modules/WriteConfigFile.cmake
+++ b/cmake/modules/WriteConfigFile.cmake
@@ -1,35 +1,84 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 MACRO (WRITE_CONFIG_FILE filename)
 
+  String(REGEX REPLACE "^.*(install).*$" "\\1" INSTALL_VERSION ${filename})
+  String(COMPARE EQUAL "install" "${INSTALL_VERSION}" INSTALL_TRUE)
+
+  List(REMOVE_ITEM LD_LIBRARY_PATH ${CMAKE_BINARY_DIR}/lib)
+
+  If (INSTALL_TRUE)
+    SET(_INSTALLDIR ${CMAKE_INSTALL_PREFIX})  
+    SET(_BINDIR ${CMAKE_INSTALL_PREFIX}/bin)  
+#    SET(VMCWORKDIR ${CMAKE_INSTALL_PREFIX}/share/fairbase)  
+    SET(FAIRLIBDIR ${CMAKE_INSTALL_PREFIX}/lib)  
+    SET(_LD_LIBRARY_PATH ${FAIRLIBDIR} ${LD_LIBRARY_PATH}) 
+  Else (INSTALL_TRUE)
+    SET(_INSTALLDIR ${CMAKE_BINARY_DIR})  
+    SET(_BINDIR ${CMAKE_BINARY_DIR})  
+#    SET(VMCWORKDIR ${CMAKE_SOURCE_DIR})  
+    SET(FAIRLIBDIR ${CMAKE_BINARY_DIR}/lib)  
+    SET(_LD_LIBRARY_PATH ${FAIRLIBDIR} ${LD_LIBRARY_PATH}) 
+  EndIf (INSTALL_TRUE)
+
   If(NOT DEFINED FULL_CONFIG_FILE)
     Set(FULL_CONFIG_FILE "true")
   EndIf(NOT DEFINED FULL_CONFIG_FILE)
 
-  SET(FAIRLIBDIR ${CMAKE_CURRENT_BINARY_DIR}/lib)  
-  SET(LD_LIBRARY_PATH ${FAIRLIBDIR} ${LD_LIBRARY_PATH}) 
   
   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
-    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system.sh.in
-                   ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
-                  )
-    FILE(READ /etc/issue _linux_flavour)
-    STRING(REGEX REPLACE "[\\]" " " _result1 "${_linux_flavour}")
-    STRING(REGEX REPLACE "\n" ";" _result "${_result1}")
-    SET(_counter 0)
-    FOREACH(_line ${_result})
-      if (_counter EQUAL 0)
-        SET(_counter 1)
-        set(_linux_flavour ${_line})
-      endif (_counter EQUAL 0)
-    ENDFOREACH(_line ${_result})
+    IF(FAIRROOTPATH)
+      configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/check_system.sh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
+                    )
+      configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/check_system.csh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.csh
+                    )
+    ELSE(FAIRROOTPATH)
+      configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system.sh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
+                    )
+      configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system.csh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.csh
+                    )
+    ENDIF(FAIRROOTPATH)
+    
+    EXECUTE_PROCESS(COMMAND lsb_release -sd 
+                     OUTPUT_VARIABLE _linux_flavour
+                     OUTPUT_STRIP_TRAILING_WHITESPACE
+                    )
+
+    IF(_linux_flavour)
+      STRING(REGEX REPLACE "^\"" "" _linux_flavour ${_linux_flavour})
+      STRING(REGEX REPLACE "\"$" "" _linux_flavour ${_linux_flavour})
+    ENDIF(_linux_flavour)
+
     EXECUTE_PROCESS(COMMAND uname -m 
                     OUTPUT_VARIABLE _system 
                     OUTPUT_STRIP_TRAILING_WHITESPACE
                    )
    
   ElseIf(CMAKE_SYSTEM_NAME MATCHES Darwin)
-    configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system_mac.sh.in
-                   ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
-                  )
+    IF(FAIRROOTPATH)
+      configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/check_system_mac.sh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
+                    )
+      configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/check_system_mac.csh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.csh
+                    )
+    ELSE(FAIRROOTPATH)
+      configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system_mac.sh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.sh
+                    )
+      configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/check_system_mac.csh.in
+                     ${CMAKE_CURRENT_BINARY_DIR}/check_system.csh
+                    )
+    ENDIF(FAIRROOTPATH)
     EXECUTE_PROCESS(COMMAND uname -sr 
                     OUTPUT_VARIABLE _linux_flavour
                     OUTPUT_STRIP_TRAILING_WHITESPACE
@@ -119,12 +168,13 @@ MACRO (WRITE_CONFIG_FILE filename)
   CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_DIR})
   Set(ROOT_INCLUDE_DIR ${output} )
 
+  #KG
   Set(VMCWORKDIR ${CMAKE_SOURCE_DIR})
 
   Set(FAIRLIBDIR ${FAIRLIBDIR})
 
-  List(REMOVE_DUPLICATES LD_LIBRARY_PATH)
-  CONVERT_LIST_TO_STRING(${LD_LIBRARY_PATH})
+  List(REMOVE_DUPLICATES _LD_LIBRARY_PATH)
+  CONVERT_LIST_TO_STRING(${_LD_LIBRARY_PATH})
 
   IF(CMAKE_SYSTEM_NAME MATCHES Linux)
     Set(MY_LD_LIBRARY_PATH ${output})
@@ -136,6 +186,11 @@ MACRO (WRITE_CONFIG_FILE filename)
 
   Set(USE_VGM 1)
 
+  SET(PYTHONPATH ${CMAKE_SOURCE_DIR}/python ${SIMPATH}/lib ${SIMPATH}/lib/root ${SIMPATH}/lib/Geant4 ${SIMPATH}/lib/g4py ${PYTHONPATH})
+  UNIQUE(PYTHONPATH "${PYTHONPATH}")
+  CONVERT_LIST_TO_STRING(${PYTHONPATH})
+  SET(MY_PYTHONPATH ${output})
+
   SET (PATH ${ROOTSYS}/bin ${PATH})
   UNIQUE(PATH "${PATH}")
   CONVERT_LIST_TO_STRING(${PATH})
@@ -149,16 +204,34 @@ MACRO (WRITE_CONFIG_FILE filename)
 
   CONVERT_LIST_TO_STRING($ENV{NEW_CLASSPATH})
   Set(MY_CLASSPATH ${output})
-  
-  IF(${filename} MATCHES "[.]csh")
+
+  CONVERT_LIST_TO_STRING(${ROOT_INCLUDE_PATH})
+  Set(ROOT_INCLUDE_PATH ${output})
+
+  IF(${filename} MATCHES "[.]csh.*$")
+    IF(FAIRROOTPATH)
+    configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/config.csh.in
+	           ${CMAKE_CURRENT_BINARY_DIR}/${filename}
+                  )
+    ELSE(FAIRROOTPATH)    
     configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/config.csh.in
 	           ${CMAKE_CURRENT_BINARY_DIR}/${filename}
                   )
-  ELSE(${filename} MATCHES "[.]csh")
+    ENDIF(FAIRROOTPATH)
+
+
+  ELSE(${filename} MATCHES "[.]csh.*$")
+    IF(FAIRROOTPATH)
+    configure_file(${FAIRROOTPATH}/share/fairbase/cmake/scripts/config.sh.in
+	           ${CMAKE_CURRENT_BINARY_DIR}/${filename}
+                  )
+    ELSE(FAIRROOTPATH) 
     configure_file(${PROJECT_SOURCE_DIR}/cmake/scripts/config.sh.in
 	           ${CMAKE_CURRENT_BINARY_DIR}/${filename}
                   )
-  ENDIF(${filename} MATCHES "[.]csh")
+    ENDIF(FAIRROOTPATH)
+
+  ENDIF(${filename} MATCHES "[.]csh.*$")
 
 
 ENDMACRO (WRITE_CONFIG_FILE)
@@ -180,4 +253,4 @@ MACRO (CONVERT_LIST_TO_STRING)
     Set(output "")
   EndIf(tmp)
 
-ENDMACRO (CONVERT_LIST_TO_STRING LIST)
\ No newline at end of file
+ENDMACRO (CONVERT_LIST_TO_STRING LIST)
diff --git a/cmake/modules/FindCLHEP.cmake b/cmake/modules_old/FindCLHEP.cmake
similarity index 87%
rename from cmake/modules/FindCLHEP.cmake
rename to cmake/modules_old/FindCLHEP.cmake
index f425376..c88cfc7 100644
--- a/cmake/modules/FindCLHEP.cmake
+++ b/cmake/modules_old/FindCLHEP.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find CLHEP
 # Once done this will define
 #
diff --git a/cmake/modules/FindGEANT3.cmake b/cmake/modules_old/FindGEANT3.cmake
similarity index 82%
rename from cmake/modules/FindGEANT3.cmake
rename to cmake/modules_old/FindGEANT3.cmake
index ab250da..9a39f69 100644
--- a/cmake/modules/FindGEANT3.cmake
+++ b/cmake/modules_old/FindGEANT3.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find GEANT3
 # Once done this will define
 #
@@ -36,7 +43,7 @@ SET(CMAKE_REQUIRED_LIBRARIES
     Physics 
     Gui 
     EG 
-    ${GENERATORS_LIBRARY_DIR}/libPythia6.so 
+    ${Pythia6_LIBRARY_DIR}/libPythia6.so 
     EGPythia6 
     VMC 
     Geom 
@@ -74,18 +81,21 @@ endif (GEANT3_INCLUDE_DIR AND GEANT3_LIBRARIES)
 MESSAGE(STATUS "Looking for GEANT3...")
 
 FIND_PATH(GEANT3_SYSTEM_DIR NAMES data PATHS
+  ${GEANT3_PATH}/share/geant3
   ${SIMPATH}/share/geant3
   ${SIMPATH}/transport/geant3
   NO_DEFAULT_PATH
 )
 
 FIND_PATH(GEANT3_INCLUDE_DIR NAMES TGeant3.h PATHS
+  ${GEANT3_PATH}/include/TGeant3
   ${SIMPATH}/include/TGeant3
   ${SIMPATH}/transport/geant3/TGeant3
   NO_DEFAULT_PATH
 )
 
 FIND_PATH(GEANT3_LIBRARY_DIR NAMES libgeant321.so PATHS
+  ${GEANT3_PATH}/lib
   ${SIMPATH}/lib
   ${SIMPATH}/transport/geant3/lib/tgt_linux
   ${SIMPATH}/transport/geant3/lib/tgt_linuxicc
@@ -95,6 +105,7 @@ FIND_PATH(GEANT3_LIBRARY_DIR NAMES libgeant321.so PATHS
 )
 
 FIND_LIBRARY(GEANT3_LIB NAMES geant321 PATHS
+  ${GEANT3_PATH}/lib
   ${SIMPATH}/lib
   ${SIMPATH}/transport/geant3/lib/tgt_linux
   ${SIMPATH}/transport/geant3/lib/tgt_linuxicc
diff --git a/cmake/modules/FindGEANT4.cmake b/cmake/modules_old/FindGEANT4.cmake
similarity index 78%
rename from cmake/modules/FindGEANT4.cmake
rename to cmake/modules_old/FindGEANT4.cmake
index e4147ea..ebc404d 100644
--- a/cmake/modules/FindGEANT4.cmake
+++ b/cmake/modules_old/FindGEANT4.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find GEANT4
 # Once done this will define
 #
diff --git a/cmake/modules_old/FindGEANT4DATA.cmake b/cmake/modules_old/FindGEANT4DATA.cmake
new file mode 100644
index 0000000..8bcfb03
--- /dev/null
+++ b/cmake/modules_old/FindGEANT4DATA.cmake
@@ -0,0 +1,169 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+# - Try to find GEANT4 data files
+#
+
+
+MESSAGE(STATUS "Looking for GEANT4 DATA files...")
+
+FIND_PATH(GEANT4_DATA NAMES $ENV{G4PIIDATA} G4PII G4PII1.3 PATHS
+  ${SIMPATH}/share/Geant4/data
+  $ENV{G4INSTALL_DATA}
+  ${GEANT4_SHARE_DIR}/$ENV{GEANT4VERSION}/data
+  NO_DEFAULT_PATH
+)
+
+#If(DEFINED ENV{G4LEDATA})
+#  Set(G4LEDATA $ENV{G4LEDATA})
+#Else()
+  FIND_PATH(G4LEDATA NAMES README PATHS
+    $ENV{G4LEDATA}
+    ${GEANT4_DATA}/G4EMLOW
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4LEDATA)
+  Message(STATUS "Found G4EMLOW data")
+Else (G4LEDATA)
+  Message(STATUS "NOT Found G4EMLOW data")
+EndIf (G4LEDATA)
+
+#If(DEFINED ENV{G4LEVELGAMMADATA})
+#  Set(G4LEVELGAMMADATA $ENV{G4LEVELGAMMADATA})
+#Else()
+  FIND_PATH(G4LEVELGAMMADATA  NAMES README-LevelGammaData PATHS
+    $ENV{G4LEVELGAMMADATA}
+    ${GEANT4_DATA}/PhotonEvaporation/
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4LEVELGAMMADATA)
+  Message(STATUS "Found PhotonEvaporation data")
+Else (G4LEVELGAMMADATA)
+  Message(STATUS "NOT Found PhotonEvaporation data")
+EndIf (G4LEVELGAMMADATA)
+
+
+#If(DEFINED ENV{G4NEUTRONHPDATA})
+#  Set(G4NEUTRONHPDATA $ENV{G4NEUTRONHPDATA})
+#Else()
+  FIND_PATH(G4NEUTRONHPDATA NAMES README  PATHS
+    $ENV{G4NEUTRONHPDATA}
+    ${GEANT4_DATA}/G4NDL
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4NEUTRONHPDATA)
+  Message(STATUS "Found G4NDL data")
+  SET(G4NeutronHPCrossSections ${G4NEUTRONHPDATA})
+Else ()
+  Message(STATUS "NOT Found G4NDL data")
+EndIf ()
+
+#If(DEFINED ENV{G4NEUTRONXSDATA})
+#  Set(G4NEUTRONXSDATA $ENV{G4NEUTRONXSDATA})
+#Else()
+  FIND_PATH(G4NEUTRONXSDATA NAMES cap1  PATHS
+    $ENV{G4NEUTRONXSDATA}
+    ${GEANT4_DATA}/G4NEUTRONXS
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4NEUTRONXSDATA)
+  Message(STATUS "Found G4NEUTRONXS data")
+Else (G4NEUTRONXSDATA)
+  Message(STATUS "NOT Found G4NEUTRONXS data")
+EndIf (G4NEUTRONXSDATA)
+
+Message("G4PIIDATA: $ENV{G4PIIDATA}")
+#If(DEFINED ENV{G4PIIDATA})
+#  Set(G4PIIDATA $ENV{G4PIIDATA})
+#Else()
+  FIND_PATH(G4PIIDATA NAMES PIXE_DataLibrary.pdf documentation.pdf PATHS
+    $ENV{G4PIIDATA}
+    ${GEANT4_DATA}/G4PII
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+
+If (G4PIIDATA)
+  Message(STATUS "Found G4PII data")
+Else (G4PIIDATA)
+  Message(STATUS "NOT Found G4PII data")
+EndIf (G4PIIDATA)
+
+
+#If(DEFINED ENV{G4RADIOACTIVEDATA})
+#  Set(G4RADIOACTIVEDATA $ENV{G4RADIOACTIVEDATA})
+#Else()
+  FIND_PATH(G4RADIOACTIVEDATA NAMES README_RDM PATHS
+    $ENV{G4RADIOACTIVEDATA}
+    ${GEANT4_DATA}/RadioactiveDecay
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4RADIOACTIVEDATA)
+  Message(STATUS "Found RadioactiveDecay data")
+Else (G4RADIOACTIVEDATA)
+  Message(STATUS "NOT Found RadioactiveDecay data")
+EndIf (G4RADIOACTIVEDATA)
+
+
+#If(DEFINED ENV{G4REALSURFACEDATA})
+#  Set(G4REALSURFACEDATA $ENV{G4REALSURFACEDATA})
+#Else()
+  FIND_PATH(G4REALSURFACEDATA NAMES EtchedTiO.dat PATHS
+    $ENV{G4REALSURFACEDATA}
+    ${GEANT4_DATA}/RealSurface
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4REALSURFACEDATA)
+  Message(STATUS "Found RealSurface data")
+Else (G4REALSURFACEDATA)
+  Message(STATUS "NOT Found RealSurface data")
+EndIf (G4REALSURFACEDATA)
+
+#If(DEFINED ENV{G4SAIDXSDATA})
+#  Set(G4SAIDXSDATA $ENV{G4SAIDXSDATA})
+#Else()
+  FIND_PATH(G4SAIDXSDATA NAMES README_Eta PATHS
+    $ENV{G4SAIDXSDATA}
+    ${GEANT4_DATA}/G4SAIDDATA
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4SAIDXSDATA)
+  Message(STATUS "Found G4SAID data")
+Else (G4SAIDXSDATA)
+  Message(STATUS "NOT Found G4SAID data")
+EndIf (G4SAIDXSDATA)
+
+#If(DEFINED ENV{G4ENSDFSTATEDATA})
+#  Set(G4ENSDFSTATEDATA $ENV{G4ENSDFSTATEDATA})
+#Else()
+  FIND_PATH(G4ENSDFSTATEDATA NAMES ENSDFSTATE.dat PATHS
+    $ENV{G4ENSDFSTATEDATA}
+    ${GEANT4_DATA}/G4ENSDFSTATE
+    NO_DEFAULT_PATH
+  )
+#EndIf()
+
+If (G4ENSDFSTATEDATA)
+  Message(STATUS "Found G4ENSDFSTATE data")
+Else (G4ENSDFSTATEDATA)
+  Message(STATUS "NOT Found G4ENSDFSTATE data")
+EndIf (G4ENSDFSTATEDATA)
diff --git a/cmake/modules/FindGEANT4VMC.cmake b/cmake/modules_old/FindGEANT4VMC.cmake
similarity index 87%
rename from cmake/modules/FindGEANT4VMC.cmake
rename to cmake/modules_old/FindGEANT4VMC.cmake
index 2eaa911..5bc3f0b 100644
--- a/cmake/modules/FindGEANT4VMC.cmake
+++ b/cmake/modules_old/FindGEANT4VMC.cmake
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # - Try to find GEANT4VMC
 # Once done this will define
 #
diff --git a/cmake/modules/FindGENERATORS.cmake b/cmake/modules_old/FindGENERATORS.cmake
similarity index 100%
rename from cmake/modules/FindGENERATORS.cmake
rename to cmake/modules_old/FindGENERATORS.cmake
diff --git a/cmake/modules/FindRuleChecker.cmake b/cmake/modules_old/FindRuleChecker.cmake
similarity index 100%
rename from cmake/modules/FindRuleChecker.cmake
rename to cmake/modules_old/FindRuleChecker.cmake
diff --git a/cmake/scripts/CMakeLists.txt_roc b/cmake/scripts/CMakeLists.txt_roc
index 244bb76..65a32f5 100644
--- a/cmake/scripts/CMakeLists.txt_roc
+++ b/cmake/scripts/CMakeLists.txt_roc
@@ -1,20 +1,39 @@
 # copy files from source directory to build directory
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc
-                   COMMAND cmake -E copy_directory  ${CMAKE_CURRENT_SOURCE_DIR}                            ${CMAKE_CURRENT_BINARY_DIR}/roc
+                   COMMAND cmake -E copy_directory  ${CMAKE_CURRENT_SOURCE_DIR}                            
+                           ${CMAKE_CURRENT_BINARY_DIR}/roc
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                    )
 
+If(CMAKE_SYSTEM_NAME MATCHES Darwin)
+  # Unpack the dabc tarball and patch the needed files
+  Add_Custom_Command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/dabc/Makefile
+                   COMMAND tar -xzvf dabcroc11.tar.gz
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc/dabc
+                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/
+                   )
+  Add_Custom_Command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/patch_okay
+                   COMMAND patch -p0 < roclib_macos.patch
+                   COMMAND touch patch_okay
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
+                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/dabc/Makefile
+                   )
+Else(CMAKE_SYSTEM_NAME MATCHES Darwin)
+  Add_Custom_Command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/patch_okay
+                   COMMAND touch patch_okay
+                   WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
+                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc
+                   )
+EndIf(CMAKE_SYSTEM_NAME MATCHES Darwin)
 
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRoc.so
-                   #COMMAND make > /dev/null 2>& 1
                    COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}
                            ROOTSYS=${ROOTSYS} make roclib 
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
-                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc
+                   DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/patch_okay
                   )
 
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcBase.so
-                   #COMMAND make > /dev/null 2>& 1
                    COMMAND make dabccore 
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
                    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRoc.so
@@ -22,7 +41,7 @@ add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcBase.so
 
 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcRoc.so
                           ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcMbs.so
-                   #COMMAND make > /dev/null 2>& 1
+                          ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRocDict.rootmap
                    COMMAND LD_LIBRARY_PATH=${ROOT_LIBRARY_DIR}
                            ROOTSYS=${ROOTSYS} make rocdict
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
@@ -33,15 +52,19 @@ add_custom_command(OUTPUT
                           ${LIBRARY_OUTPUT_PATH}/libDabcRoc.so
                           ${LIBRARY_OUTPUT_PATH}/libDabcBase.so
                           ${LIBRARY_OUTPUT_PATH}/libRoc.so
+                          ${LIBRARY_OUTPUT_PATH}/libDabcMbs.so
+                          ${LIBRARY_OUTPUT_PATH}/libRocDict.rootmap
                    COMMAND cmake -E copy_if_different lib/libDabcRoc.so ${LIBRARY_OUTPUT_PATH}
                    COMMAND cmake -E copy_if_different lib/libRoc.so ${LIBRARY_OUTPUT_PATH}
                    COMMAND cmake -E copy_if_different lib/libDabcBase.so ${LIBRARY_OUTPUT_PATH}
                    COMMAND cmake -E copy_if_different lib/libDabcMbs.so ${LIBRARY_OUTPUT_PATH}
+                   COMMAND cmake -E copy_if_different lib/libRocDict.rootmap ${LIBRARY_OUTPUT_PATH}
                    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/roc
                    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRoc.so 
                            ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcBase.so 
                            ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcMbs.so 
                            ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libDabcRoc.so 
+                           ${CMAKE_CURRENT_BINARY_DIR}/roc/lib/libRocDict.rootmap 
                   )
 
 # create a target which will always be build and does actually nothing. The target is only
@@ -53,6 +76,7 @@ add_custom_target(RocLib
                   DEPENDS ${LIBRARY_OUTPUT_PATH}/libDabcBase.so
                   DEPENDS ${LIBRARY_OUTPUT_PATH}/libDabcMbs.so
                   DEPENDS ${LIBRARY_OUTPUT_PATH}/libRoc.so
+                  DEPENDS ${LIBRARY_OUTPUT_PATH}/libRocDict.rootmap
                  )
 
 # import libDabcRoc.so which is not in the scope of CMake. This step makes it possible that
diff --git a/cmake/scripts/FairVersion.h.default b/cmake/scripts/FairVersion.h.default
index ec2b3a5..1ce18f0 100644
--- a/cmake/scripts/FairVersion.h.default
+++ b/cmake/scripts/FairVersion.h.default
@@ -1,7 +1,5 @@
 #ifndef FAIRROOT_VERSION
-#define FAIRROOT_VERSION 0.0.99
-#define FAIRROOT_SVN_REVISION 0
-#define FAIRROOT_SVN_BRANCH "Default"
-#define FAIRROOT_SVN_DATE "1.1.2000"
+#define FAIRROOT_VERSION 0.0.9
+#define FAIRROOT_GIT_DATE "Sun Jan 1 00:00:00 0"
 #endif
 
diff --git a/cmake/scripts/FairVersion.h.tmp b/cmake/scripts/FairVersion.h.tmp
index 46fbbce..27ef81a 100644
--- a/cmake/scripts/FairVersion.h.tmp
+++ b/cmake/scripts/FairVersion.h.tmp
@@ -1,7 +1,5 @@
 #ifndef FAIRROOT_VERSION
-#define FAIRROOT_VERSION @FAIRROOT_SVN_VERSION@
-#define FAIRROOT_SVN_REVISION @FAIRROOT_SVN_REVISION@
-#define FAIRROOT_SVN_BRANCH "@FAIRROOT_SVN_BRANCH@"
-#define FAIRROOT_SVN_DATE "@FAIRROOT_SVN_DATE@"
+#define FAIRROOT_VERSION @FAIRROOT_GIT_VERSION@
+#define FAIRROOT_GIT_DATE "@FAIRROOT_GIT_DATE@"
 #endif
 
diff --git a/cmake/scripts/check_system.csh.in b/cmake/scripts/check_system.csh.in
new file mode 100644
index 0000000..ef3d117
--- /dev/null
+++ b/cmake/scripts/check_system.csh.in
@@ -0,0 +1,28 @@
+#!/bin/csh
+set linux_flavour=`lsb_release -sd | sed -e 's/^"//' -e 's/"$//'`
+set system=`uname -m`
+setenv same_system 1
+
+echo "System during compilation: $Linux_Flavour_"
+echo "                           $System_"
+echo "System now               : $linux_flavour"
+echo "                           $system"
+
+if ( "$linux_flavour" != "$Linux_Flavour_" ) then
+  echo "You try to run the software on a different"
+  echo "linux flavour than it was compiled on."
+  echo "This is normaly a serious error, so we stop"
+  echo "the execution at this point."
+  echo "If you know what you do you can change the"
+  echo "config.csh script to bypass this security issue."
+  setenv same_system 0
+endif
+if ( "$system" != "$System_" ) then
+  echo "You try to run the software on a different"
+  echo "linux architecture than it was compiled on."
+  echo "This is normaly a serious error, so we stop"
+  echo "the execution at this point."
+  echo "If you know what you do you can change the"
+  echo "config.csh script to bypass this security issue."
+  setenv same_system 0
+endif
diff --git a/cmake/scripts/check_system.sh.in b/cmake/scripts/check_system.sh.in
index 4ecac7f..f931bf7 100644
--- a/cmake/scripts/check_system.sh.in
+++ b/cmake/scripts/check_system.sh.in
@@ -1,6 +1,5 @@
 #!/bin/bash
-#linux_flavour=$(head -n 1 /etc/issue|tr '\\' ' '|awk '{gsub("\"","",$0);print $0}')
-linux_flavour=$(sed '/^$/d' /etc/issue | head -n 1 | tr  '\\' ' '|awk '{gsub("\"","",$0);print $0}')
+linux_flavour=$(lsb_release -sd | sed -e 's/^"//' -e 's/"$//')
 system=$(uname -m)
 same_system=1
 
@@ -11,7 +10,7 @@ echo "                           $system"
 
 if [ ! "$linux_flavour" = "$Linux_Flavour_" ]; then
   echo "You try to run the software on a different"
-  echo "linux flavour than it was compuiled on."
+  echo "linux flavour than it was compiled on."
   echo "This is normaly a serious error, so we stop"
   echo "the execution at this point."
   echo "If you know what you do you can change the"
@@ -20,7 +19,7 @@ if [ ! "$linux_flavour" = "$Linux_Flavour_" ]; then
 fi
 if [ ! "$system" = "$System_" ]; then
   echo "You try to run the software on a different"
-  echo "linux flavour than it was compuiled on."
+  echo "linux architecture than it was compiled on."
   echo "This is normaly a serious error, so we stop"
   echo "the execution at this point."
   echo "If you know what you do you can change the"
diff --git a/cmake/scripts/check_system_mac.csh.in b/cmake/scripts/check_system_mac.csh.in
new file mode 100644
index 0000000..82e5852
--- /dev/null
+++ b/cmake/scripts/check_system_mac.csh.in
@@ -0,0 +1,29 @@
+#!/bin/csh
+set linux_flavour=`uname -sr`
+set system=`uname -m`
+setenv same_system 1
+
+echo "System during compilation: $Linux_Flavour_"
+echo "                           $System_"
+echo "System now               : $linux_flavour"
+echo "                           $system"
+
+if ( "$linux_flavour" != "$Linux_Flavour_" ) then
+  echo "You try to run the software on a different"
+  echo "OSX flavour than it was compiled on."
+  echo "This is normaly a serious error, so we stop"
+  echo "the execution at this point."
+  echo "If you know what you do you can change the"
+  echo "config.csh script to bypass this security issue."
+  setenv same_system 0
+endif
+if ( "$system" != "$System_" ) then
+  echo "You try to run the software on a different"
+  echo "OSX architecture than it was compiled on."
+  echo "This is normaly a serious error, so we stop"
+  echo "the execution at this point."
+  echo "If you know what you do you can change the"
+  echo "config.csh script to bypass this security issue."
+  setenv same_system 0
+endif
+
diff --git a/cmake/scripts/check_system_mac.sh.in b/cmake/scripts/check_system_mac.sh.in
index 9f3227b..f7957fd 100644
--- a/cmake/scripts/check_system_mac.sh.in
+++ b/cmake/scripts/check_system_mac.sh.in
@@ -10,7 +10,7 @@ echo "                           $system"
 
 if [ ! "$linux_flavour" = "$Linux_Flavour_" ]; then
   echo "You try to run the software on a different"
-  echo "linux flavour than it was compuiled on."
+  echo "OSX flavour than it was compiled on."
   echo "This is normaly a serious error, so we stop"
   echo "the execution at this point."
   echo "If you know what you do you can change the"
@@ -19,7 +19,7 @@ if [ ! "$linux_flavour" = "$Linux_Flavour_" ]; then
 fi
 if [ ! "$system" = "$System_" ]; then
   echo "You try to run the software on a different"
-  echo "linux flavour than it was compuiled on."
+  echo "OSX architecture than it was compiled on."
   echo "This is normaly a serious error, so we stop"
   echo "the execution at this point."
   echo "If you know what you do you can change the"
diff --git a/cmake/scripts/config.csh.in b/cmake/scripts/config.csh.in
index ce9b016..3f3329a 100644
--- a/cmake/scripts/config.csh.in
+++ b/cmake/scripts/config.csh.in
@@ -1,45 +1,51 @@
+#!/bin/csh
+
 setenv Linux_Flavour_ "@_linux_flavour@"
 setenv System_ "@_system@"
-source @CMAKE_BINARY_DIR@/check_system.sh                               
-if [ "$same_system" == "1" ]; then 
+. @_BINDIR@/check_system.csh
+if ( "$same_system" == "1" ) then 
   setenv SIMPATH "@SIMPATH@"
   setenv ROOTSYS "@ROOTSYS@"
-  setenv GEANT4_LIBRARY_DIR "@GEANT4_LIBRARY_DIR@"
-  setenv GEANT4_INCLUDE_DIR "@GEANT4_INCLUDE_DIR@"
-  setenv GEANT4VMC_INCLUDE_DIR "@GEANT4VMC_INCLUDE_DIR@"
-  setenv GEANT4VMC_LIBRARY_DIR "@GEANT4VMC_LIBRARY_DIR@"
-  setenv GEANT4VMC_MACRO_DIR "@GEANT4VMC_MACRO_DIR@"
-  setenv G4LEDATA "@G4LEDATA@"
-  setenv G4LEVELGAMMADATA "@G4LEVELGAMMADATA@"
-  setenv G4NeutronHPCrossSections "@G4NeutronHPCrossSections@"
-  setenv G4NEUTRONHPDATA "@G4NeutronHPCrossSections@"
-  setenv G4NEUTRONXSDATA "@G4NEUTRONXSDATA@"
-  setenv G4PIIDATA "@G4PIIDATA@"
-  setenv G4RADIOACTIVEDATA "@G4RADIOACTIVEDATA@"
-  setenv G4REALSURFACEDATA "@G4REALSURFACEDATA@"
-  setenv G4SAIDXSDATA "@G4SAIDXSDATA@"
-  setenv CLHEP_INCLUDE_DIR "@CLHEP_INCLUDE_DIR@"
-  setenv CLHEP_LIBRARY_DIR "@CLHEP_LIBRARY_DIR@"
-  setenv CLHEP_BASE_DIR "@CLHEP_BASE_DIR@"
-  setenv PLUTO_LIBRARY_DIR "@PLUTO_LIBRARY_DIR@"
-  setenv PLUTO_INCLUDE_DIR "@PLUTO_INCLUDE_DIR@"
-  setenv PYTHIA6_LIBRARY_DIR "@PYTHIA6_LIBRARY_DIR@"
-  setenv G3SYS "@G3SYS@"
-  setenv GEANT3_INCLUDE_DIR "@GEANT3_INCLUDE_DIR@"
-  setenv GEANT3_LIBRARY_DIR "@GEANT3_LIBRARY_DIR@"
-  setenv GEANT3_LIBRARIES "@GEANT3_LIBRARIES@"
+  setenv FAIRROOTPATH "@FAIRROOTPATH@"
+  if ( @FULL_CONFIG_FILE@ == true ) then
+    setenv GEANT4_LIBRARY_DIR "@GEANT4_LIBRARY_DIR@"
+    setenv GEANT4_INCLUDE_DIR "@GEANT4_INCLUDE_DIR@"
+    setenv GEANT4VMC_INCLUDE_DIR "@GEANT4VMC_INCLUDE_DIR@"
+    setenv GEANT4VMC_LIBRARY_DIR "@GEANT4VMC_LIBRARY_DIR@"
+    setenv GEANT4VMC_MACRO_DIR "@GEANT4VMC_MACRO_DIR@"
+    setenv CLHEP_INCLUDE_DIR "@CLHEP_INCLUDE_DIR@"
+    setenv CLHEP_LIBRARY_DIR "@CLHEP_LIBRARY_DIR@"
+    setenv CLHEP_BASE_DIR "@CLHEP_BASE_DIR@"
+    setenv PLUTO_LIBRARY_DIR "@PLUTO_LIBRARY_DIR@"
+    setenv PLUTO_INCLUDE_DIR "@PLUTO_INCLUDE_DIR@"
+    setenv PYTHIA6_LIBRARY_DIR "@PYTHIA6_LIBRARY_DIR@"
+    setenv G3SYS "@G3SYS@"
+    setenv GEANT3_INCLUDE_DIR "@GEANT3_INCLUDE_DIR@"
+    setenv GEANT3_LIBRARY_DIR "@GEANT3_LIBRARY_DIR@"
+    setenv GEANT3_LIBRARIES "@GEANT3_LIBRARIES@"
+    setenv USE_VGM "1"
+    setenv PYTHIA8DATA "@PYTHIA8DATA@"
+    setenv CLASSPATH "@MY_CLASSPATH@"
+
+    setenv G4LEDATA "@G4LEDATA@"
+    setenv G4LEVELGAMMADATA "@G4LEVELGAMMADATA@"
+    setenv G4NeutronHPCrossSections "@G4NeutronHPCrossSections@"
+    setenv G4NEUTRONHPDATA "@G4NeutronHPCrossSections@"
+    setenv G4NEUTRONXSDATA "@G4NEUTRONXSDATA@"
+    setenv G4PIIDATA "@G4PIIDATA@"
+    setenv G4RADIOACTIVEDATA "@G4RADIOACTIVEDATA@"
+    setenv G4REALSURFACEDATA "@G4REALSURFACEDATA@"
+    setenv G4SAIDXSDATA "@G4SAIDXSDATA@"
+    setenv G4ENSDFSTATEDATA "@G4ENSDFSTATEDATA@"
+  endif
   setenv ROOT_LIBRARY_DIR "@ROOT_LIBRARY_DIR@"
   setenv ROOT_LIBRARIES "@ROOT_LIBRARIES@"
   setenv ROOT_INCLUDE_DIR "@ROOT_INCLUDE_DIR@"
-  setenv VMCWORKDIR "@CMAKE_SOURCE_DIR@"
+  setenv ROOT_INCLUDE_PATH "@ROOT_INCLUDE_PATH@"
+  setenv VMCWORKDIR "@VMCWORKDIR@"
   setenv FAIRLIBDIR "@FAIRLIBDIR@"
+  setenv PYTHONPATH "@MY_PYTHONPATH@"
   setenv DYLD_LIBRARY_PATH "@MY_DYLD_LIBRARY_PATH@"
   setenv LD_LIBRARY_PATH "@MY_LD_LIBRARY_PATH@"
-  setenv USE_VGM "1"
   setenv PATH "@MY_PATH@"
-  setenv PYTHIA8DATA "@PYTHIA8DATA@"
-  setenv CLASSPATH "@MY_CLASSPATH@"
-
-
-
-fi
\ No newline at end of file
+endif
diff --git a/cmake/scripts/config.sh.in b/cmake/scripts/config.sh.in
index 7ce7807..e3319b7 100644
--- a/cmake/scripts/config.sh.in
+++ b/cmake/scripts/config.sh.in
@@ -1,9 +1,12 @@
+#!/bin/bash
+
 export Linux_Flavour_="@_linux_flavour@"
 export System_="@_system@"
-source @CMAKE_BINARY_DIR@/check_system.sh                               
-if [ "$same_system" == "1" ]; then 
+. @_BINDIR@/check_system.sh
+if [ $same_system -eq 1 ]; then
   export SIMPATH="@SIMPATH@"
   export ROOTSYS="@ROOTSYS@"
+  export FAIRROOTPATH="@FAIRROOTPATH@"
   if (@FULL_CONFIG_FILE@); then
     export GEANT4_LIBRARY_DIR="@GEANT4_LIBRARY_DIR@"
     export GEANT4_INCLUDE_DIR="@GEANT4_INCLUDE_DIR@"
@@ -33,12 +36,15 @@ if [ "$same_system" == "1" ]; then
     export G4RADIOACTIVEDATA="@G4RADIOACTIVEDATA@"
     export G4REALSURFACEDATA="@G4REALSURFACEDATA@"
     export G4SAIDXSDATA="@G4SAIDXSDATA@"
+    export G4ENSDFSTATEDATA="@G4ENSDFSTATEDATA@"
   fi
   export ROOT_LIBRARY_DIR="@ROOT_LIBRARY_DIR@"
   export ROOT_LIBRARIES="@ROOT_LIBRARIES@"
   export ROOT_INCLUDE_DIR="@ROOT_INCLUDE_DIR@"
-  export VMCWORKDIR="@CMAKE_SOURCE_DIR@"
+  export ROOT_INCLUDE_PATH="@ROOT_INCLUDE_PATH@"
+  export VMCWORKDIR="@VMCWORKDIR@"
   export FAIRLIBDIR="@FAIRLIBDIR@"
+  export PYTHONPATH="@MY_PYTHONPATH@"
   export DYLD_LIBRARY_PATH="@MY_DYLD_LIBRARY_PATH@"
   export LD_LIBRARY_PATH="@MY_LD_LIBRARY_PATH@"
   export PATH="@MY_PATH@"
diff --git a/cmake/scripts/fairroot-config.in b/cmake/scripts/fairroot-config.in
new file mode 100644
index 0000000..5f90fb8
--- /dev/null
+++ b/cmake/scripts/fairroot-config.in
@@ -0,0 +1,84 @@
+#!/bin/bash
+
+_version=@FAIRROOT_GIT_VERSION@
+_major_version=${_version:2:2}
+_minor_version=${_version:5:2}
+_patch=${_version:7}
+length=${#_patch}
+if [ $length -eq 0 ]; then
+  _patch_version=0
+elif [ $length -eq 1 ]; then
+  _patch_version=$(printf '%d\n' "'$_patch")
+  _patch_version=$((${_patch_version}-96)) # a should be 1 but a in ascii is 97
+else
+  _patch_version=${_patch}
+fi
+
+_cc=@CMAKE_C_COMPILER@
+_cxx=@CMAKE_CXX_COMPILER@
+_fairsoft_path=@SIMPATH@
+
+usage="\
+Usage: fairroot-config [--version] [--major_version] [--minor_version] [--patch_version] \
+[--cc] [--cxx] [--fairsoft_path] [--help]"
+
+if [ $# -eq 0 -o $# -gt 1 ]; then
+   echo "${usage}" 1>&2
+   exit 1
+fi
+
+out=""
+
+
+case $1 in
+    --version)
+      ### Output the fairroot version
+      out="$out ${_version}"
+      ;;
+    --major_version)
+      ### Output the fairroot version
+      out="$out ${_major_version}"
+      ;;
+    --minor_version)
+      ### Output the fairroot version
+      out="$out ${_minor_version}"
+      ;;
+    --patch_version)
+      ### Output the fairroot version
+      out="$out ${_patch_version}"
+      ;;
+    --cc)
+      ### Output the full path of used c compiler
+      out="$out ${_cc}"
+      ;;
+    --cxx)
+      ### Output the full path of used cxx compiler
+      out="$out ${_cxx}"
+      ;;
+    --fairsoft_path)
+      ### Output the full path to the used fairsoft installation
+      out="$out ${_fairsoft_path}"
+      ;;
+    --help)
+      ### Print a help message
+      echo "Usage: `basename $0` [options]"
+      echo ""
+      echo "  --version            Print the fairroot version"
+      echo "  --major_version      Print the fairroot major version"
+      echo "  --minor_version      Print the fairroot minor version"
+      echo "  --patch_version      Print the fairroot patch version"
+      echo "  --cc                 Print the full path of the used c compiler"
+      echo "  --cxx                Print the full path of the used cxx compiler"
+      echo "  --fairsoft_path      Print the full path of the used fairsoft version"
+      exit 0
+      ;;
+    *)
+      ### Give an error
+      echo "Unknown argument \"$1\"!" 1>&2
+      echo "${usage}" 1>&2
+      exit 1
+      ;;
+esac
+
+### Output the stuff
+echo $out
diff --git a/cmake/scripts/generate_dictionary_root.sh.in b/cmake/scripts/generate_dictionary_root.sh.in
new file mode 100755
index 0000000..ed245e5
--- /dev/null
+++ b/cmake/scripts/generate_dictionary_root.sh.in
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+# This macro is used to generate the ROOT dictionaries
+# To use the ctest launchers one needs some environment variables which
+# are only present when running CMake. To have the same environment at
+# the time the dictionary is build this script is used which is build
+# at the time cmake runs.
+
+# Setup the needed environment
+export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
+export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
+export ROOTSYS=@ROOTSYS@
+
+@ROOT_CINT_EXECUTABLE@ -f @Int_DICTIONARY@ @EXTRA_DICT_PARAMETERS_STR@ -c  @Int_DEF_STR@ @Int_INC_STR@ @Int_HDRS_STR@ @Int_LINKDEF@
diff --git a/cmake/scripts/root_macro.sh.in b/cmake/scripts/root_macro.sh.in
index 31a0788..40759d2 100644
--- a/cmake/scripts/root_macro.sh.in
+++ b/cmake/scripts/root_macro.sh.in
@@ -10,10 +10,11 @@
 # Setup the needed environment
 export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
 export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
-export PATH=$PATH:@GEANT4_DIR@
+export PATH=@SIMPATH@/bin:$PATH:@Geant4_DIR@
 export ROOTSYS=@ROOTSYS@
 export ROOTEXE=@ROOT_INSTALL_DIR@/bin/root.exe
-export VMCWORKDIR=@PROJECT_SOURCE_DIR@
+export ROOT_INCLUDE_PATH=@MY_ROOT_INCLUDE_PATH@
+export VMCWORKDIR=@VMCWORKDIR@
 export GEANT4VMC_MACRO_DIR=@GEANT4VMC_MACRO_DIR@
 export USE_VGM=1
 export BOOST=@Boost_Avail@
@@ -26,8 +27,11 @@ export G4PIIDATA="@G4PIIDATA@"
 export G4RADIOACTIVEDATA="@G4RADIOACTIVEDATA@"
 export G4REALSURFACEDATA="@G4REALSURFACEDATA@"
 export G4SAIDXSDATA="@G4SAIDXSDATA@"
-if [ -e @GEANT4_DIR@/env.sh ]; then
-  . @GEANT4_DIR@/env.sh
+export G4ENSDFSTATEDATA="@G4ENSDFSTATEDATA@"
+export G3SYS="@GEANT3_SYSTEM_DIR@"
+export PYTHIA8DATA="@PYTHIA8DATA@"
+if [ -e @Geant4_DIR@/env.sh ]; then
+  . @Geant4_DIR@/env.sh
 fi
 
 # Concatenate all parameters given on the command line to one 
diff --git a/cmake/scripts/root_macro_macos.sh.in b/cmake/scripts/root_macro_macos.sh.in
deleted file mode 100644
index d77e7f5..0000000
--- a/cmake/scripts/root_macro_macos.sh.in
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/bin/bash
-
-# This macro is needed to start the Root macros used for automatic testing
-# from inside CMake using the add_test functionality. Since the tests 
-# starts with a fresh environment on has to set first the correct environment
-# needed to run FairRoot.
-# Also parameters defined in add_test will be converted in the correct format
-# to be passed to root.
-
-# Setup the needed environment
-export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
-export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
-export PATH=$PATH:@GEANT4_DIR@
-export ROOTSYS=@ROOTSYS@
-export ROOTEXE=@ROOT_INSTALL_DIR@/bin/root.exe
-export VMCWORKDIR=@PROJECT_SOURCE_DIR@
-export GEANT4VMC_MACRO_DIR=@GEANT4VMC_MACRO_DIR@
-export USE_VGM=1
-export BOOST=@Boost_Avail@
-export G4LEDATA="@G4LEDATA@"
-export G4LEVELGAMMADATA="@G4LEVELGAMMADATA@"
-export G4NeutronHPCrossSections="@G4NeutronHPCrossSections@"
-export G4NEUTRONHPDATA="@G4NeutronHPCrossSections@"
-export G4NEUTRONXSDATA="@G4NEUTRONXSDATA@"
-export G4PIIDATA="@G4PIIDATA@"
-export G4RADIOACTIVEDATA="@G4RADIOACTIVEDATA@"
-export G4REALSURFACEDATA="@G4REALSURFACEDATA@"
-if [ -e @GEANT4_DIR@/env.sh ]; then
-  . @GEANT4_DIR@/env.sh
-fi
-
-# Concatenate all parameters given on the command line to one 
-# comma separated string 
-parameters=""
-for i in $*; do 
-  if [ -z $parameters ]; then
-    parameters=$i
-  else
-    parameters=$(echo "$parameters,$i")
-  fi 
-done
-
-cd @new_path@
-
-# execute root with the defined macro and the command line parameters
-$ROOTEXE -q -b @my_script_name@\($parameters\)
diff --git a/cmake/scripts/run_binary.sh.in b/cmake/scripts/run_binary.sh.in
index 44eacd1..eb82e80 100644
--- a/cmake/scripts/run_binary.sh.in
+++ b/cmake/scripts/run_binary.sh.in
@@ -2,7 +2,7 @@
 
 #export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
 #export ROOTSYS=@ROOTSYS@
-export VMCWORKDIR=@PROJECT_SOURCE_DIR@
+export VMCWORKDIR=@VMCWORKDIR@
 export GEANT4VMC_MACRO_DIR=@GEANT4VMC_MACRO_DIR@
 export USE_VGM=1
 #export PATH=@ROOTSYS@/bin:$PATH
@@ -31,5 +31,7 @@ export G4NEUTRONXSDATA=@G4NEUTRONXSDATA@
 export G4PIIDATA=@G4PIIDATA@
 export G4RADIOACTIVEDATA=@G4RADIOACTIVEDATA@
 export G4REALSURFACEDATA=@G4REALSURFACEDATA@
+export G4SAIDXSDATA="@G4SAIDXSDATA@"
+export G4ENSDFSTATEDATA="@G4ENSDFSTATEDATA@"
 
 @my_exe_name@
diff --git a/cmake/scripts/set_env.sh.in b/cmake/scripts/set_env.sh.in
index c9f2e0c..ef84229 100644
--- a/cmake/scripts/set_env.sh.in
+++ b/cmake/scripts/set_env.sh.in
@@ -1,36 +1,31 @@
 #!/bin/bash
 
+# Setup the needed environment
 export LD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
+export DYLD_LIBRARY_PATH=@MY_LD_LIBRARY_PATH@
+export PATH=@SIMPATH@/bin:$PATH:@Geant4_DIR@
 export ROOTSYS=@ROOTSYS@
-export VMCWORKDIR=@PROJECT_SOURCE_DIR@
+export ROOTEXE=@ROOT_INSTALL_DIR@/bin/root.exe
+export ROOT_INCLUDE_PATH=@MY_ROOT_INCLUDE_PATH@
+export VMCWORKDIR=@VMCWORKDIR@
 export GEANT4VMC_MACRO_DIR=@GEANT4VMC_MACRO_DIR@
 export USE_VGM=1
-export PATH=@ROOTSYS@/bin:$PATH
-
-export GEANT4_LIBRARY_DIR=@GEANT4_LIBRARY_DIR@
-export GEANT4_INCLUDE_DIR=@GEANT4_INCLUDE_DIR@
-export GEANT4VMC_INCLUDE_DIR=@GEANT4VMC_INCLUDE_DIR@
-export GEANT4VMC_LIBRARY_DIR=@GEANT4VMC_LIBRARY_DIR@
-export CLHEP_INCLUDE_DIR=@CLHEP_INCLUDE_DIR@
-export CLHEP_LIBRARY_DIR=@CLHEP_LIBRARY_DIR@
-export PLUTO_LIBRARY_DIR=@PLUTO_LIBRARY_DIR@
-export PLUTO_INCLUDE_DIR=@PLUTO_INCLUDE_DIR@
-export PYTHIA6_LIBRARY_DIR=@PYTHIA6_LIBRARY_DIR@
-export G3SYS=@G3SYS@
-export GEANT3_INCLUDE_DIR=@GEANT3_INCLUDE_DIR@
-export GEANT3_LIBRARY_DIR=@GEANT3_LIBRARY_DIR@
-export GEANT3_LIBRARIES=@GEANT3_LIBRARIES@
-export USE_VGM=1
-export PYTHIA8DATA=@PYTHIA8DATA@
-export CLASSPATH=@MY_CLASSPATH@
-export G4LEDATA=@G4LEDATA@
-export G4LEVELGAMMADATA=@G4LEVELGAMMADATA@
-export G4NeutronHPCrossSections=@G4NeutronHPCrossSections@
-export G4NEUTRONHPDATA=@G4NeutronHPCrossSections@
-export G4NEUTRONXSDATA=@G4NEUTRONXSDATA@
-export G4PIIDATA=@G4PIIDATA@
-export G4RADIOACTIVEDATA=@G4RADIOACTIVEDATA@
-export G4REALSURFACEDATA=@G4REALSURFACEDATA@
+export BOOST=@Boost_Avail@
+export G4LEDATA="@G4LEDATA@"
+export G4LEVELGAMMADATA="@G4LEVELGAMMADATA@"
+export G4NeutronHPCrossSections="@G4NeutronHPCrossSections@"
+export G4NEUTRONHPDATA="@G4NeutronHPCrossSections@"
+export G4NEUTRONXSDATA="@G4NEUTRONXSDATA@"
+export G4PIIDATA="@G4PIIDATA@"
+export G4RADIOACTIVEDATA="@G4RADIOACTIVEDATA@"
+export G4REALSURFACEDATA="@G4REALSURFACEDATA@"
+export G4SAIDXSDATA="@G4SAIDXSDATA@"
+export G4ENSDFSTATEDATA="@G4ENSDFSTATEDATA@"
+export G3SYS="@GEANT3_SYSTEM_DIR@"
+export PYTHIA8DATA="@PYTHIA8DATA@"
+if [ -e @Geant4_DIR@/env.sh ]; then
+  . @Geant4_DIR@/env.sh
+fi
 
 cd @new_path@
 
diff --git a/cmake/scripts/set_env_macos.sh.in b/cmake/scripts/set_env_macos.sh.in
index 32565d8..614c470 100644
--- a/cmake/scripts/set_env_macos.sh.in
+++ b/cmake/scripts/set_env_macos.sh.in
@@ -31,6 +31,8 @@ export G4NEUTRONXSDATA="@G4NEUTRONXSDATA@"
 export G4PIIDATA="@G4PIIDATA@"
 export G4RADIOACTIVEDATA="@G4RADIOACTIVEDATA@"
 export G4REALSURFACEDATA="@G4REALSURFACEDATA@"
+export G4SAIDXSDATA="@G4SAIDXSDATA@"
+export G4ENSDFSTATEDATA="@G4ENSDFSTATEDATA@"
 
 
 cd @new_path@
diff --git a/config/constants.h b/config/constants.h
new file mode 100644
index 0000000..d33b60f
--- /dev/null
+++ b/config/constants.h
@@ -0,0 +1,2 @@
+enum CoordinateSystem {sysCenterOfMass, sysLaboratory};
+const CoordinateSystem gCoordinateSystem = sysCenterOfMass;
diff --git a/config/eventdisplay.xml b/config/eventdisplay.xml
new file mode 100644
index 0000000..e3a794e
--- /dev/null
+++ b/config/eventdisplay.xml
@@ -0,0 +1,23 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="detector">
+    <subdetector name="ms01yokebarrel" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01cryostat" color="gray" transparency="15" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeii" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeio" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeim" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeoi" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeom" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeoo" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="pipe1" color="orange" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="tpcChamber1" color="cyan" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="tof1" color="spring" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="emc1Chamber1" color="violet" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="zdc01" color="green" transparency="0" isRecursiveColoring="true"/>
+</coloring>
+
diff --git a/config/rootmanager.dat b/config/rootmanager.dat
new file mode 100644
index 0000000..d02bb39
--- /dev/null
+++ b/config/rootmanager.dat
@@ -0,0 +1 @@
+treename=cbmsim
diff --git a/cpc/CMakeLists.txt b/cpc/CMakeLists.txt
index 4c596f5..83416bf 100644
--- a/cpc/CMakeLists.txt
+++ b/cpc/CMakeLists.txt
@@ -3,24 +3,27 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/cpc
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(CPC_SRCS
 MpdCpcGeo.cxx 
diff --git a/cuda/CMakeLists.txt b/cuda/CMakeLists.txt
index 2093105..7d79302 100644
--- a/cuda/CMakeLists.txt
+++ b/cuda/CMakeLists.txt
@@ -1,2 +1,9 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 add_subdirectory(cuda_imp)
 add_subdirectory(interface)
diff --git a/cuda/README.md b/cuda/README.md
new file mode 100644
index 0000000..573c041
--- /dev/null
+++ b/cuda/README.md
@@ -0,0 +1,5 @@
+cuda
+========
+
+Example implementation of the CUDA (http://www.nvidia.com/object/cuda_home_new.html) code, doing tracking.
+
diff --git a/cuda/cuda_imp/CMakeLists.txt b/cuda/cuda_imp/CMakeLists.txt
index 1586063..a8b66b4 100644
--- a/cuda/cuda_imp/CMakeLists.txt
+++ b/cuda/cuda_imp/CMakeLists.txt
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 
 ##############################################################################
 # There are two ways to add include directories to the NVCC command
diff --git a/cuda/cuda_imp/HitTrk.h b/cuda/cuda_imp/HitTrk.h
index 4d72a1f..721baa4 100644
--- a/cuda/cuda_imp/HitTrk.h
+++ b/cuda/cuda_imp/HitTrk.h
@@ -1,2 +1,9 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #define HIT  30
 #define TRK  2000
diff --git a/cuda/interface/CMakeLists.txt b/cuda/interface/CMakeLists.txt
index d77bc41..a642819 100644
--- a/cuda/interface/CMakeLists.txt
+++ b/cuda/interface/CMakeLists.txt
@@ -1,3 +1,10 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CUDA_INCLUDE}
diff --git a/cuda/interface/FairCuda.h b/cuda/interface/FairCuda.h
index 74038cf..2aec883 100644
--- a/cuda/interface/FairCuda.h
+++ b/cuda/interface/FairCuda.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef _FAIRCUDA_H_
 #define _FAIRCUDA_H_
 
diff --git a/cuda/interface/cudaLinkDef.h b/cuda/interface/cudaLinkDef.h
index e63150a..1d5013d 100644
--- a/cuda/interface/cudaLinkDef.h
+++ b/cuda/interface/cudaLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifdef __CINT__
 
 #pragma link off all globals;
diff --git a/cuda/macro/cuda_info.C b/cuda/macro/cuda_info.C
index 9747396..7e3c61b 100644
--- a/cuda/macro/cuda_info.C
+++ b/cuda/macro/cuda_info.C
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 cuda_info()
 {
   //Load the library
diff --git a/datamatch/CMakeLists.txt b/datamatch/CMakeLists.txt
new file mode 100644
index 0000000..871688b
--- /dev/null
+++ b/datamatch/CMakeLists.txt
@@ -0,0 +1,60 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
+# Create a library called "libFairDataMatch" which includes the source files given in
+# the array .
+# The extension is already found.  Any number of sources could be listed here.
+
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/fairtools
+  ${CMAKE_SOURCE_DIR}/geobase 
+  ${CMAKE_SOURCE_DIR}/parbase
+  ${CMAKE_SOURCE_DIR}/base/steer
+  ${CMAKE_SOURCE_DIR}/base/event
+  ${CMAKE_SOURCE_DIR}/base/field
+  ${CMAKE_SOURCE_DIR}/base/sim
+  ${CMAKE_SOURCE_DIR}/base/source
+  ${CMAKE_CURRENT_SOURCE_DIR}
+)
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
+)
+ 
+Link_Directories(${LINK_DIRECTORIES})
+
+set(SRCS
+FairMCMatch.cxx
+FairMCMatchCreatorTask.cxx
+FairMCMatchLoaderTask.cxx
+FairMCMatchSelectorTask.cxx
+FairMCObject.cxx
+FairMCStage.cxx
+FairMCResult.cxx
+FairMCEntry.cxx
+FairMCList.cxx
+FairMCDataCrawler.cxx
+)
+
+Set(HEADERS )
+Set(LINKDEF FairMCMatchLinkDef.h)
+Set(LIBRARY_NAME FairDataMatch)
+Set(DEPENDENCIES Base Core)
+#    FairTools ParBase GeoBase 
+#    Proof GeomPainter Geom VMC EG MathCore Physics 
+#    Matrix Tree Hist RIO Core
+#)
+
+GENERATE_LIBRARY()
+
diff --git a/datamatch/FairMCDataCrawler.cxx b/datamatch/FairMCDataCrawler.cxx
new file mode 100644
index 0000000..eacda81
--- /dev/null
+++ b/datamatch/FairMCDataCrawler.cxx
@@ -0,0 +1,246 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCDataCrawler.cpp
+ *
+ *  Created on: Jul 5, 2011
+ *      Author: stockman
+ */
+
+#include "FairMCDataCrawler.h"
+
+#include "FairLink.h"                   // for FairLink, operator<<
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+
+#include <iostream>                     // for operator<<, ostream, cout, etc
+
+ClassImp(FairMCDataCrawler);
+
+FairMCDataCrawler::FairMCDataCrawler()
+  : fIoman(FairRootManager::Instance()),
+    fFinalStage(),
+    fUltimateStage(0),
+    fVerbose(0),
+    fStoreAllEndpoints(kTRUE),
+    fStoreIntermediate(kTRUE)
+{
+}
+
+FairMCDataCrawler::~FairMCDataCrawler()
+{
+}
+
+void FairMCDataCrawler::Init()
+{
+
+
+  InitDataObjects();
+  /*
+  fIoman->GetObject("MVDPoint");
+  fIoman->GetObject("MVDStripDigis");
+  fIoman->GetObject("MVDPixelDigis");
+  fIoman->GetObject("MVDHitsPixel");
+  fIoman->GetObject("MVDHitsStrip");
+  fIoman->GetObject("MVDPixelClusterCand");
+  fIoman->GetObject("MVDStripClusterCand");
+  fIoman->GetObject("MVDSortedStripDigis");
+  fIoman->GetObject("MVDSortedPixelDigis");
+
+
+  fIoman->GetObject("EmcCluster");
+  fIoman->GetObject("EmcBump");
+  fIoman->GetObject("EmcDigi");
+  fIoman->GetObject("EmcHit");
+  fIoman->GetObject("EmcPoint");
+  fIoman->GetObject("EmcRecoHit");
+  fIoman->GetObject("EmcSharedDigi");
+  fIoman->GetObject("EmcWaveform");
+
+
+
+  fIoman->GetObject("STTPoint");
+  fIoman->GetObject("STTHit");
+  fIoman->GetObject("SttHelixHit");
+  fIoman->GetObject("STTTrack");
+  fIoman->GetObject("STTTrackCand");
+
+  fIoman->GetObject("FairTpcPoint");
+  fIoman->GetObject("FairTpcPrimaryCluster");
+  fIoman->GetObject("FairTpcDriftedElectron");
+  fIoman->GetObject("FairTpcAvalanche");
+  fIoman->GetObject("FairTpcSignal");
+  fIoman->GetObject("FairTpcDigi");
+  fIoman->GetObject("FairTpcCluster");
+
+
+  fIoman->GetObject("GEMPoint");
+  fIoman->GetObject("GEMDigi");
+  fIoman->GetObject("GEMHit");
+
+  fIoman->GetObject("FairDchPoint");
+  fIoman->GetObject("FairDchDigi");
+  fIoman->GetObject("PndDchCylinderHit");
+
+  fIoman->GetObject("MdtPoint");
+  fIoman->GetObject("MdtHit");
+  fIoman->GetObject("MdtTrk");
+
+  fIoman->GetObject("LheHit");
+  fIoman->GetObject("LheCandidate");
+  fIoman->GetObject("LheTrack");
+  fIoman->GetObject("MVDIdealTrackCand");
+  fIoman->GetObject("MVDRiemannTrackCand");
+  fIoman->GetObject("PndTrack");
+  fIoman->GetObject("LheGenTrack");
+  fIoman->GetObject("PidChargedCand");
+  fIoman->GetObject("PidNeutralCand");
+  */
+}
+
+FairMultiLinkedData FairMCDataCrawler::GetInfo(FairMultiLinkedData startLink, TString stopStage)
+{
+  return GetInfo(startLink, fIoman->GetBranchId(stopStage));
+}
+
+FairMultiLinkedData FairMCDataCrawler::GetInfo(FairMultiLinkedData startLink, Int_t stopStageId)
+{
+  fFinalStage.ResetLinks();
+  if (fVerbose > 1) {
+    std::cout << "-------------------------------------" << std::endl;
+    std::cout << "StartLink: " << startLink;
+  }
+  if (fVerbose > 1) { std::cout << "StopStageLink: " << fIoman->GetBranchName(stopStageId) << std::endl; }
+  GetNextStage(startLink, stopStageId);
+  if (fVerbose > 1) { std::cout << "FinalStage: " << fFinalStage << std::endl; }
+  return fFinalStage;
+}
+
+FairMultiLinkedData* FairMCDataCrawler::GetEntry(FairLink link)
+{
+  return static_cast<FairMultiLinkedData*>(FairRootManager::Instance()->GetCloneOfLinkData(link));
+}
+
+FairMultiLinkedData* FairMCDataCrawler::GetEntry(Int_t fileId, Int_t eventNr, Int_t type, Int_t index)
+{
+  return GetEntry(FairLink(fileId, eventNr, type, index));
+}
+
+void FairMCDataCrawler::GetNextStage(FairMultiLinkedData& startStage, Int_t stopStage)
+{
+  FairMultiLinkedData* tempStage;
+  for (int i = 0; i < startStage.GetNLinks(); i++) {
+    FairLink actualLink = startStage.GetLink(i);
+//    if (fVerbose > 0) { std::cout << "Actual Link: " << actualLink << std::endl; }
+    if (actualLink.GetType() < 0) {
+      if (fStoreAllEndpoints) { AddToFinalStage(actualLink, 1); }
+      if (fVerbose > 2) {
+        std::cout << "ActualLink.Type < 0" << std::endl;
+        std::cout << "FinalStage: " << fFinalStage << std::endl;
+        std::cout << "---------------------" << std::endl;
+      }
+      if (fVerbose > 1) {
+        std::cout << std::endl;
+      }
+    } else if (actualLink.GetType() == stopStage) {
+      AddToFinalStage(actualLink, 1);
+      if (fVerbose > 2) {
+        std::cout << "ActualLink.Type == stopStage" << std::endl;
+        std::cout << "FinalStage: " << fFinalStage << std::endl;
+        std::cout << "---------------------" << std::endl;
+      }
+      if (fVerbose > 1) {
+        std::cout << std::endl;
+      }
+    } else if (actualLink.GetType() == fUltimateStage) {
+      if (fStoreAllEndpoints) { AddToFinalStage(actualLink, 1); }
+      if (fVerbose > 2) {
+        std::cout << "ActualLink.Type == UltimateStage" << std::endl;
+        std::cout << "FinalStage: " << fFinalStage << std::endl;
+        std::cout << "---------------------" << std::endl;
+      }
+      if (fVerbose > 1) {
+        std::cout << std::endl;
+      }
+    } else if (actualLink.GetType() == FairRootManager::Instance()->GetBranchId("EventHeader.")) {
+      if (fStoreAllEndpoints) { AddToFinalStage(actualLink, 1); }
+      if (fVerbose > 2) {
+        std::cout << "ActualLink.Type == EventHeader" << std::endl;
+        std::cout << "FinalStage: " << fFinalStage << std::endl;
+        std::cout << "---------------------" << std::endl;
+      }
+      if (fVerbose > 1) {
+        std::cout << std::endl;
+      }
+    } else {
+      tempStage = GetEntry(actualLink);
+      if (tempStage == 0) {
+        if (fStoreAllEndpoints) { AddToFinalStage(actualLink, 1); }
+        if (fVerbose > 2) {
+          std::cout << "TempStage == 0" << std::endl;
+          std::cout << "FinalStage: " << fFinalStage << std::endl;
+          std::cout << "---------------------" << std::endl;
+        }
+        if (fVerbose > 1) {
+          std::cout << std::endl;
+        }
+        continue;
+      }
+      if (fVerbose > 0) {
+//        std::cout << "TempStage Start";
+        std::cout << " // ";
+        actualLink.Print();
+        std::cout << " --> " << *tempStage;
+      }
+      if (tempStage->GetNLinks() == 0) {
+        if (fStoreAllEndpoints) { AddToFinalStage(actualLink,1); }
+        if (fVerbose > 0) {
+          std::cout << "tempStage->GetNLinks == 0" << std::endl;
+          std::cout << "FinalStage: " << fFinalStage << std::endl;
+          std::cout << "---------------------" << std::endl;
+        }
+      } else {
+        if(fStoreIntermediate) { AddToFinalStage(actualLink, 1); }
+        double tempStageWeight = 1;
+        double startLinkWeight = startStage.GetLink(i).GetWeight();
+
+        if (fVerbose > 2) {
+          //std::cout << "Tempstage " << tempStage.GetSource() << ": weight " << tempStageWeight << std::endl;
+          std::cout << "StartLinkWeight " << startLinkWeight << std::endl;
+        }
+        //std::cout << " StageWeight: " << tempStageWeight << " startLinkWeight: " << startLinkWeight;
+        tempStage->MultiplyAllWeights(tempStageWeight);
+
+        if ((tempStageWeight * startLinkWeight) == 0) {
+          tempStage->MultiplyAllWeights(tempStageWeight);
+          tempStage->AddAllWeights(startLinkWeight/startStage.GetNLinks());
+          if (fVerbose > 2) {
+            std::cout << " NLinks: " << tempStage->GetNLinks() << " ";
+            std::cout << "AddAllWeights: " << startLinkWeight/startStage.GetNLinks() << std::endl;
+          }
+        } else {
+          tempStage->MultiplyAllWeights(startLinkWeight);
+          if (fVerbose > 2) {
+            std::cout << "MultiplyAllWeights: " << startLinkWeight << std::endl;
+          }
+        }
+
+      }
+      //      if (fVerbose > 0)
+      //        std::cout<< "TempStage Stop: " << *tempStage << std::endl;
+
+      GetNextStage(*tempStage, stopStage);
+    }
+  }
+}
+
+void FairMCDataCrawler::AddToFinalStage(FairLink hitPair, Float_t mult)
+{
+  fFinalStage.AddLink(hitPair, false, mult);
+}
diff --git a/datamatch/FairMCDataCrawler.h b/datamatch/FairMCDataCrawler.h
new file mode 100644
index 0000000..873a577
--- /dev/null
+++ b/datamatch/FairMCDataCrawler.h
@@ -0,0 +1,71 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCDataCrawler.h
+ *
+ *  Created on: Jul 5, 2011
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCDATACRAWLER_H_
+#define FAIRMCDATACRAWLER_H_
+
+#include "TObject.h"                    // for TObject
+
+#include "FairMultiLinkedData.h"        // for FairMultiLinkedData
+
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TString.h"                    // for TString
+
+class FairLink;
+class FairRootManager;
+
+class FairMCDataCrawler : public TObject
+{
+  public:
+    FairMCDataCrawler();
+    virtual ~FairMCDataCrawler();
+
+    FairMultiLinkedData GetInfo(FairMultiLinkedData startLink, TString stopStage);
+    FairMultiLinkedData GetInfo(FairMultiLinkedData startLink, Int_t stopStageId);
+
+    FairMultiLinkedData* GetEntry(Int_t fileId, Int_t eventNr, Int_t type, Int_t index);
+    FairMultiLinkedData* GetEntry(FairLink link);
+
+    void SetStoreIntermediate(Bool_t val = kTRUE) {fStoreIntermediate = val;}
+    void SetStoreAllEndpoints(Bool_t val = kTRUE) {fStoreAllEndpoints = val;}
+
+    void Init();
+
+    void SetVerbose(Int_t val) {fVerbose = val;};
+
+    virtual void InitDataObjects() = 0;
+
+  protected:
+
+    FairRootManager* fIoman;
+
+  private:
+    FairMultiLinkedData fFinalStage;
+    Int_t fUltimateStage; ///< last stage in link chain. Here all recursive operations must stop.
+
+    Int_t fVerbose;
+    Bool_t fStoreAllEndpoints; ///< true if non-stop-stage data is stored in results
+    Bool_t fStoreIntermediate; ///< true if all intermediate steps should be stored
+
+    void GetNextStage(FairMultiLinkedData& startEntry, Int_t stopStage);
+    void AddToFinalStage(FairLink link, Float_t mult);
+    void ClearFinalStage();
+
+    FairMCDataCrawler(const FairMCDataCrawler&);
+    FairMCDataCrawler& operator=(const FairMCDataCrawler&);
+
+    ClassDef(FairMCDataCrawler, 1);
+};
+
+#endif /* PNDMCDATACRAWLER_H_ */
diff --git a/datamatch/FairMCEntry.cxx b/datamatch/FairMCEntry.cxx
new file mode 100644
index 0000000..513dde8
--- /dev/null
+++ b/datamatch/FairMCEntry.cxx
@@ -0,0 +1,44 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCEntry.cpp
+ *
+ *  Created on: Dec 22, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCEntry.h"
+
+ClassImp(FairMCEntry);
+
+FairMCEntry::FairMCEntry()
+  : FairMultiLinkedData(),
+    fSource(-1),
+    fPos(-1)
+{
+  SetPersistanceCheck(kFALSE);
+}
+
+FairMCEntry::~FairMCEntry()
+{
+}
+
+void FairMCEntry::RemoveType(Int_t type)
+{
+ // std::set<FairLink>::iterator endIter = fLinks.end();
+  std::set<FairLink>::iterator it = fLinks.begin();
+  for (; it!=fLinks.end();) {
+    if (it->GetType() == type) {
+      fLinks.erase(it);
+      it = fLinks.begin();
+    } else {
+      it++;
+    }
+  }
+}
+
diff --git a/datamatch/FairMCEntry.h b/datamatch/FairMCEntry.h
new file mode 100644
index 0000000..05a9da4
--- /dev/null
+++ b/datamatch/FairMCEntry.h
@@ -0,0 +1,72 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCEntry.h
+ *
+ *  Created on: Dec 22, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCENTRY_H_
+#define FAIRMCENTRY_H_
+
+#include "FairMultiLinkedData.h"        // for FairMultiLinkedData
+
+#include "FairLink.h"                   // for FairLink
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, FairMCEntry::Class, etc
+
+#include <iostream>                     // for ostream
+#include <set>                          // for set
+
+class FairMCEntry : public FairMultiLinkedData
+{
+  public:
+    FairMCEntry();
+    FairMCEntry(std::set<FairLink> links, Int_t source = -1, Int_t pos = -1)
+      : FairMultiLinkedData(links),
+        fSource(source),
+        fPos(pos) {
+      SetPersistanceCheck(kFALSE);
+    }
+
+    FairMCEntry(FairMultiLinkedData links, Int_t source = -1, Int_t pos = -1)
+      : FairMultiLinkedData(links),
+        fSource(source),
+        fPos(pos) {
+      SetPersistanceCheck(kFALSE);
+    }
+
+    void SetSource(Int_t source) {fSource = source;}
+    void SetPos(Int_t pos) {fPos = pos;}
+
+    Int_t GetSource() const {return fSource;}
+    Int_t GetPos() const {return fPos;}
+
+    void RemoveType(Int_t type);
+
+    virtual ~FairMCEntry();
+
+    virtual void PrintInfo(std::ostream& out) {
+      out << *this;
+    }
+
+    friend std::ostream& operator<< (std::ostream& out, const FairMCEntry& link) {
+      (static_cast<FairMultiLinkedData>(link)).PrintLinkInfo(out);
+      return out;
+    }
+
+  private:
+    Int_t fSource;
+    Int_t fPos;
+
+    ClassDef(FairMCEntry, 1);
+};
+
+#endif
diff --git a/datamatch/FairMCList.cxx b/datamatch/FairMCList.cxx
new file mode 100644
index 0000000..4104960
--- /dev/null
+++ b/datamatch/FairMCList.cxx
@@ -0,0 +1,29 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCList.cxx
+ *
+ *  Created on: Dec 3, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCList.h"
+
+ClassImp(FairMCList);
+
+FairMCList::FairMCList()
+  : TObject(),
+    fList(),
+    fEntry(-1),
+    fType(-1)
+{
+}
+
+FairMCList::~FairMCList()
+{
+}
diff --git a/datamatch/FairMCList.h b/datamatch/FairMCList.h
new file mode 100644
index 0000000..1ebb78d
--- /dev/null
+++ b/datamatch/FairMCList.h
@@ -0,0 +1,64 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCList.h
+ *
+ *  Created on: Dec 3, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCLIST_H_
+#define FAIRMCLIST_H_
+
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Int_t, FairMCList::Class, etc
+
+#include <vector>                       // for vector
+
+class FairMCList : public TObject
+{
+  public:
+    FairMCList();
+    FairMCList(Int_t type, Int_t entry)
+      : TObject(),
+        fList(),
+        fEntry(entry),
+        fType(type) {
+    }
+
+    FairMCList(Int_t type, Int_t entry, std::vector<Int_t> list)
+      : TObject(),
+        fList(list),
+        fEntry(entry),
+        fType(type) {
+    }
+
+    virtual ~FairMCList();
+
+    void SetType(Int_t type) { fType = type;}
+    void SetEntry(Int_t entry) { fEntry = entry;}
+    void AddElement(Int_t element) {fList.push_back(element);}
+
+    Int_t GetType() const {return fType;}
+    Int_t GetEntry() const {return fEntry;}
+    Int_t GetNElements() const {return fList.size();}
+    Int_t GetElement(Int_t index)const {return fList.at(index);}
+    std::vector<Int_t> GetElements() const {return fList;}
+
+    void Reset() {fList.clear();}
+
+  private:
+    std::vector<Int_t> fList;
+    Int_t fEntry;
+    Int_t fType;
+
+    ClassDef(FairMCList, 1);
+};
+
+#endif /* PNDMCLIST_H_ */
diff --git a/datamatch/FairMCMatch.cxx b/datamatch/FairMCMatch.cxx
new file mode 100644
index 0000000..01063ed
--- /dev/null
+++ b/datamatch/FairMCMatch.cxx
@@ -0,0 +1,405 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCMatch.cxx
+ *
+ *  Created on: Nov 23, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCMatch.h"
+
+#include "FairLink.h"                   // for FairLink
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "TClonesArray.h"               // for TClonesArray
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+ClassImp(FairMCMatch);
+
+FairMCMatch::FairMCMatch()
+  : TNamed(),
+    fUltimateStage(0),
+    fList(),
+    fFinalStageML(),
+    fVerbose(0)
+{
+  fFinalStageML.SetPersistanceCheck(kFALSE);
+}
+
+FairMCMatch::~FairMCMatch()
+{
+  for (TListIterator iter = fList.begin(); iter != fList.end(); iter++) {
+    delete(iter->second);
+  }
+  fList.clear();
+}
+
+void FairMCMatch::AddElement(Int_t sourceType, int index, Int_t targetType, int link)
+{
+  FairLink myPair(targetType, link);
+  AddElement(sourceType, index, myPair);
+}
+
+void FairMCMatch::AddElement(Int_t type, int index, FairLink link)
+{
+  fList[type]->AddLink(link, index);
+}
+
+
+
+void FairMCMatch::SetElements(Int_t sourceType, int index, FairMultiLinkedData* links)
+{
+  fList[sourceType]->SetEntry(links, index);
+}
+
+void FairMCMatch::InitStage(Int_t type, std::string fileName, std::string branchName)
+{
+  if (fList[type] == 0) {
+    FairMCStage* newStage = new FairMCStage(type, fileName, branchName);
+    fList[type] = newStage;
+    if (fVerbose > 1) {
+      std::cout << "InitStages: " << *newStage;
+    }
+  } else {
+    std::cout << "-W- FairMCMatch::InitStage: Stage " << type << " exists already!" << std::endl;
+  }
+}
+
+void FairMCMatch::InitStage(std::string branchName, std::string fileName)
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (ioman->CheckBranch(branchName.c_str()) == 1) {
+    Int_t type = ioman->GetBranchId(branchName.c_str());
+    if (type > -1) {
+      InitStage(type, fileName, branchName);
+    } else {
+      std::cout << "-W- FairMCMatch::InitStage: Branch name " << branchName << " not registered!" << std::endl;
+    }
+  } else {
+    std::cout << "-W- FairMCMatch::InitStage: Branch name " << branchName << " not persistant!" << std::endl;
+  }
+}
+
+void FairMCMatch::RemoveStage(Int_t type)
+{
+  fList.erase(type);
+}
+
+
+void FairMCMatch::SetCommonWeightStages(Float_t weight)
+{
+  for (int i = 0; i < GetNMCStages(); i++) {
+    if (GetMCStage(i)) {
+      GetMCStage(i)->SetWeight(weight);
+    }
+  }
+}
+
+FairMCResult FairMCMatch::GetMCInfo(TString start, TString stop)
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  return GetMCInfo(ioman->GetBranchId(start), ioman->GetBranchId(stop));
+}
+
+FairMCResult FairMCMatch::GetMCInfo(Int_t start, Int_t stop)
+{
+  FairMCResult result(start, stop);
+  if(!IsTypeInList(start)) {
+    return result;
+  }
+  if (start < stop) {
+    return GetMCInfoForward(start, stop);
+  } else {
+    return GetMCInfoBackward(start, stop);
+  }
+}
+
+FairMCEntry FairMCMatch::GetMCInfoSingle(FairLink aLink, TString stop)
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  return GetMCInfoSingle(aLink, ioman->GetBranchId(stop));
+}
+
+FairMCEntry FairMCMatch::GetMCInfoSingle(FairLink aLink, Int_t stop)
+{
+  FairMCEntry result;
+  if(!IsTypeInList(static_cast<Int_t>(aLink.GetType()))) {
+    return result;
+  }
+  if(!(fList[static_cast<Int_t>(aLink.GetType())]->GetNEntries() > aLink.GetIndex())) {
+    return result;
+  }
+
+  if (aLink.GetType() < stop) {
+    return GetMCInfoForwardSingle(aLink, stop);
+  } else {
+    return GetMCInfoBackwardSingle(aLink, stop);
+  }
+}
+
+FairMCResult FairMCMatch::GetMCInfoForward(Int_t start, Int_t stop)
+{
+  FairMCResult result(start, stop);
+  FairMCStage startVec = *(fList[start]);
+  for (int i = 0; i < startVec.GetNEntries(); i++) {
+    FairLink tempLink(startVec.GetStageId(), i);
+
+    FairMCEntry tempEntry(GetMCInfoForwardSingle(tempLink, stop));
+    if (tempEntry.GetNLinks() > 0)
+      if (tempEntry.GetLink(0).GetType() == start) {
+        tempEntry.DeleteLink(tempEntry.GetLink(0));
+      }
+    tempEntry.SetSource(start);
+    tempEntry.SetPos(i);
+    result.SetEntry(tempEntry);
+  }
+  return result;
+}
+
+FairMCEntry FairMCMatch::GetMCInfoForwardSingle(FairLink link, Int_t stop)
+{
+  FairMCEntry result;
+  ClearFinalStage();
+
+  FairMultiLinkedData tempStage;
+  tempStage.SetPersistanceCheck(kFALSE);
+  tempStage.AddLink(link, true);
+  FindStagesPointingToLinks(tempStage, stop);
+  result.SetLinks(fFinalStageML);
+  return result;
+}
+
+FairMCResult FairMCMatch::GetMCInfoBackward(Int_t start, Int_t stop)
+{
+  FairMCResult result(start, stop);
+  FairMCStage startVec = *(fList[start]);
+  for (int i = 0; i < startVec.GetNEntries(); i++) {
+    FairLink tempLink(start, i);
+    GetMCInfoBackwardSingle(tempLink, stop, startVec.GetWeight());
+    result.SetEntry(&fFinalStageML, result.GetNEntries());
+  }
+  return result;
+}
+
+FairMCEntry FairMCMatch::GetMCInfoBackwardSingle(FairLink aLink, Int_t stop, Double_t weight)
+{
+  FairMCEntry result;
+  FairMultiLinkedData multiLink = fList[static_cast<Int_t>(aLink.GetType())]->GetEntry(aLink.GetIndex());
+
+  ClearFinalStage();
+  multiLink.MultiplyAllWeights(weight);
+  GetNextStage(multiLink, stop);
+  result.SetLinks(fFinalStageML);
+
+  return result;
+}
+
+
+void FairMCMatch::FindStagesPointingToLinks(FairMultiLinkedData links, Int_t stop)
+{
+  FairMultiLinkedData tempLinks;
+  tempLinks.SetPersistanceCheck(kFALSE);
+  for (int i = 0; i < links.GetNLinks(); i++) {
+    FairLink myLink = links.GetLink(i);
+    FairMultiLinkedData myNewLinks = FindStagesPointingToLink(myLink);
+    myNewLinks.SetPersistanceCheck(kFALSE);
+    if (myNewLinks.GetNLinks() == 0) {
+      fFinalStageML.AddLink(myLink, true);
+    } else {
+      for (int j = 0; j < myNewLinks.GetNLinks(); j++) {
+        if (myNewLinks.GetLink(j).GetType() == static_cast<Int_t>(stop)) {
+          fFinalStageML.AddLink(myNewLinks.GetLink(j), true);
+        } else if (myNewLinks.GetLink(j).GetType() > static_cast<Int_t>(stop)) {
+          fFinalStageML.AddLink(myLink, true);
+        } else {
+          tempLinks.AddLink(myNewLinks.GetLink(j), true);
+        }
+      }
+    }
+  }
+  if (tempLinks.GetNLinks() != 0) {
+    FindStagesPointingToLinks(tempLinks, stop);
+  }
+}
+
+
+FairMultiLinkedData FairMCMatch::FindStagesPointingToLink(FairLink link)
+{
+  FairMultiLinkedData result;
+  result.SetPersistanceCheck(kFALSE);
+  TListIteratorConst iter = fList.find(static_cast<Int_t>(link.GetType()));
+  for(; iter!= fList.end(); iter++) {
+    if (iter->second->PosInList(link).GetNLinks() > 0) {
+      result.AddLinks(iter->second->PosInList(link), true);
+    }
+  }
+  return result;
+}
+
+
+FairMultiLinkedData FairMCMatch::FindLinksToStage(Int_t stage)
+{
+  FairMultiLinkedData result;
+  result.SetPersistanceCheck(kFALSE);
+  for (int i = 0; i < GetNMCStages(); i++) {
+    result.AddLinks(GetMCStage(i)->GetLinksWithType(stage), true);
+  }
+  return result;
+}
+
+void FairMCMatch::CreateArtificialStage(TString branchName, std::string fileName)
+{
+  FairRootManager* ioman = FairRootManager::Instance();
+  std::cout << "Create Artificial Stage for " << branchName;
+  std::cout << " with ID " << ioman->GetBranchId(branchName) << std::endl;
+  if (ioman->GetBranchId(branchName) > -1) {
+    CreateArtificialStage(ioman->GetBranchId(branchName), fileName, branchName.Data());
+  } else {
+    std::cout << "-E- FairMCMatch::CreateArtificialStage: Branch does not exist: " << branchName << std::endl;
+  }
+}
+
+void FairMCMatch::CreateArtificialStage(Int_t stage, std::string fileName, std::string branchName)
+{
+  FairMultiLinkedData stageLinks = FindLinksToStage(stage);
+  stageLinks.SetPersistanceCheck(kFALSE);
+  if (stageLinks.GetNLinks() > 0) {
+    InitStage(stage, fileName, branchName);
+    FairMultiLinkedData artData;
+    artData.SetLink(FairLink(static_cast<Int_t>(-1), -1));
+    for (int i = 0; i < stageLinks.GetNLinks(); i++) {
+      if (stageLinks.GetLink(i).GetIndex() > -1) {
+        fList[stage]->SetEntry(&artData, stageLinks.GetLink(i).GetIndex());
+      }
+    }
+    fList[stage]->SetLoaded(kTRUE);
+
+  }
+}
+
+void FairMCMatch::GetNextStage(FairMultiLinkedData& startStage, Int_t stopStage)
+{
+
+  FairMCEntry tempStage;
+
+  for (int i = 0; i < startStage.GetNLinks(); i++) {
+    if (startStage.GetLink(i).GetType() == stopStage) {
+      AddToFinalStage(startStage.GetLink(i),1);
+      if (fVerbose > 0) {
+        std::cout << "FinalStage: " << fFinalStageML << std::endl;
+        std::cout << "---------------------" << std::endl;
+      }
+    } else if (startStage.GetLink(i).GetType() == fUltimateStage) {
+    } else {
+      tempStage = GetEntry(startStage.GetLink(i));
+      if (fVerbose > 0) {
+        std::cout << "TempStage Start";
+        startStage.GetLink(i).PrintLinkInfo();
+        std::cout << " --> " << tempStage << std::endl;
+      }
+      if (tempStage.GetNLinks() == 0) {
+        AddToFinalStage(startStage.GetLink(i),1);
+        if (fVerbose > 0) {
+          std::cout << "FinalStage: " << fFinalStageML << std::endl;
+          std::cout << "---------------------" << std::endl;
+        }
+      } else {
+        double tempStageWeight = GetMCStageType(static_cast<Int_t>(tempStage.GetSource()))->GetWeight();
+        double startLinkWeight = startStage.GetLink(i).GetWeight();
+
+        if (fVerbose > 0) {
+          std::cout << "Tempstage " << tempStage.GetSource() << ": weight " << tempStageWeight << std::endl;
+          std::cout << "StartLinkWeight " << startLinkWeight << std::endl;
+        }
+        tempStage.MultiplyAllWeights(tempStageWeight);
+
+        if ((tempStageWeight * startLinkWeight) == 0) {
+          tempStage.MultiplyAllWeights(tempStageWeight);
+          tempStage.AddAllWeights(startLinkWeight/startStage.GetNLinks());
+          if (fVerbose > 0) {
+            std::cout << " NLinks: " << tempStage.GetNLinks() << " ";
+            std::cout << "AddAllWeights: " << startLinkWeight/startStage.GetNLinks() << std::endl;
+          }
+        } else {
+          tempStage.MultiplyAllWeights(startLinkWeight);
+          if (fVerbose > 0) {
+            std::cout << "MultiplyAllWeights: " << startLinkWeight << std::endl;
+          }
+        }
+
+      }
+      if (fVerbose > 0) {
+        std::cout<< "TempStage Stop: " << tempStage << std::endl;
+      }
+
+      GetNextStage(tempStage, stopStage);
+    }
+  }
+}
+
+FairMCEntry FairMCMatch::GetEntry(Int_t type, int index)
+{
+
+  FairMCEntry empty;
+  if (index < 0) { return empty; }
+  if (fList[type] == 0) {
+    return empty;
+  }
+  if (fList[type]->GetNEntries() > index) {
+    return fList[type]->GetEntry(index);
+  }
+  return empty;
+}
+
+FairMCEntry FairMCMatch::GetEntry(FairLink link)
+{
+  return GetEntry(static_cast<Int_t>(link.GetType()), link.GetIndex());
+}
+
+void FairMCMatch::AddToFinalStage(FairLink hitPair, Float_t mult)
+{
+  fFinalStageML.AddLink(hitPair, true, mult);
+}
+
+void FairMCMatch::ClearFinalStage()
+{
+  fFinalStageML.Reset();
+}
+
+void FairMCMatch::ClearMCList()
+{
+  for (TListIterator iter = fList.begin(); iter != fList.end(); iter++) {
+    if (iter->second != 0) {
+      iter->second->ClearEntries();
+    } 
+  }
+  fList.clear();
+}
+
+bool FairMCMatch::IsTypeInList(Int_t type)
+{
+  for(TListIterator iter = fList.begin(); iter != fList.end(); iter++) {
+    if (iter->first == type) {
+      return true;
+    }
+  }
+  return false;
+}
+
+void FairMCMatch::LoadInMCLists(TClonesArray* myLinkArray)
+{
+  for (int i = 0; i < myLinkArray->GetEntriesFast(); i++) {
+    FairMCEntry* myLink = static_cast<FairMCEntry*>(myLinkArray->At(i));
+    if (IsTypeInList(static_cast<Int_t>(myLink->GetSource()))) {
+      fList[static_cast<Int_t>(myLink->GetSource())]->SetEntry(*myLink);
+      fList[static_cast<Int_t>(myLink->GetSource())]->SetLoaded(kTRUE);
+    }
+  }
+}
diff --git a/datamatch/FairMCMatch.h b/datamatch/FairMCMatch.h
new file mode 100644
index 0000000..33cf2c2
--- /dev/null
+++ b/datamatch/FairMCMatch.h
@@ -0,0 +1,139 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCMatch.h
+ *
+ *  Created on: Nov 23, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCMATCH_H_
+#define FAIRMCMATCH_H_
+
+#include "TNamed.h"                     // for TNamed
+
+#include "FairMCEntry.h"                // for FairMCEntry
+#include "FairMCResult.h"               // for FairMCResult
+#include "FairMCStage.h"                // for FairMCStage
+#include "FairMultiLinkedData.h"        // for FairMultiLinkedData
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, FairMCMatch::Class, etc
+#include "TString.h"                    // for TString
+#include "TClonesArray.h"
+
+#include <iostream>                     // for ostream, cout, endl
+#include <map>                          // for map, etc
+#include <string>                       // for string
+#include <utility>                      // for pair
+
+class FairLink;
+
+typedef std::map<Int_t, FairMCStage*>::iterator TListIterator;
+typedef std::map<Int_t, FairMCStage*>::const_iterator TListIteratorConst;
+
+class FairMCMatch: public TNamed
+{
+  public:
+    FairMCMatch();
+    FairMCMatch(const char* name, const char* title)
+      : TNamed(name, title),
+        fUltimateStage(0),
+        fList(),
+        fFinalStageML(),
+        fVerbose(0) {
+      fFinalStageML.SetPersistanceCheck(kFALSE);
+    }
+
+    virtual ~FairMCMatch();
+
+    void AddElement(Int_t type, int index, FairLink link);
+    void AddElement(Int_t sourceType, int index, Int_t targetType, int link);
+    void SetElements(Int_t sourceType, int index, FairMultiLinkedData* links);
+    void InitStage(Int_t type, std::string fileName, std::string branchName);
+    void InitStage(std::string fileName, std::string branchName = "");
+    void RemoveStage(Int_t type);
+    void LoadInMCLists(TClonesArray* myLinkArray);
+    void ClearMCList();
+
+    void SetCommonWeightStages(Float_t weight);
+
+    FairMCEntry GetEntry(Int_t type, int index);
+    FairMCEntry GetEntry(FairLink link);
+
+    FairMCResult GetMCInfo(Int_t start, Int_t stop);
+    FairMCResult GetMCInfo(TString start, TString stop);
+    FairMCEntry  GetMCInfoSingle(FairLink aLink, Int_t stop);
+    FairMCEntry  GetMCInfoSingle(FairLink aLink, TString stop);
+
+    int GetNMCStages() const {return fList.size();}
+
+    FairMCStage* GetMCStage(int index) const {
+      TListIteratorConst iter = fList.begin();
+      for (int i = 0; i < index; i++) {
+        iter++;
+      }
+      return (iter->second);
+    }
+
+    FairMCStage* GetMCStageType(TString branch) {
+      FairRootManager* ioman = FairRootManager::Instance();
+      if (ioman->GetBranchId(branch) > 0) {
+        return fList[ioman->GetBranchId(branch)];
+      } else {
+        return 0;
+      }
+    }
+
+    FairMCStage* GetMCStageType(Int_t type) {
+      return fList[type];
+    }
+
+    void CreateArtificialStage(TString branchName, std::string fileName = "");
+    void CreateArtificialStage(Int_t stage, std::string fileName = "", std::string branchName = "");
+
+    FairMultiLinkedData FindLinksToStage(Int_t stage);
+
+    bool IsTypeInList(Int_t type);
+
+    void PrintInfo(std::ostream& out = std::cout) {out << *this;}
+
+    friend std::ostream& operator<< (std::ostream& out, const FairMCMatch& match) {
+      for (int i = 0; i < match.GetNMCStages(); i++) {
+        if (match.GetMCStage(i)->GetLoaded() == kTRUE) {
+          match.GetMCStage(i)->PrintInfo(out);
+          out << std::endl;
+        }
+      }
+      return out;
+    }
+
+  private:
+
+    Int_t fUltimateStage; ///< last stage in link chain. Here all recursive operations must stop.
+    std::map<Int_t, FairMCStage*> fList;
+    FairMultiLinkedData fFinalStageML;
+    Int_t fVerbose;
+
+    void FindStagesPointingToLinks(FairMultiLinkedData links, Int_t stop);
+    FairMultiLinkedData FindStagesPointingToLink(FairLink link);
+
+    FairMCResult GetMCInfoForward(Int_t start, Int_t stop);
+    FairMCResult GetMCInfoBackward(Int_t start, Int_t stop);
+    FairMCEntry GetMCInfoForwardSingle(FairLink link, Int_t stop);
+    FairMCEntry GetMCInfoBackwardSingle(FairLink link, Int_t stop, Double_t weight = 1.);
+
+    void GetNextStage(FairMultiLinkedData& startEntry, Int_t stopStage);
+    void AddToFinalStage(FairLink link, Float_t mult);
+    void ClearFinalStage();
+
+    ClassDef(FairMCMatch, 1);
+};
+
+#endif /* PNDMCMATCH_H_ */
diff --git a/datamatch/FairMCMatchCreatorTask.cxx b/datamatch/FairMCMatchCreatorTask.cxx
new file mode 100644
index 0000000..0b95342
--- /dev/null
+++ b/datamatch/FairMCMatchCreatorTask.cxx
@@ -0,0 +1,150 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                FairMCMatchCreatorTask source file             -----
+// -----                  Created 18/07/08  by T.Stockmanns        -----
+// -------------------------------------------------------------------------
+#include "FairMCMatchCreatorTask.h"
+
+#include "FairLink.h"                   // for FairLink
+#include "FairMCEntry.h"                // for FairMCEntry
+#include "FairMCMatch.h"                // for FairMCMatch
+#include "FairMCStage.h"                // for FairMCStage
+#include "FairMultiLinkedData.h"        // for FairMultiLinkedData
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+#include "TClonesArray.h"               // for TClonesArray
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+// -----   Default constructor   -------------------------------------------
+FairMCMatchCreatorTask::FairMCMatchCreatorTask()
+  : FairTask("Creates FairMCMatch"),
+    fMCMatch(NULL),
+    fBranches(),
+    fPersistance(kTRUE),
+    fMCLink(NULL),
+    fEventNr(0)
+{
+}
+// -------------------------------------------------------------------------
+
+
+// -----   Destructor   ----------------------------------------------------
+FairMCMatchCreatorTask::~FairMCMatchCreatorTask()
+{
+}
+
+// -----   Public method Init   --------------------------------------------
+InitStatus FairMCMatchCreatorTask::Init()
+{
+  fMCMatch = new FairMCMatch("FairMCMatch", "FairMCMatch");
+
+  InitDataStages();
+
+  InitStatus status = InitBranches();
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (!ioman) {
+    std::cout << "-E- FairMCMatchCreatorTask::Init: "
+              << "RootManager not instantiated!" << std::endl;
+    return kFATAL;
+  }
+
+  fMCLink = new TClonesArray("FairMCEntry");
+  ioman->Register("MCLink", "MCInfo", fMCLink, kTRUE);
+
+  ioman->Register("MCMatch", "MCInfo", fMCMatch, kFALSE);
+
+  std::cout << "-I- FairMCMatchCreatorTask::Init: Initialization successfull" << std::endl;
+
+
+  return status;
+}
+
+InitStatus FairMCMatchCreatorTask::InitBranches()
+{
+
+  // Get RootManager
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (!ioman) {
+    std::cout << "-E- FairMCMatchCreatorTask::Init: "
+              << "RootManager not instantiated!" << std::endl;
+    return kFATAL;
+  }
+
+  int NStages = fMCMatch->GetNMCStages();
+  for (int i = NStages-1; i > -1; i--) {
+    TClonesArray* myBranch = static_cast<TClonesArray*>(ioman->GetObject(fMCMatch->GetMCStage(i)->GetBranchName().c_str()));
+    if (!myBranch)  {
+      //std::cout << "NMCStages: " << fMCMatch->GetNMCStages() << std::endl;
+      std::cout << "-W- FairMCMatchCreatorTask::Init: "<< "No "<<fMCMatch->GetMCStage(i)->GetBranchName() << " array!" << std::endl;
+      fMCMatch->GetMCStage(i)->SetFill(kFALSE); //RemoveStage(fMCMatch->GetMCStage(i)->GetStageId());
+
+      continue;
+    } else { fMCMatch->GetMCStage(i)->SetFill(kTRUE); }
+    fBranches[fMCMatch->GetMCStage(i)->GetBranchName()] = myBranch;
+  }
+  return kSUCCESS;
+}
+
+// -------------------------------------------------------------------------
+void FairMCMatchCreatorTask::SetParContainers()
+{
+}
+
+// -----   Public method Exec   --------------------------------------------
+void FairMCMatchCreatorTask::Exec(Option_t* /*opt*/)
+{
+  if (!fMCLink) { Fatal("Exec", "No fMCLinkDet"); }
+  fMCLink->Delete();
+  fMCMatch->ClearMCList();
+
+  fMCMatch->LoadInMCLists(fMCLink);
+
+  for (int i = 0; i < fMCMatch->GetNMCStages(); i++) {
+    if (fMCMatch->GetMCStage(i)->GetFill() == kTRUE && fMCMatch->GetMCStage(i)->GetLoaded() == kFALSE) {
+      TClonesArray* clArray = fBranches[fMCMatch->GetMCStage(i)->GetBranchName()];
+      for (int j = 0; j < clArray->GetEntries(); j++) {
+        FairMultiLinkedData* myData = static_cast<FairMultiLinkedData*>(clArray->At(j));
+        fMCMatch->SetElements(fMCMatch->GetMCStage(i)->GetStageId(), j, myData);
+      }
+      if (fMCMatch->GetMCStage(i)->GetNEntries() > 0) {
+        fMCMatch->GetMCStage(i)->SetLoaded(kTRUE);
+      }
+    }
+  }
+
+  int i = 0;
+  if (fPersistance) {
+    for (int index = 0; index < fMCMatch->GetNMCStages(); index++) {
+      FairMCStage myStage(*(fMCMatch->GetMCStage(index)));
+
+      for (int indStage = 0; indStage < myStage.GetNEntries(); indStage++) {
+
+        FairMCEntry myLink(myStage.GetMCLink(indStage));
+        new((*fMCLink)[i]) FairMCEntry(myLink.GetLinks(), myLink.GetSource(), myLink.GetPos());
+        i++;
+      }
+    }
+  }
+
+  if (fVerbose > 0) {
+    fMCMatch->Print();
+    std::cout << std::endl;
+  }
+}
+
+void FairMCMatchCreatorTask::Finish()
+{
+}
+
+
+ClassImp(FairMCMatchCreatorTask);
diff --git a/datamatch/FairMCMatchCreatorTask.h b/datamatch/FairMCMatchCreatorTask.h
new file mode 100644
index 0000000..503a242
--- /dev/null
+++ b/datamatch/FairMCMatchCreatorTask.h
@@ -0,0 +1,85 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                 FAIRMCMATCHCREATORTASK header file             -----
+// -----                  Created 20/03/07  by R.Kliemt               -----
+// -------------------------------------------------------------------------
+
+
+/** FAIRMCMATCHCREATORTASK.h
+ *@author T.Stockmanns <t.stockmanns@fz-juelich.de>
+ **
+ ** Displays all available informations for a given event
+ **/
+
+
+#ifndef FAIRMCMATCHCREATORTASK_H
+#define FAIRMCMATCHCREATORTASK_H
+
+#include "FairTask.h"                   // for InitStatus, FairTask
+
+#include "Rtypes.h"                     // for Bool_t, etc
+
+#include <map>                          // for map
+#include <string>                       // for string
+
+class FairMCMatch;
+class TClonesArray;
+
+class FairMCMatchCreatorTask : public FairTask
+{
+  public:
+
+    /** Default constructor **/
+    FairMCMatchCreatorTask();
+
+    /** Destructor **/
+    virtual ~FairMCMatchCreatorTask();
+
+
+    /** Virtual method Init **/
+    virtual void SetParContainers();
+    void SetPersistance(Bool_t pers) {fPersistance = pers;}
+    Bool_t GetPersistance() {return fPersistance;}
+
+    virtual InitStatus Init();
+
+
+    /** Virtual method Exec **/
+    virtual void Exec(Option_t* opt);
+
+    virtual void Finish();
+
+    virtual void InitDataStages() = 0;
+
+  protected:
+    FairMCMatch* fMCMatch;
+
+  private:
+
+    std::map<std::string, TClonesArray*> fBranches;
+    Bool_t fPersistance;
+    TClonesArray* fMCLink;//->
+    Int_t fEventNr;
+
+    InitStatus InitBranches();
+
+    void Register();
+
+    void Reset();
+
+    void ProduceHits();
+
+    FairMCMatchCreatorTask(const FairMCMatchCreatorTask&);
+    FairMCMatchCreatorTask& operator=(const FairMCMatchCreatorTask&);
+
+    ClassDef(FairMCMatchCreatorTask,1);
+
+};
+
+#endif
diff --git a/datamatch/FairMCMatchLinkDef.h b/datamatch/FairMCMatchLinkDef.h
new file mode 100644
index 0000000..6b5f764
--- /dev/null
+++ b/datamatch/FairMCMatchLinkDef.h
@@ -0,0 +1,26 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairMCMatch+;
+#pragma link C++ class FairMCMatchCreatorTask+;
+#pragma link C++ class FairMCMatchLoaderTask+;
+#pragma link C++ class FairMCMatchSelectorTask+;
+#pragma link C++ class FairMCEntry+;
+#pragma link C++ class FairMCList+;
+#pragma link C++ class FairMCObject+;
+#pragma link C++ class FairMCStage+;
+#pragma link C++ class FairMCResult+;
+#pragma link C++ class FairMCDataCrawler+;
+
+#endif
+
diff --git a/datamatch/FairMCMatchLoaderTask.cxx b/datamatch/FairMCMatchLoaderTask.cxx
new file mode 100644
index 0000000..654a017
--- /dev/null
+++ b/datamatch/FairMCMatchLoaderTask.cxx
@@ -0,0 +1,141 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                FairMCMatchLoaderTask source file             -----
+// -----                  Created 18/07/08  by T.Stockmanns        -----
+// -------------------------------------------------------------------------
+#include "FairMCMatchLoaderTask.h"
+
+#include "FairMCMatch.h"                // for FairMCMatch
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+#include "TClonesArray.h"               // for TClonesArray
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+// -----   Default constructor   -------------------------------------------
+FairMCMatchLoaderTask::FairMCMatchLoaderTask()
+  : FairTask("Creates FairMCMatch"),
+    fMCMatch(NULL),
+    fMCLink(NULL),
+    fEventNr(0)
+{
+}
+// -------------------------------------------------------------------------
+
+
+// -----   Destructor   ----------------------------------------------------
+FairMCMatchLoaderTask::~FairMCMatchLoaderTask()
+{
+}
+
+// -----   Public method Init   --------------------------------------------
+InitStatus FairMCMatchLoaderTask::Init()
+{
+  fMCMatch = new FairMCMatch("FairMCMatch", "FairMCMatch");
+
+  InitDataStages();
+
+  /*
+  fMCMatch->InitStage("MVDPoint");
+  fMCMatch->InitStage("MVDStripDigis");
+  fMCMatch->InitStage("MVDPixelDigis");
+  fMCMatch->InitStage("MVDHitsPixel");
+  fMCMatch->InitStage("MVDHitsStrip");
+  fMCMatch->InitStage("MVDPixelClusterCand");
+  fMCMatch->InitStage("MVDStripClusterCand");
+
+  fMCMatch->InitStage("EmcCluster");
+  fMCMatch->InitStage("EmcBump");
+  fMCMatch->InitStage("EmcDigi");
+  fMCMatch->InitStage("EmcHit");
+  fMCMatch->InitStage("EmcPoint");
+  fMCMatch->InitStage("EmcRecoHit");
+  fMCMatch->InitStage("EmcSharedDigi");
+  fMCMatch->InitStage("EmcWaveform");
+
+  fMCMatch->InitStage("STTPoint");
+  fMCMatch->InitStage("STTHit");
+  fMCMatch->InitStage("SttHelixHit");
+  fMCMatch->InitStage("STTTrack");
+  fMCMatch->InitStage("STTTrackCand");
+
+  fMCMatch->InitStage("PndTpcPoint");
+  fMCMatch->InitStage("PndTpcPrimaryCluster");
+  fMCMatch->InitStage("PndTpcDriftedElectron");
+  fMCMatch->InitStage("PndTpcAvalanche");
+  fMCMatch->InitStage("PndTpcSignal");
+  fMCMatch->InitStage("PndTpcDigi");
+  fMCMatch->InitStage("PndTpcCluster");
+
+
+  fMCMatch->InitStage("GEMPoint");
+  fMCMatch->InitStage("GEMDigi");
+  fMCMatch->InitStage("GEMHit");
+
+  fMCMatch->InitStage("PndDchPoint");
+  fMCMatch->InitStage("PndDchDigi");
+  fMCMatch->InitStage("PndDchCylinderHit");
+
+  fMCMatch->InitStage("MdtPoint");
+  fMCMatch->InitStage("MdtHit");
+  fMCMatch->InitStage("MdtTrk");
+
+  fMCMatch->InitStage("LheHit");
+  fMCMatch->InitStage("LheCandidate");
+  fMCMatch->InitStage("LheTrack");
+  fMCMatch->InitStage("MVDIdealTrackCand");
+  fMCMatch->InitStage("MVDRiemannTrackCand");
+  //fMCMatch->InitStage("PndTrack");
+  fMCMatch->InitStage("LheGenTrack");
+  fMCMatch->InitStage("PidChargedCand");
+  fMCMatch->InitStage("PidNeutralCand");
+  */
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (!ioman) {
+    std::cout << "-E- FairMCMatchLoaderTask::Init: "
+              << "RootManager not instantiated!" << std::endl;
+    return kFATAL;
+  }
+
+  fMCLink = static_cast<TClonesArray*>(ioman->GetObject("MCLink"));
+  ioman->Register("MCMatch", "MCInfo", fMCMatch, kFALSE);
+
+  return kSUCCESS;
+}
+
+
+// -------------------------------------------------------------------------
+void FairMCMatchLoaderTask::SetParContainers()
+{
+}
+
+
+// -----   Public method Exec   --------------------------------------------
+void FairMCMatchLoaderTask::Exec(Option_t* /*opt*/)
+{
+
+  if (!fMCLink) { Fatal("Exec", "No fMCLink"); }
+  fMCMatch->ClearMCList();
+
+  fMCMatch->LoadInMCLists(fMCLink);
+  fMCMatch->CreateArtificialStage("MCTrack");
+
+  fMCMatch->Print();
+  std::cout << std::endl;
+}
+
+void FairMCMatchLoaderTask::Finish()
+{
+}
+
+
+ClassImp(FairMCMatchLoaderTask);
diff --git a/datamatch/FairMCMatchLoaderTask.h b/datamatch/FairMCMatchLoaderTask.h
new file mode 100644
index 0000000..2babdaf
--- /dev/null
+++ b/datamatch/FairMCMatchLoaderTask.h
@@ -0,0 +1,75 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                 FAIRMCMATCHCREATORTASK header file             -----
+// -----                  Created 20/03/07  by R.Kliemt               -----
+// -------------------------------------------------------------------------
+
+
+/** PNDMCMATCHCREATORTASK.h
+ *@author T.Stockmanns <t.stockmanns@fz-juelich.de>
+ **
+ ** Displays all available informations for a given event
+ **/
+
+
+#ifndef FAIRMCMATCHLOADERTASK_H
+#define FAIRMCMATCHLOADERTASK_H
+
+#include "FairTask.h"                   // for FairTask, InitStatus
+
+#include "Rtypes.h"                     // for ClassDef
+
+class FairMCMatch;
+class TClonesArray;
+
+class FairMCMatchLoaderTask : public FairTask
+{
+  public:
+
+    /** Default constructor **/
+    FairMCMatchLoaderTask();
+
+    /** Destructor **/
+    virtual ~FairMCMatchLoaderTask();
+
+
+    /** Virtual method Init **/
+    virtual void SetParContainers();
+    virtual InitStatus Init();
+
+
+    /** Virtual method Exec **/
+    virtual void Exec(Option_t* opt);
+
+    virtual void Finish();
+
+    virtual void InitDataStages() = 0;
+
+  protected:
+
+    FairMCMatch* fMCMatch;
+
+  private:
+
+    TClonesArray* fMCLink;
+    int fEventNr;
+
+    void Register();
+
+    void Reset();
+
+    void ProduceHits();
+
+    FairMCMatchLoaderTask(const FairMCMatchLoaderTask&);
+    FairMCMatchLoaderTask& operator=(const FairMCMatchLoaderTask&);
+
+    ClassDef(FairMCMatchLoaderTask,1);
+};
+
+#endif
diff --git a/datamatch/FairMCMatchSelectorTask.cxx b/datamatch/FairMCMatchSelectorTask.cxx
new file mode 100644
index 0000000..84792e6
--- /dev/null
+++ b/datamatch/FairMCMatchSelectorTask.cxx
@@ -0,0 +1,121 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                FairMCMatchSelectorTask source file             -----
+// -----                  Created 18/07/08  by T.Stockmanns        -----
+// -------------------------------------------------------------------------
+#include "FairMCMatchSelectorTask.h"
+
+#include "FairMCMatch.h"                // for FairMCMatch
+#include "FairMCResult.h"               // for operator<<
+#include "FairMCStage.h"                // for FairMCStage
+#include "FairRootManager.h"            // for FairRootManager
+
+#include "Riosfwd.h"                    // for ostream
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, ostream, etc
+
+// -----   Default constructor   -------------------------------------------
+FairMCMatchSelectorTask::FairMCMatchSelectorTask()
+  : FairTask("Creates FairMCMatch"),
+    fMCMatch(NULL),
+    fStart(-1),
+    fStop(-1),
+    fStartString(""),
+    fStopString(""),
+    fStageWeights(),
+    fCommonWeight(0)
+{
+}
+// -------------------------------------------------------------------------
+
+FairMCMatchSelectorTask::FairMCMatchSelectorTask(TString start, TString stop)
+  : FairTask("Creates FairMCMatch"),
+    fMCMatch(NULL),
+    fStart(-1),
+    fStop(-1),
+    fStartString(start),
+    fStopString(stop),
+    fStageWeights(),
+    fCommonWeight(0)
+{
+}
+
+FairMCMatchSelectorTask::FairMCMatchSelectorTask(Int_t start, Int_t stop)
+  : FairTask("Creates FairMCMatch"),
+    fMCMatch(NULL),
+    fStart(start),
+    fStop(stop),
+    fStartString(""),
+    fStopString(""),
+    fStageWeights(),
+    fCommonWeight(0)
+{
+}
+
+// -----   Destructor   ----------------------------------------------------
+FairMCMatchSelectorTask::~FairMCMatchSelectorTask()
+{
+}
+
+// -----   Public method Init   --------------------------------------------
+InitStatus FairMCMatchSelectorTask::Init()
+{
+
+  FairRootManager* ioman = FairRootManager::Instance();
+  if (!ioman) {
+    std::cout << "-E- FairMCMatchSelectorTask::Init: "
+              << "RootManager not instantiated!" << std::endl;
+    return kFATAL;
+  }
+
+  fMCMatch = static_cast<FairMCMatch*>(ioman->GetObject("MCMatch"));
+  if (fStart < 0 && fStop < 0) {
+    fStart = ioman->GetBranchId(fStartString);
+    fStop = ioman->GetBranchId(fStopString);
+    std::cout << fStartString << ": " << fStart << " / " << fStopString << ": " << fStop << std::endl;
+  }
+
+  std::cout << "-I- FairMCMatchSelectorTask::Init: Initialization successfull" << std::endl;
+
+
+  return kSUCCESS;
+}
+
+
+// -------------------------------------------------------------------------
+void FairMCMatchSelectorTask::SetParContainers()
+{
+}
+
+
+// -----   Public method Exec   --------------------------------------------
+void FairMCMatchSelectorTask::Exec(Option_t* /*opt*/)
+{
+  std::cout << "Output Selector: " << std::endl;
+  SetWeights();
+  fMCMatch->CreateArtificialStage("MCTrack");
+  std::cout << fMCMatch->GetMCInfo(fStart, fStop);
+  std::cout << std::endl;
+}
+
+void FairMCMatchSelectorTask::SetWeights()
+{
+  fMCMatch->SetCommonWeightStages(fCommonWeight);
+  for (unsigned int i = 0; i < fStageWeights.size(); i++) {
+    fMCMatch->GetMCStageType(fStageWeights[i].first)->SetWeight(fStageWeights[i].second);
+  }
+}
+
+void FairMCMatchSelectorTask::Finish()
+{
+}
+
+
+ClassImp(FairMCMatchSelectorTask);
diff --git a/datamatch/FairMCMatchSelectorTask.h b/datamatch/FairMCMatchSelectorTask.h
new file mode 100644
index 0000000..04bff93
--- /dev/null
+++ b/datamatch/FairMCMatchSelectorTask.h
@@ -0,0 +1,93 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+// -------------------------------------------------------------------------
+// -----                 FAIRMCMATCHSELECTORTASK header file             -----
+// -----                  Created 18/01/10  by T.Stockmanns             -----
+// -------------------------------------------------------------------------
+
+
+/** FAIRMCMATCHSELECTORTASK.h
+ *@author T.Stockmanns <t.stockmanns@fz-juelich.de>
+ **
+ ** Displays all available informations for a given event
+ **/
+
+
+#ifndef FAIRMCMATCHSELECTORTASK_H
+#define FAIRMCMATCHSELECTORTASK_H
+
+#include "FairTask.h"                   // for FairTask, InitStatus
+
+#include "Rtypes.h"                     // for Int_t, Float_t, etc
+#include "TString.h"                    // for TString
+
+#include <utility>                      // for pair
+#include <vector>                       // for vector
+
+class FairMCMatch;
+
+class FairMCMatchSelectorTask : public FairTask
+{
+  public:
+
+    /** Default constructor **/
+    FairMCMatchSelectorTask();
+
+    FairMCMatchSelectorTask(TString start, TString stop);
+
+    FairMCMatchSelectorTask(Int_t start, Int_t stop);
+
+    /** Destructor **/
+    virtual ~FairMCMatchSelectorTask();
+
+
+    /** Virtual method Init **/
+    virtual void SetParContainers();
+    virtual InitStatus Init();
+
+
+    /** Virtual method Exec **/
+    virtual void Exec(Option_t* opt);
+
+    virtual void Finish();
+
+    virtual void SetStart(Int_t type) {fStart = type;}
+    virtual void SetStop(Int_t type) {fStop = type;}
+
+    virtual void SetAllWeights(Float_t weight) {fCommonWeight = weight;}
+    virtual void SetWeightStage(Int_t type, Float_t weight) {
+      fStageWeights.push_back(std::pair<Int_t, Float_t>(static_cast<Int_t>(type), weight));
+    }
+
+    virtual void SetWeights();
+
+  private:
+    FairMCMatch* fMCMatch;
+    Int_t fStart;
+    Int_t fStop;
+
+    TString fStartString;
+    TString fStopString;
+
+    std::vector<std::pair<Int_t, Float_t> > fStageWeights;
+    Float_t fCommonWeight;
+
+    void Register();
+
+    void Reset();
+
+    void ProduceHits();
+
+    FairMCMatchSelectorTask(const FairMCMatchSelectorTask&);
+    FairMCMatchSelectorTask& operator=(const FairMCMatchSelectorTask&);
+
+    ClassDef(FairMCMatchSelectorTask,1);
+
+};
+
+#endif
diff --git a/datamatch/FairMCObject.cxx b/datamatch/FairMCObject.cxx
new file mode 100644
index 0000000..f4e69f4
--- /dev/null
+++ b/datamatch/FairMCObject.cxx
@@ -0,0 +1,102 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCObject.cpp
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCObject.h"
+
+ClassImp(FairMCObject);
+
+FairMCObject::FairMCObject()
+  : TObject(),
+    fStage(0),
+    fStageId()
+{
+}
+
+FairMCObject::~FairMCObject()
+{
+}
+
+void FairMCObject::SetEntry(FairMCEntry entry)
+{
+  if (entry.GetPos() < 0) {
+    std::cout << "-E- FairMCObject::SetEntry(FairMCEntry): pos " << entry.GetPos() << std::endl;
+    return;
+  }
+  AdoptSize(entry.GetPos());
+  fStage[entry.GetPos()] = entry;
+}
+
+void FairMCObject::SetEntry(std::vector<Int_t> type, std::vector<Int_t> link, int index)
+{
+  FairMCEntry myEntry;
+  myEntry.SetPos(index);
+  myEntry.SetPersistanceCheck(kFALSE);
+  for (unsigned int i = 0; i < type.size(); i++) {
+    myEntry.AddLink(FairLink(type[i],link[i]));
+  }
+  SetEntry(myEntry);
+}
+
+void FairMCObject::SetEntry(FairMultiLinkedData* data, int index)
+{
+  AdoptSize(index);
+  fStage[index].SetLinks(data->GetLinks());
+}
+
+void FairMCObject::SetLink(FairLink link, int index)
+{
+  if (index < static_cast<int>(fStage.size())) {
+    fStage[index].ResetLinks();
+  }
+  AddLink(link, index);
+}
+
+
+void FairMCObject::AddLink(FairLink link, int index)
+{
+  AdoptSize(index);
+  fStage[index].AddLink(link);
+}
+
+void FairMCObject::AdoptSize(int index)
+{
+  int start = fStage.size();
+  while ( static_cast<int>(fStage.size()) < index+1) {
+    FairMCEntry myVec;
+    myVec.SetPos(fStage.size());
+    myVec.SetSource(GetStageId());
+    myVec.SetPersistanceCheck(kFALSE);
+    fStage.push_back(myVec);
+    start++;
+  }
+}
+
+FairMultiLinkedData FairMCObject::PosInList(FairLink link)
+{
+  FairMultiLinkedData result;
+  result.SetPersistanceCheck(kFALSE);
+  for (unsigned int i = 0; i < fStage.size(); i++) {
+    if (fStage[i].IsLinkInList(link.GetType(), link.GetIndex())) {
+      result.AddLink(FairLink(GetStageId(), i));
+    }
+  }
+  return result;
+}
+
+void FairMCObject::RemoveType(Int_t type)
+{
+  for (unsigned int i = 0; i < fStage.size(); i++) {
+    fStage[i].RemoveType(type);
+  }
+}
diff --git a/datamatch/FairMCObject.h b/datamatch/FairMCObject.h
new file mode 100644
index 0000000..91eb37a
--- /dev/null
+++ b/datamatch/FairMCObject.h
@@ -0,0 +1,133 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCStage.h
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCOBJECT_H_
+#define FAIRMCOBJECT_H_
+
+#include "TObject.h"                    // for TObject
+
+#include "FairLink.h"                   // for FairLink
+#include "FairMCEntry.h"                // for FairMCEntry
+#include "FairMultiLinkedData.h"        // for FairMultiLinkedData
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, FairMCObject::Class, etc
+
+#include <iostream>                     // for ostream, etc
+#include <utility>                      // for pair
+#include <vector>                       // for vector
+
+class FairMCObject: public TObject
+{
+  public:
+    FairMCObject();
+    FairMCObject(Int_t type)
+      : TObject(),
+        fStage(),
+        fStageId(type)
+        {
+        }	
+    FairMCObject(const FairMCObject& obj)
+      : TObject(obj),
+        fStage(obj.GetEntryVector()), 
+        fStageId(obj.GetStageId())
+        {
+        }
+    FairMCObject(Int_t type, std::vector<FairMCEntry> stage)
+      : TObject(),
+        fStage(stage),
+        fStageId(type) 
+        {
+        }
+
+    FairMCObject& operator=(const FairMCObject& from) {
+      if (this == &from) { return *this; }
+
+      TObject::operator=(from);
+      fStage=from.fStage;
+      fStageId=from.fStageId;
+
+      return *this;
+    }
+
+    virtual ~FairMCObject();
+
+    void SetStageId(Int_t type) {fStageId = type;}
+
+    void SetEntry(std::vector<Int_t> type, std::vector<Int_t> link, int index);
+    void SetEntry(FairMultiLinkedData* data, int index);
+    void SetEntry(FairMCEntry link);
+
+    void SetStage(std::vector<FairMCEntry> stage) {fStage = stage;}
+    void SetLink(FairLink link, int index);
+    void AddLink(FairLink link, int index);
+
+    FairMCEntry GetEntry(int index) const {return fStage[index];}
+    FairLink  GetSingleLink(int entryIndex, int linkIndex) const {
+      return fStage.at(entryIndex).GetLink(linkIndex);
+    }
+
+    Int_t GetStageId(void) const {return fStageId;}
+
+    FairMCEntry GetMCLink(Int_t index) {return fStage.at(index);}
+
+    int GetNEntries() const {return fStage.size();}
+    int GetNLinks(int entryIndex)const {return fStage.at(entryIndex).GetNLinks();}
+    std::vector<FairMCEntry> GetEntryVector() const {return fStage;}
+
+    FairMultiLinkedData PosInList(std::pair<int, int> link);
+    FairMultiLinkedData PosInList(FairLink link);
+
+    FairMultiLinkedData GetLinksWithType(Int_t type) {
+      FairMultiLinkedData result;
+      for (int i = 0; i < GetNEntries(); i++) {
+        result.AddLinks(GetMCLink(i).GetLinksWithType(type));
+      }
+      return result;
+    }
+
+    void RemoveType(Int_t type);
+
+    virtual void ClearEntries() {fStage.clear();}
+
+    virtual void PrintInfo(std::ostream& out = std::cout) {out << *this;}
+
+    /*
+        void operator=(const FairMCObject& obj) {
+          fStageId = obj.GetStageId();
+          fStage = obj.GetEntryVector();
+        }
+    */
+
+    friend std::ostream& operator<< (std::ostream& out, const FairMCObject& obj) {
+      std::vector<FairMCEntry> stages = obj.GetEntryVector();
+      for (unsigned int i = 0; i < stages.size(); i++) {
+        if (stages[i].GetNLinks() > 0) {
+          out << i << ": ";
+          stages[i].PrintInfo(out);
+          out << std::endl;
+        }
+      }
+      return out;
+    }
+
+  private:
+    void AdoptSize(int index);
+    std::vector<FairMCEntry> fStage;
+    Int_t fStageId;
+
+    ClassDef(FairMCObject, 0);
+};
+
+#endif /* PNDMCOBJECT_H_ */
diff --git a/datamatch/FairMCResult.cxx b/datamatch/FairMCResult.cxx
new file mode 100644
index 0000000..9017bbb
--- /dev/null
+++ b/datamatch/FairMCResult.cxx
@@ -0,0 +1,36 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCResult.cpp
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCResult.h"
+
+ClassImp(FairMCResult);
+
+FairMCResult::FairMCResult()
+  : FairMCObject(),
+    fStartType(-1),
+    fStopType(-1)
+{
+}
+
+FairMCResult::~FairMCResult()
+{
+}
+
+FairMCResult::FairMCResult(Int_t start, Int_t stop)
+  : FairMCObject(),
+    fStartType(start),
+    fStopType(stop)
+{
+}
+
diff --git a/datamatch/FairMCResult.h b/datamatch/FairMCResult.h
new file mode 100644
index 0000000..7569716
--- /dev/null
+++ b/datamatch/FairMCResult.h
@@ -0,0 +1,75 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCResult.h
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCRESULT_H_
+#define FAIRMCRESULT_H_
+
+#include "FairMCObject.h"               // for FairMCObject
+
+#include "FairMCEntry.h"                // for FairMCEntry
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Int_t, FairMCResult::Class, etc
+
+#include <iostream>                     // for operator<<, ostream, etc
+
+class FairMCResult: public FairMCObject
+{
+  public:
+    FairMCResult();
+    FairMCResult(Int_t start, Int_t stop);
+
+    FairMCResult(const FairMCResult& result)
+      : FairMCObject(result.GetStartType(), result.GetEntryVector()),
+        fStartType(result.GetStartType()),
+        fStopType(result.GetStopType()) {
+    }
+
+
+    FairMCResult& operator=(const FairMCResult& result) {
+
+      if (this == &result) { return *this; }
+
+      FairMCObject::operator=(result);
+      fStartType = result.fStartType;
+      fStopType = result.fStopType;
+
+      return *this;
+    }
+
+    virtual ~FairMCResult();
+
+    void SetStartType(Int_t start) {fStartType = start;}
+    void SetStopType(Int_t stop) {fStopType = stop;}
+
+    Int_t GetStartType(void) const {return fStartType;}
+    Int_t GetStopType(void) const {return fStopType;}
+
+    virtual void PrintInfo(std::ostream& out = std::cout) { out << *this;}
+
+    friend std::ostream& operator<< (std::ostream& out, const FairMCResult& result) {
+      out << "MC Link from: " << result.GetStartType() << " to "  << result.GetStopType() << ":" << std::endl;
+      (static_cast<FairMCObject>(result)).PrintInfo(out);
+      return out;
+    }
+
+
+  private:
+    Int_t fStartType;
+    Int_t fStopType;
+
+    ClassDef(FairMCResult, 2);
+};
+
+#endif /* FairMCResult_H_ */
diff --git a/datamatch/FairMCStage.cxx b/datamatch/FairMCStage.cxx
new file mode 100644
index 0000000..c071106
--- /dev/null
+++ b/datamatch/FairMCStage.cxx
@@ -0,0 +1,42 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCStage.cpp
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#include "FairMCStage.h"
+
+ClassImp(FairMCStage);
+
+FairMCStage::FairMCStage()
+  : FairMCObject(),
+    fBranchName(""),
+    fFileName(""),
+    fWeight(1.0),
+    fLoaded(kFALSE),
+    fFill(kFALSE)
+{
+}
+
+FairMCStage::~FairMCStage()
+{
+}
+
+FairMCStage::FairMCStage(Int_t id, std::string fileName, std::string branchName, Double_t weight)
+  : FairMCObject(id),
+    fBranchName(branchName),
+    fFileName(fileName),
+    fWeight(weight),
+    fLoaded(kFALSE),
+    fFill(kFALSE)
+{
+}
+
diff --git a/datamatch/FairMCStage.h b/datamatch/FairMCStage.h
new file mode 100644
index 0000000..92455b8
--- /dev/null
+++ b/datamatch/FairMCStage.h
@@ -0,0 +1,94 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMCStage.h
+ *
+ *  Created on: Dec 1, 2009
+ *      Author: stockman
+ */
+
+#ifndef FAIRMCSTAGE_H_
+#define FAIRMCSTAGE_H_
+
+#include "FairMCObject.h"               // for FairMCObject
+
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Bool_t, Double_t, etc
+
+#include <iostream>                     // for ostream, basic_ostream, etc
+#include <string>                       // for string, operator<<, etc
+
+class FairMCStage: public FairMCObject
+{
+  public:
+    FairMCStage();
+    FairMCStage(Int_t id, std::string fileName, std::string branchName, Double_t weight = 1.0);
+
+    FairMCStage(const FairMCStage& mcStage)
+      : FairMCObject(mcStage),
+        fBranchName(mcStage.fBranchName),
+        fFileName(mcStage.fFileName),
+        fWeight(mcStage.fWeight),
+        fLoaded(mcStage.fLoaded),
+        fFill(mcStage.fFill) {
+    }
+
+    FairMCStage& operator=(const FairMCStage& result) {
+
+      if (this == &result) { return *this; }
+
+      FairMCObject::operator=(result);
+      fBranchName = result.fBranchName;
+      fFileName = result.fFileName;
+      fWeight = result.fWeight;
+      fLoaded = result.fLoaded;
+      fFill = result.fFill;
+
+      return *this;
+    }
+
+
+
+    virtual ~FairMCStage();
+
+    void SetBranchName(std::string branchName)  { fBranchName = branchName; }
+    void SetFileName(std::string fileName)      { fFileName = fileName; }
+    void SetWeight(Double_t weight)       { fWeight = weight; }
+    void SetLoaded(Bool_t loaded)         { fLoaded = loaded; }
+    void SetFill(Bool_t fill)           { fFill = fill; }
+
+    std::string GetBranchName(void)   const {return fBranchName;}
+    std::string GetFileName(void)     const {return fFileName;}
+    Double_t  GetWeight(void)     const {return fWeight;}
+    Bool_t    GetLoaded(void)   const {return fLoaded;}
+    Bool_t    GetFill(void)     const {return fFill;}
+
+    virtual void ClearEntries() {
+      FairMCObject::ClearEntries();
+      fLoaded = kFALSE;
+    }
+
+    virtual void PrintInfo(std::ostream& out) {out << *this;}
+
+    friend std::ostream& operator<< (std::ostream& out, const FairMCStage& stage) {
+      out << stage.GetStageId() << ": " << stage.GetBranchName() << " // " <<  stage.GetFileName() << std::endl; //" with weight: " << stage.GetWeight() << std::endl;
+      (static_cast<FairMCObject>(stage)).PrintInfo(out);
+      return out;
+    }
+
+  private:
+    std::string fBranchName;
+    std::string fFileName;
+    Double_t fWeight;
+    Bool_t fLoaded; ///< indicates if this stage was loaded already from a Link file
+    Bool_t fFill; ///< indicates if a corresponding DataFile with FairLinks exists to fill this stage
+
+    ClassDef(FairMCStage, 1);
+};
+
+#endif /* PNDMCSTAGE_H_ */
diff --git a/datamatch/FairMCTrackEnumAssociator.h b/datamatch/FairMCTrackEnumAssociator.h
new file mode 100644
index 0000000..867ccb9
--- /dev/null
+++ b/datamatch/FairMCTrackEnumAssociator.h
@@ -0,0 +1,86 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+#ifndef MCTRACKENUMASSOCIATOR_H
+#define MCTRACKENUMASSOCIATOR_H
+
+// *************************************************************************
+//  Author: Stefano Spataro            e-mail: spataro@to.infn.it
+//
+//  take all hits from tracks and create the corresponding PndTrackID object
+//
+// Created: 27-06-11
+// Modified: Stefano Spataro
+//
+// *************************************************************************
+
+#include "TClonesArray.h"
+
+#include "FairTask.h"
+
+#include "PndTrackID.h"
+
+
+class PndMCTrackEnumAssociator : public FairTask
+{
+
+  public:
+
+    PndMCTrackEnumAssociator(const char* name, const char* title="PND Task");
+    PndMCTrackEnumAssociator();
+    virtual ~PndMCTrackEnumAssociator();
+
+    virtual InitStatus Init();              //
+    virtual void Exec(Option_t* option);    //
+    void Register();
+
+    Int_t GetMvdHitPixels(Int_t index);     // from the MVD pixel index retrns the Pndrack index
+    Int_t GetMvdHitStrips(Int_t index);     // from the MVD strip hit index retrns the Pndrack index
+    Int_t GetSttHits(Int_t index);     // from the STT hit index retrns the Pndrack index
+    Int_t GetGemHits(Int_t index);     // from the GEM hit index retrns the Pndrack index
+    Int_t GetFtsHits(Int_t index);     // from the FTS hit index retrns the Pndrack index
+
+
+    // Modifiers -----------------------
+    void SetTrackInBranchName(const TString& name)   { fTrackInBranchName = name;  }
+    void SetTrackOutBranchName(const TString& name)  { fTrackOutBranchName = name; }
+
+    void SetOption(Option_t* option=" ") {fOption = option;  fOption.ToLower();}
+
+    void SetVerbose(Bool_t verb)                     {  fVerbose       = verb ;};
+    void SetPersistence(Bool_t pers)                 {  fPersistence   = pers ;};
+
+  protected:
+
+    TString fTrackInBranchName;      //! Name of the input TCA
+    TString fTrackOutBranchName;     //! Name of the output TCA
+
+    TClonesArray*  fTpcInput;             //! pointers to TPC TCA
+    TClonesArray*  fSttHitInput;          //! pointers to STT Hit TCA
+    TClonesArray*  fMvdMCArray;           //!
+    TClonesArray*  fMvdStripHitArray;     //!
+    TClonesArray*  fMvdPixelHitArray;     //!
+    TClonesArray*  fMvdStripClusterArray; //!
+    TClonesArray*  fMvdPixelClusterArray; //!
+    TClonesArray*  fMvdStripDigiArray;    //!
+    TClonesArray*  fMvdPixelDigiArray;    //!
+    TClonesArray*  fGemMCArray;           //! pointers to GEMPoint TCA
+    TClonesArray*  fGemInput;             //! pointers to GEMHit TCA
+    TClonesArray*  fFtsMCArray;           //! pointers to FtsPoint TCA
+    TClonesArray*  fFtsInput;             //! pointers to FtsHit TCA
+
+    TClonesArray*  fTrackIDArray;         //! pointers to PndTrackID (output)
+    TClonesArray*  fTrackArray;           //! pointers to PndTrack (input)
+
+    Bool_t fVerbose;             // Switch ON/OFF debug messages        (defaulf OFF)
+    Bool_t fPersistence;         // Persistence of LheHit/LheGeantTrack (default ON)
+
+    ClassDef(PndMCTrackEnumAssociator,1)      // PndMCTrackEnumAssociator
+
+};
+
+#endif
diff --git a/datamatch/README.md b/datamatch/README.md
new file mode 100644
index 0000000..e0fbabf
--- /dev/null
+++ b/datamatch/README.md
@@ -0,0 +1,14 @@
+datamatch
+========
+
+Classes responsibles for the data matching.
+
+Each of the analysis tasks is producing some data from another data.
+In order to compare the analysis results on any level with the simulated
+Monte Carlo input (or with any previous analysis step).
+
+This functionality is performed with the help of `FairLink`s, where
+for every created data object a list of `FairLink`s is created, pointing to
+all of the data used to create that very data object, with the pointers to the event number, data's array and data's position in that array. With this information it is possible to compare the reconstructed data with the simulated one.
+
+
diff --git a/dch/CMakeLists.txt b/dch/CMakeLists.txt
index b2142ee..aa5932e 100644
--- a/dch/CMakeLists.txt
+++ b/dch/CMakeLists.txt
@@ -6,21 +6,20 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/dch
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(Dch_SRCS
 MpdDchGeo.cxx 
diff --git a/emc/CMakeLists.txt b/emc/CMakeLists.txt
index 3f26eae..b33cc26 100644
--- a/emc/CMakeLists.txt
+++ b/emc/CMakeLists.txt
@@ -3,11 +3,15 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/emc 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/clustering
@@ -15,13 +19,13 @@ ${CMAKE_SOURCE_DIR}/emc/hitmaker
 ${CMAKE_SOURCE_DIR}/emc/clustering
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 ) 
 
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(MPDEMC_SRCS
 MpdEmcContFact.cxx
diff --git a/etof/CMakeLists.txt b/etof/CMakeLists.txt
index 98ef53b..9cfbaf0 100644
--- a/etof/CMakeLists.txt
+++ b/etof/CMakeLists.txt
@@ -3,11 +3,15 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/tof
@@ -16,13 +20,13 @@ ${CMAKE_SOURCE_DIR}/lhetrack
 ${CMAKE_SOURCE_DIR}/etof
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(ETOF_SRCS
 MpdEtofGeo.cxx
diff --git a/etof/MpdEtofHitProducerIdeal.cxx b/etof/MpdEtofHitProducerIdeal.cxx
index 4bc040c..5d6aae5 100644
--- a/etof/MpdEtofHitProducerIdeal.cxx
+++ b/etof/MpdEtofHitProducerIdeal.cxx
@@ -12,6 +12,7 @@
 #include "TClonesArray.h"
 
 #include "FairRootManager.h"
+#include "FairLogger.h"
 
 #include "MpdTofUtils.h"
 #include "MpdTofHit.h"
diff --git a/eventdisplay/CMakeLists.txt b/eventdisplay/CMakeLists.txt
index 79ba582..02689b4 100644
--- a/eventdisplay/CMakeLists.txt
+++ b/eventdisplay/CMakeLists.txt
@@ -1,31 +1,28 @@
 # Create a library called "libEventDisplay" 
-# 06.12.07  M. Al-Turany
-
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${GEANT3_INCLUDE_DIR}
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base
-${CMAKE_SOURCE_DIR}/gconfig
-${CMAKE_SOURCE_DIR}/trackbase 
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
 ${CMAKE_SOURCE_DIR}/geane
-${CMAKE_SOURCE_DIR}/mcstack
-${CMAKE_SOURCE_DIR}/mpddata
-${CMAKE_SOURCE_DIR}/kalman
-${CMAKE_SOURCE_DIR}/tpc
-${CMAKE_SOURCE_DIR}/lhetrack
+${CMAKE_SOURCE_DIR}/config
+${CMAKE_SOURCE_DIR}/fairtools
+${CMAKE_SOURCE_DIR}/geobase
+${CMAKE_SOURCE_DIR}/parbase
 ${CMAKE_SOURCE_DIR}/eventdisplay
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+  ${Boost_INCLUDE_DIRS}
+  ${GEANT3_INCLUDE_DIR}
+  ${XML2_INCLUDE_DIR}
+)
 
 set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+  ${ROOT_LIBRARY_DIR}
+  ${XML2_LIBRARY_DIR}
 )
- 
-link_directories( ${LINK_DIRECTORIES})
 
 set(SRCS
 FairEventManager.cxx  
@@ -41,12 +38,97 @@ FairMCPointDraw.cxx
 FairHitDraw.cxx
 FairHitPointSetDraw.cxx
 FairTimeStampPointDraw.cxx
-MpdTrackDraw.cxx
+FairWebScreenshots.cxx
 )
 
-Set(HEADERS )
-Set(LINKDEF EventDisplayLinkDef.h)
+if (BMNROOT)
+  Set(INCLUDE_DIRECTORIES
+    ${INCLUDE_DIRECTORIES} 
+    ${CMAKE_SOURCE_DIR}/eventdisplay/raw
+    ${CMAKE_SOURCE_DIR}/bmndata
+    ${CMAKE_SOURCE_DIR}/globaltracking
+    ${CMAKE_SOURCE_DIR}/gem
+  )
+  Set(SRCS
+    ${SRCS}
+    raw/RawDataParser.cxx
+    raw/RawDataConverter.cxx
+    raw/RawMWPCDigitDraw.cxx
+    bmn/BmnDigitDraw.cxx
+    bmn/BmnTrackDrawH.cxx
+    bmn/BmnTrackDrawP.cxx
+    bmn/BmnGlobalTrackDraw.cxx
+    bmn/FairMCModuleDraw.cxx
+  )
+endif (BMNROOT)
+
+if (MPDROOT)
+  Set(INCLUDE_DIRECTORIES
+    ${INCLUDE_DIRECTORIES}
+    ${CMAKE_SOURCE_DIR}/mcstack
+    ${CMAKE_SOURCE_DIR}/mpddata
+    ${CMAKE_SOURCE_DIR}/kalman
+    ${CMAKE_SOURCE_DIR}/tpc
+    ${CMAKE_SOURCE_DIR}/lhetrack
+    ${CMAKE_SOURCE_DIR}/emc
+    ${CMAKE_SOURCE_DIR}/zdc
+  )
+  Set(SRCS
+    ${SRCS}
+    mpd/MpdGlobalTrackDraw.cxx
+    mpd/MpdEmcTowerDraw.cxx
+    mpd/MpdZdcTowerDraw.cxx
+  )
+endif (MPDROOT)
+
+if (TDAQ_FOUND)
+  Set(SYSTEM_INCLUDE_DIRECTORIES
+    ${SYSTEM_INCLUDE_DIRECTORIES} 
+    ${TDAQ_INCLUDE_PATH}
+  )
+  Set(LINK_DIRECTORIES
+    ${LINK_DIRECTORIES} 
+    ${TDAQ_LIBRARY_PATH}
+  )
+  Set(SRCS
+    ${SRCS} 
+    #tdaq/BmnEventMonitor.cxx
+  )
+endif (TDAQ_FOUND)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
+
+link_directories(${LINK_DIRECTORIES})
+
+Set(HEADERS)
+if (BMNROOT)
+ if (TDAQ_FOUND)
+  Set(LINKDEF bmn/EventBDLinkDef.h)
+ else (TDAQ_FOUND)
+  Set(LINKDEF bmn/EventBLinkDef.h)
+ endif (TDAQ_FOUND)
+else (BMNROOT)
+ if (MPDROOT)
+  if (TDAQ_FOUND)
+   Set(LINKDEF mpd/EventMDLinkDef.h)
+  else (TDAQ_FOUND)
+   Set(LINKDEF mpd/EventMLinkDef.h)
+  endif (TDAQ_FOUND)
+ else (MPDROOT)
+  if (TDAQ_FOUND)
+   Set(LINKDEF tdaq/EventDLinkDef.h)
+  else (TDAQ_FOUND)
+   Set(LINKDEF EventDisplayLinkDef.h)
+  endif (TDAQ_FOUND)
+ endif (MPDROOT)
+endif (BMNROOT)
 Set(LIBRARY_NAME EventDisplay)
-Set(DEPENDENCIES Base Eve Geom EG Physics Ged Gui Graf3d Tree Cint Core)
+
+#if (TDAQ_FOUND)
+#  Set(DEPENDENCIES Base Eve Geom EG Physics Ged Gui Graf3d Tree Cint Core xml2 emon emon-dal cmdline ipc owl omniORB4 omnithread ers)
+#else (TDAQ_FOUND)
+  Set(DEPENDENCIES Base Eve Geom EG Physics Ged Gui Graf3d Tree Cint Core xml2)
+#endif (TDAQ_FOUND)
 
 GENERATE_LIBRARY()
diff --git a/eventdisplay/EventDisplayLinkDef.h b/eventdisplay/EventDisplayLinkDef.h
index 25268e6..44d61df 100644
--- a/eventdisplay/EventDisplayLinkDef.h
+++ b/eventdisplay/EventDisplayLinkDef.h
@@ -4,22 +4,21 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class  FairEventManager;
-#pragma link C++ class  FairMCTracks;
-#pragma link C++ class  FairMCStack;
-#pragma link C++ class  FairMCTracksEditor;
-#pragma link C++ class  FairEventManagerEditor;
-#pragma link C++ class  FairBoxSetDraw;
-#pragma link C++ class  FairPointSetDraw;
-#pragma link C++ class  FairHitDraw;
-#pragma link C++ class  FairBoxSet;
-#pragma link C++ class  FairBoxSetEditor;
-#pragma link C++ class  FairHitPointSetDraw;
-#pragma link C++ class  FairMCPointDraw;
-#pragma link C++ class  FairTimeStampPointDraw;
-#pragma link C++ class  MpdTrackDraw;
-
-
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairMCModuleDraw;
+#pragma link C++ class FairWebScreenshots;
 
 #endif
 
diff --git a/eventdisplay/FairBoxSet.cxx b/eventdisplay/FairBoxSet.cxx
index 05a5eef..98fdbbf 100644
--- a/eventdisplay/FairBoxSet.cxx
+++ b/eventdisplay/FairBoxSet.cxx
@@ -5,6 +5,7 @@
 
 #include "FairBoxSet.h"
 
+
 // -----   Standard constructor   ------------------------------------------
 FairBoxSet::FairBoxSet(FairBoxSetDraw* drawer, const char* name, const char* t)
   : TEveBoxSet(name, t), fDraw(drawer)
diff --git a/eventdisplay/FairBoxSetDraw.cxx b/eventdisplay/FairBoxSetDraw.cxx
index 2f598be..83c2936 100644
--- a/eventdisplay/FairBoxSetDraw.cxx
+++ b/eventdisplay/FairBoxSetDraw.cxx
@@ -34,9 +34,9 @@ FairBoxSetDraw::FairBoxSetDraw()
     fEventManager(NULL),
     fManager(NULL),
     fq(NULL),
-    fX(1.),
-    fY(1.),
-    fZ(1.),
+    fX(0.3),
+    fY(0.3),
+    fZ(0.3),
     fTimeWindowPlus(0.),
     fTimeWindowMinus(0.),
     fStartTime(0.),
@@ -57,9 +57,9 @@ FairBoxSetDraw::FairBoxSetDraw(const char* name, Int_t iVerbose)
     fEventManager(NULL),
     fManager(NULL),
     fq(NULL),
-    fX(1.),
-    fY(1.),
-    fZ(1.),
+    fX(0.3),
+    fY(0.3),
+    fZ(0.3),
     fTimeWindowPlus(0.),
     fTimeWindowMinus(0.),
     fStartTime(0.),
@@ -151,10 +151,10 @@ Int_t FairBoxSetDraw::GetValue(TObject* obj, Int_t i)
 FairBoxSet* FairBoxSetDraw::CreateBoxSet()
 {
   FairBoxSet* aBoxSet = new FairBoxSet(this, GetName());
-  aBoxSet->Reset(FairBoxSet::kBT_AABoxFixedDim, kFALSE, 32);
-  aBoxSet->SetDefWidth(0.3);
-  aBoxSet->SetDefHeight(0.3);
-  aBoxSet->SetDefDepth(0.3);
+  aBoxSet->Reset(FairBoxSet::kBT_AABoxFixedDim, kFALSE, 64);
+  aBoxSet->SetDefWidth(fX);
+  aBoxSet->SetDefHeight(fY);
+  aBoxSet->SetDefDepth(fZ);
   fq = aBoxSet;
 
   return aBoxSet;
diff --git a/eventdisplay/FairBoxSetEditor.h b/eventdisplay/FairBoxSetEditor.h
index 8ee3bbb..399fd93 100644
--- a/eventdisplay/FairBoxSetEditor.h
+++ b/eventdisplay/FairBoxSetEditor.h
@@ -43,8 +43,10 @@ class FairBoxSetEditor : public TGedFrame
 
     virtual void SetModel(TObject* obj) {
       fM = dynamic_cast<FairBoxSet*>(obj);
-      fTimeWindowPlus->SetNumber(fM->GetTimeWindowPlus());
-      fTimeWindowMinus->SetNumber(fM->GetTimeWindowMinus());
+      if (fM) {
+        fTimeWindowPlus->SetNumber(fM->GetTimeWindowPlus());
+        fTimeWindowMinus->SetNumber(fM->GetTimeWindowMinus());
+      }
     }
 
     virtual void TimeWindow();
diff --git a/eventdisplay/FairEventManager.cxx b/eventdisplay/FairEventManager.cxx
index 8c6adef..6256ff1 100644
--- a/eventdisplay/FairEventManager.cxx
+++ b/eventdisplay/FairEventManager.cxx
@@ -1,25 +1,38 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //______________________________________________________________________________
 /** FairEventManager
 *  class for event management and navigation.
 *  M. Al-Turany 06.12.2007
 **/
 #include "FairEventManager.h"
+#include "constants.h"
 
-#include "FairRootManager.h"            // for FairRootManager
-#include "FairRunAna.h"                 // for FairRunAna
-
-#include "TDatabasePDG.h"               // for TDatabasePDG
-#include "TEveGeoNode.h"                // for TEveGeoTopNode
-#include "TEveManager.h"                // for TEveManager, gEve
-#include "TGeoManager.h"                // for gGeoManager, TGeoManager
+#include "FairMCPointDraw.h"
+#include "FairMCTracks.h"
+#include "FairHitPointSetDraw.h"
 
+#include "TDatabasePDG.h"
+#include "TEveGeoNode.h"
+#include "TEveManager.h"
+#include "TGeoManager.h"
+#include <TGLViewer.h>
 #include <TGLCameraOverlay.h>
 #include <TGLLightSet.h>
 #include <TEveProjectionAxes.h>
 #include <TEveBrowser.h>
 
-#include "constants.h"
-
+// XML
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xmlschemastypes.h>
+#include <unistd.h>
+#include <cerrno>
 #include <iostream>
 using namespace std;
 
@@ -31,9 +44,10 @@ FairEventManager* FairEventManager::Instance()
 {
   return fgRinstance;
 }
+
 //______________________________________________________________________________
 FairEventManager::FairEventManager()
-  :TEveEventManager("FairEventManager", ""),
+  :TEveEventManager("EventManager", ""),
    fRootManager(FairRootManager::Instance()),
    fEntry(0),
    fRunAna(FairRunAna::Instance()),
@@ -55,11 +69,18 @@ FairEventManager::FairEventManager()
    fRhoZGeomScene(0),
    fRPhiEventScene(0),
    fRhoZEventScene(0),
-   background_color(1),
    EveMCPoints(NULL),
    EveMCTracks(NULL),
    EveRecoPoints(NULL),
-   EveRecoTracks(NULL)
+   EveRecoTracks(NULL),
+   arrSelectedColoring(NULL),
+   arrLevelColoring(NULL),
+   background_color(1),
+   isDarkColor(true),
+   fEntryCount(0),
+   isZDCModule(NULL),
+   fgShowRecoPointsIsShow(false),
+   fgRedrawRecoPointsReqired(false)
 {
     fgRinstance = this;
 
@@ -76,447 +97,304 @@ FairEventManager::FairEventManager()
 // red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
 void FairEventManager::InitColorStructure()
 {
+    TString coloring_xml_path = "$VMCWORKDIR/config/eventdisplay.xml";
+    TString coloring_xsd_path = "$VMCWORKDIR/eventdisplay/coloring.xsd";
+    gSystem->ExpandPathName(coloring_xml_path);
+    gSystem->ExpandPathName(coloring_xsd_path);
+
     cntSelectedColoring = 0;
     cntLevelColoring = 0;
 
-    if (gVisualizationColoring == levelColoring)
+    if(ValidateXml(coloring_xml_path.Data(),coloring_xsd_path.Data())==true)
     {
-        // number of described detector levels
-        cntLevelColoring = 5;
-        arrLevelColoring = new structLevelColoring[cntLevelColoring];
-
-        // if BM@N
-        if (gCoordinateSystem == sysLaboratory)
+        xmlNode* root_element = NULL;
+        xmlSchemaPtr schema = NULL;
+        xmlSchemaParserCtxtPtr ctxt;
+        xmlDoc* doc = xmlReadFile(coloring_xml_path.Data(), NULL, 0);
+        
+        /*
+         * Get the root element node
+         */
+        root_element = xmlDocGetRootElement(doc);
+        xmlAttr* root_element_attributes = root_element->properties;
+        xmlChar* value = xmlNodeListGetString(root_element->doc, root_element_attributes->children, 1);
+
+        xmlFree(root_element_attributes);
+        xmlNodePtr cur_node = root_element;
+        if (strcmp((char*)value,"default")==0)
         {
-            // LEVEL 1
-            arrLevelColoring[0].fill_color =    "gray"; //yellow for white background
-            arrLevelColoring[0].isFillLine =    true;
-            arrLevelColoring[0].visibility =    true;
-            arrLevelColoring[0].transparency =  30;
-
-            // LEVEL 2
-            arrLevelColoring[1].fill_color =    "yellow"; //magenta for white background
-            arrLevelColoring[1].isFillLine =    true;
-            arrLevelColoring[1].visibility =    true;
-            arrLevelColoring[1].transparency =  30;
-
-            // LEVEL 3
-            arrLevelColoring[2].fill_color =    "cyan"; //green for white background
-            arrLevelColoring[2].isFillLine =    true;
-            arrLevelColoring[2].visibility =    true;
-            arrLevelColoring[2].transparency =  30;
-
-            // LEVEL 4
-            arrLevelColoring[3].fill_color =    "white"; //cyan for white background
-            arrLevelColoring[3].isFillLine =    true;
-            arrLevelColoring[3].visibility =    true;
-            arrLevelColoring[3].transparency =  30;
-
-            // LEVEL 5
-            arrLevelColoring[4].fill_color =    "green"; //blue for white background
-            arrLevelColoring[4].isFillLine =    true;
-            arrLevelColoring[4].visibility =    true;
-            arrLevelColoring[4].transparency =  30;
+            cout<<"using default coloring"<<endl;
+            gVisualizationColoring = defaultColoring;
         }
-        // MPD
         else
-        {
-            // LEVEL 1
-            arrLevelColoring[0].fill_color =    "gray"; //yellow for white background
-            arrLevelColoring[0].isFillLine =    true;
-            arrLevelColoring[0].visibility =    true;
-            arrLevelColoring[0].transparency =  30;
-
-            // LEVEL 2
-            arrLevelColoring[1].fill_color =    "cyan"; //magenta for white background
-            arrLevelColoring[1].isFillLine =    true;
-            arrLevelColoring[1].visibility =    true;
-            arrLevelColoring[1].transparency =  30;
-
-            // LEVEL 3
-            arrLevelColoring[2].fill_color =    "violet"; //green for white background
-            arrLevelColoring[2].isFillLine =    true;
-            arrLevelColoring[2].visibility =    true;
-            arrLevelColoring[2].transparency =  30;
-
-            // LEVEL 4
-            arrLevelColoring[3].fill_color =    "azure"; //cyan for white background
-            arrLevelColoring[3].isFillLine =    true;
-            arrLevelColoring[3].visibility =    true;
-            arrLevelColoring[3].transparency =  30;
-
-            // LEVEL 5
-            arrLevelColoring[4].fill_color =    "green"; //blue for white background
-            arrLevelColoring[4].isFillLine =    true;
-            arrLevelColoring[4].visibility =    true;
-            arrLevelColoring[4].transparency =  30;
-        }
-
-        return;
-    }
-
-    // if BM@N selected coloring
-    if (gCoordinateSystem == sysLaboratory)
-    {
-        int i = 0;
-        cntSelectedColoring = 11;
-        arrSelectedColoring = new structSelectedColoring[cntSelectedColoring];
-
-        // MAGNET color
-        arrSelectedColoring[i].detector_name =          "Magnet";
-        arrSelectedColoring[i].detector_color =         "gray";
-        arrSelectedColoring[i].detector_transparency =  67;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-        // coil of magnet
-        arrSelectedColoring[i].detector_name =          "Coil";
-        arrSelectedColoring[i].detector_color =         "red";
-        arrSelectedColoring[i].detector_transparency =  67;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // TARGET color
-        arrSelectedColoring[i].detector_name =          "targ";
-        arrSelectedColoring[i].detector_color =         "yellow";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // PIPE color
-        arrSelectedColoring[i].detector_name =          "pipe1cave";
-        arrSelectedColoring[i].detector_color =         "orange";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // RECOIL color
-        arrSelectedColoring[i].detector_name =          "recoil01";
-        arrSelectedColoring[i].detector_color =         "khaki";
-        arrSelectedColoring[i].detector_transparency =  67;
-        arrSelectedColoring[i].isRecursiveColoring =  true;
-        i++;
-
-        // GEMS color
-        arrSelectedColoring[i].detector_name =          "GEMS";
-        arrSelectedColoring[i].detector_color =         "cyan";
-        arrSelectedColoring[i].detector_transparency =  15;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // TOF1 color
-        arrSelectedColoring[i].detector_name =          "tof1";
-        arrSelectedColoring[i].detector_color =         "spring";
-        arrSelectedColoring[i].detector_transparency =  15;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // DCH1 color
-        arrSelectedColoring[i].detector_name =          "dch1";
-        arrSelectedColoring[i].detector_color =         "orange+7";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // DCH2 color
-        arrSelectedColoring[i].detector_name =          "dch2";
-        arrSelectedColoring[i].detector_color =         "orange+7";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-
-        // TOF2 color
-        arrSelectedColoring[i].detector_name =          "tof2";
-        arrSelectedColoring[i].detector_color =         "spring";
-        arrSelectedColoring[i].detector_transparency =  15;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-        // inner part of TOF2
-        arrSelectedColoring[i].detector_name =          "t2reg2mod";
-        arrSelectedColoring[i].detector_color =         "spring+2";
-        //arrSelectedColoring[i].detector_transparency =  29;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
+        {          
+            if (strcmp((char*)value, "detector") == 0)
+            {
+                cntSelectedColoring = (int)xmlChildElementCount(cur_node);
+                arrSelectedColoring = new structSelectedColoring[cntSelectedColoring];
+                gVisualizationColoring = selectedColoring;
+            }
+            else
+            {
+                cntLevelColoring = (int)xmlChildElementCount(cur_node);
+                arrLevelColoring = new structLevelColoring[cntLevelColoring];
+                gVisualizationColoring = levelColoring;
 
+            }
+            cur_node = root_element->children;
+            int i=0;
+            while (cur_node)
+            {
+                if (strcmp((char*)cur_node->name, "text") != 0)//skipping elements with no attributes
+                {
+                    xmlAttr* attribute = cur_node->properties;
+                    while(attribute)
+                    {
+                        xmlChar* attr_value = xmlNodeListGetString(root_element->doc, attribute->children, 1);
+                        if (strcmp((char*)value, "detector") == 0)
+                        {
+                            if (strcmp((char*)attribute->name,"name")==0) 
+                                arrSelectedColoring[i].detector_name=(char*)attr_value;
+                            if (strcmp((char*)attribute->name,"color")==0)
+                                arrSelectedColoring[i].detector_color=(char*)attr_value;
+                            if (strcmp((char*)attribute->name,"isRecursiveColoring")==0)
+                                arrSelectedColoring[i].isRecursiveColoring=(strcmp((char*)attr_value,"true")==0);                            
+                            if (strcmp((char*)attribute->name,"transparency")==0) 
+                                arrSelectedColoring[i].detector_transparency =  atoi((char*)attr_value);
+                        }
+                        else if (strcmp((char*)value, "hierarchy") == 0)
+                        {
+                            if (strcmp((char*)attribute->name,"color")==0) 
+                                arrLevelColoring[i].fill_color=(char*)attr_value;
+                            if (strcmp((char*)attribute->name,"isFillLine")==0) 
+                                arrLevelColoring[i].isFillLine=(strcmp((char*)attr_value,"true")==0);
+                            if (strcmp((char*)attribute->name,"visibility")==0) 
+                                arrLevelColoring[i].visibility=(strcmp((char*)attr_value,"true")==0);
+                            if (strcmp((char*)attribute->name,"transparency")==0) 
+                                arrLevelColoring[i].transparency=atoi((char*)attr_value);
+                        }                    
+                        attribute = attribute->next;
+                        xmlFree(attr_value);
+                    }
+                    xmlFree(attribute);
+                    i++;                
+                }
+                cur_node = cur_node->next;
+            }
+        }
+            
+        xmlFree(value);
+        xmlFree(cur_node);
         /*
-        // ZDC color
-        arrSelectedColoring[i].detector_name =          "VETO";
-        arrSelectedColoring[i].detector_color =         "yellow";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i].isRecursiveColoring =    true;
-        i++;
-        */
+         * free the document
+         */
+        xmlCleanupParser();
+        xmlFreeDoc(doc);
     }
-    // if MPD
     else
     {
-        int i = 0;
-        cntSelectedColoring = 13;
-        arrSelectedColoring = new structSelectedColoring[cntSelectedColoring];
-
-        // MAGNET color
-        arrSelectedColoring[i].detector_name =          "ms01yokebarrel";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // cryostat
-        arrSelectedColoring[i].detector_name =          "ms01cryostat";
-        arrSelectedColoring[i].detector_color =         "gray";
-        arrSelectedColoring[i].detector_transparency =  15;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeii";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeio";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeim";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeoi";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeom";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-        // barrel end
-        arrSelectedColoring[i].detector_name =          "ms01yokeendeoo";
-        arrSelectedColoring[i].detector_color =         "blue";
-        arrSelectedColoring[i].detector_transparency =  30;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-
-        // PIPE color
-        arrSelectedColoring[i].detector_name =          "pipe1";
-        arrSelectedColoring[i].detector_color =         "orange";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-
-        // TPC color
-        arrSelectedColoring[i].detector_name =          "tpcChamber1";
-        arrSelectedColoring[i].detector_color =         "cyan";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-
-        // TOF color
-        arrSelectedColoring[i].detector_name =          "tof1";
-        arrSelectedColoring[i].detector_color =         "spring";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-
-        // EMC color
-        arrSelectedColoring[i].detector_name =          "emc1Chamber1";
-        arrSelectedColoring[i].detector_color =         "violet";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
-
-        // ZDC color
-        arrSelectedColoring[i].detector_name =          "zdc01";
-        arrSelectedColoring[i].detector_color =         "green";
-        arrSelectedColoring[i].detector_transparency =  0;
-        arrSelectedColoring[i++].isRecursiveColoring =  true;
+        cout<<"using default coloring"<<endl;
+        gVisualizationColoring = defaultColoring;
     }
-
+    
+    //sleep(20);
     return;
 }
 
 //______________________________________________________________________________
 void FairEventManager::Init(Int_t visopt, Int_t vislvl, Int_t maxvisnds)
 {
-  TEveManager::Create();
-  fRunAna->Init();
-
-  // if no gGeoManager in input file - get it from evetest.root directly for BMNRoot and MPDRoot
-  if (!gGeoManager)
-  {
-      std::cout<<"\ngGeoManager is NULL. It's loading manually"<<std::endl;
-      TFile* f = NULL;
-      if (gCoordinateSystem == sysLaboratory) //BMNRoot
-          f = new TFile("$VMCWORKDIR/macro/run/evetest.root");
-      else                                    //MPDRoot
-          f = new TFile("$VMCWORKDIR/macro/mpd/evetest.root");
-
-      f->Get("FairBaseParSet");
-  }
-
-  TGeoNode* N = gGeoManager->GetTopNode();
-  TEveGeoTopNode* TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
-
-  // change color and visibility of geometry nodes
-  if (gVisualizationColoring != defaultColoring)
-  {
-    if (gVisualizationColoring == selectedColoring)
-        SelectedGeometryColoring();
-    else
-        LevelChangeNodeProperty(N, 0);
-  }
-
-  gEve->AddGlobalElement(TNod);
-  gEve->FullRedraw3D(kTRUE);
-  fEvent = gEve->AddEvent(this);
-
-  // create projection managers
-  fRPhiMng = new TEveProjectionManager();
-  fRPhiMng->SetProjection(TEveProjection::kPT_RPhi);
-  gEve->AddToListTree(fRPhiMng, kFALSE);
-
-  fRhoZMng = new TEveProjectionManager();
-  fRhoZMng->SetProjection(TEveProjection::kPT_RhoZ);
-  gEve->AddToListTree(fRhoZMng, kFALSE);
-
-  // create axes for viewers
-  TEveProjectionAxes* axes = new TEveProjectionAxes(fRPhiMng);
-  axes->SetMainColor(kWhite);
-
-  // first 3D viewer
-  gEve->GetDefaultViewer()->SetElementName("3D View");
-  // switch off left and right light sources for first window
-  gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  gEve->GetDefaultViewer()->GetGLViewer()->SetClearColor(background_color);
-
-  // add window in EventDisplay for RPhi projection
-  TEveWindowSlot *RPhiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
-  TEveWindowPack *RPhiPack = RPhiSlot->MakePack();
-  RPhiPack->SetElementName("RPhi View");
-  RPhiPack->SetShowTitleBar(kFALSE);
-  RPhiPack->NewSlot()->MakeCurrent();
-  fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
-  fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
-  Double_t eqRPhi[4] = {0.0, 0.0, 1.0, 0.0};
-  // set clip plane and camera parameters
-  fRPhiView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
-  fRPhiView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRPhi);
-  fRPhiView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
-  fRPhiView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
-  // switch off left, right, top and bottom light sources
-  fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
-  fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
-  fRPhiView->GetGLViewer()->SetClearColor(background_color);
-  // create scene holding projected geometry for the RPhi view
-  fRPhiGeomScene  = gEve->SpawnNewScene("RPhi Geometry", "Scene holding projected geometry for the RPhi view.");
-  // add axes for scene of RPhi view
-  fRPhiGeomScene->AddElement(axes);
-  // create scene holding projected event-data for the RPhi view
-  fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data", "Scene holding projected event-data for the RPhi view.");
-  // add both scenes to RPhi View
-  fRPhiView->AddScene(fRPhiGeomScene);
-  fRPhiView->AddScene(fRPhiEventScene);
-
-  // add window in EvenDisplay for RhoZ projection
-  TEveWindowSlot *RhoZSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
-  TEveWindowPack *RhoZPack = RhoZSlot->MakePack();
-  RhoZPack->SetElementName("RhoZ View");
-  RhoZPack->SetShowTitleBar(kFALSE);
-  RhoZPack->NewSlot()->MakeCurrent();
-  fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
-  fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
-  Double_t eqRhoZ[4] = {-1.0, 0.0, 0.0, 0.0};
-  // set clip plane and camera parameters
-  fRhoZView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
-  fRhoZView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRhoZ);
-  fRhoZView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
-  fRhoZView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
-  // switch off left, right and front light sources
-  fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
-  fRhoZView->GetGLViewer()->SetClearColor(background_color);
-  // create scene holding projected geometry for the RhoZ view.
-  fRhoZGeomScene  = gEve->SpawnNewScene("RhoZ Geometry", "Scene holding projected geometry for the RhoZ view.");
-  // add axes for scene of RPhoZ view
-  fRhoZGeomScene->AddElement(axes);
-  // create scene holding projected event-data for the RhoZ view
-  fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data", "Scene holding projected event-data for the RhoZ view.");
-  // add both scenes to RhoZView
-  fRhoZView->AddScene(fRhoZGeomScene);
-  fRhoZView->AddScene(fRhoZEventScene);
-
-  // add window in EvenDisplay for MultiView
-  TEveWindowSlot *MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
-  TEveWindowPack *MultiPack = MultiSlot->MakePack();
-  MultiPack->SetElementName("Multi View");
-  MultiPack->SetHorizontal();
-  MultiPack->SetShowTitleBar(kFALSE);
-  MultiPack->NewSlot()->MakeCurrent();
-  fMulti3DView = gEve->SpawnNewViewer("3D View (multi)", "");
-  // switch off left and right light sources for 3D MultiView
-  fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  fMulti3DView->GetGLViewer()->SetClearColor(background_color);
-  // add 3D scenes (first tab) to 3D MultiView
-  fMulti3DView->AddScene(gEve->GetGlobalScene());
-  fMulti3DView->AddScene(gEve->GetEventScene());
-
-  // add slot for RPhi projection on Multi View tab
-  MultiPack = MultiPack->NewSlot()->MakePack();
-  MultiPack->SetShowTitleBar(kFALSE);
-  MultiPack->NewSlot()->MakeCurrent();
-  fMultiRPhiView = gEve->SpawnNewViewer("RPhi View (multi)", "");
-  fMultiRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
-  // set clip plane and camera parameters
-  fMultiRPhiView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
-  fMultiRPhiView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRPhi);
-  fMultiRPhiView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
-  fMultiRPhiView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
-  // switch off left, right, top and bottom light sources
-  fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
-  fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
-  fMultiRPhiView->GetGLViewer()->SetClearColor(background_color);
-  // add RPhi scenes (second tab) to RPhi MultiView
-  fMultiRPhiView->AddScene(fRPhiGeomScene);
-  fMultiRPhiView->AddScene(fRPhiEventScene);
-
-  // add slot for RhoZ projection on Multi View tab
-  MultiPack->NewSlot()->MakeCurrent();
-  fMultiRhoZView = gEve->SpawnNewViewer("RhoZ View (multi)", "");
-  fMultiRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
-  // set clip plane and camera parameters
-  fMultiRhoZView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
-  fMultiRhoZView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRhoZ);
-  fMultiRhoZView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
-  fMultiRhoZView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
-  // switch off left, right and front light sources
-  fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
-  fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
-  fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
-  fMultiRhoZView->GetGLViewer()->SetClearColor(background_color);
-  // add RhoZ scenes (second tab) to RhoZ MultiView
-  fMultiRhoZView->AddScene(fRhoZGeomScene);
-  fMultiRhoZView->AddScene(fRhoZEventScene);
-
-  // copy geometry and event scene for RPhi and RhoZ views from global scene (3D)
-  fRPhiGeomScene->AddElement(gEve->GetGlobalScene());
-  fRPhiEventScene->AddElement(gEve->GetEventScene());
-  fRhoZGeomScene->AddElement(gEve->GetGlobalScene());
-  fRhoZEventScene->AddElement(gEve->GetEventScene());
-
-  // update all scenes
-  fRPhiView->GetGLViewer()->UpdateScene(kTRUE);
-  fRhoZView->GetGLViewer()->UpdateScene(kTRUE);
-  fMulti3DView->GetGLViewer()->UpdateScene(kTRUE);
-  fMultiRPhiView->GetGLViewer()->UpdateScene(kTRUE);
-  fMultiRhoZView->GetGLViewer()->UpdateScene(kTRUE);
-
-  // don't change reposition camera on each update
-  fRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
-  fRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
-  fMulti3DView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
-  fMultiRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
-  fMultiRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
-}
+    TEveManager::Create();
+    fRunAna->Init();
+
+    TGeoNode* N = gGeoManager->GetTopNode();
+    TEveGeoTopNode* TNod = new TEveGeoTopNode(gGeoManager, N, visopt, vislvl, maxvisnds);
+
+    // change color and visibility of geometry nodes
+    if (gVisualizationColoring != defaultColoring)
+    {
+        if (gVisualizationColoring == selectedColoring)
+            SelectedGeometryColoring();
+        else
+            LevelChangeNodeProperty(N, 0);
+    }
+
+    gEve->AddGlobalElement(TNod);
+    gEve->FullRedraw3D(kTRUE);
+    fEvent = gEve->AddEvent(this);
+
+    // first 3D viewer
+    gEve->GetDefaultViewer()->SetElementName("3D View");
+    // display axes
+    //gEve->GetDefaultViewer()->GetGLViewer()->SetGuideState(TGLUtil::kAxesEdge, kTRUE, kFALSE, 0);
+    // switch off left and right light sources for first window
+    gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+    gEve->GetDefaultViewer()->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+    if (!isDarkColor)
+        gEve->GetDefaultViewer()->GetGLViewer()->UseLightColorSet();
+    gEve->GetDefaultViewer()->GetGLViewer()->SetClearColor(background_color);
+
+    // different views and projections for Offline mode
+    if (!isOnline)
+    {
+        // create projection managers
+        fRPhiMng = new TEveProjectionManager();
+        fRPhiMng->SetProjection(TEveProjection::kPT_RPhi);
+        gEve->AddToListTree(fRPhiMng, kFALSE);
+
+        fRhoZMng = new TEveProjectionManager();
+        fRhoZMng->SetProjection(TEveProjection::kPT_RhoZ);
+        gEve->AddToListTree(fRhoZMng, kFALSE);
+
+        // create axes for viewers
+        TEveProjectionAxes* axes = new TEveProjectionAxes(fRPhiMng);
+        axes->SetMainColor(kRed);
+
+        // add window in EventDisplay for RPhi projection
+        TEveWindowSlot *RPhiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+        TEveWindowPack *RPhiPack = RPhiSlot->MakePack();
+        RPhiPack->SetElementName("RPhi View");
+        RPhiPack->SetShowTitleBar(kFALSE);
+        RPhiPack->NewSlot()->MakeCurrent();
+        fRPhiView = gEve->SpawnNewViewer("RPhi View", "");
+        fRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+        Double_t eqRPhi[4] = {0.0, 0.0, 1.0, 0.0};
+        // set clip plane and camera parameters
+        fRPhiView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
+        fRPhiView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRPhi);
+        fRPhiView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
+        fRPhiView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
+        // switch off left, right, top and bottom light sources
+        fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+        fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+        fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
+        fRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
+        if (!isDarkColor)
+            fRPhiView->GetGLViewer()->UseLightColorSet();
+        fRPhiView->GetGLViewer()->SetClearColor(background_color);
+        // create scene holding projected geometry for the RPhi view
+        fRPhiGeomScene  = gEve->SpawnNewScene("RPhi Geometry", "Scene holding projected geometry for the RPhi view.");
+        // add axes for scene of RPhi view
+        fRPhiGeomScene->AddElement(axes);
+        // create scene holding projected event-data for the RPhi view
+        fRPhiEventScene = gEve->SpawnNewScene("RPhi Event Data", "Scene holding projected event-data for the RPhi view.");
+        // add both scenes to RPhi View
+        fRPhiView->AddScene(fRPhiGeomScene);
+        fRPhiView->AddScene(fRPhiEventScene);
+
+        // add window in EvenDisplay for RhoZ projection
+        TEveWindowSlot *RhoZSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+        TEveWindowPack *RhoZPack = RhoZSlot->MakePack();
+        RhoZPack->SetElementName("RhoZ View");
+        RhoZPack->SetShowTitleBar(kFALSE);
+        RhoZPack->NewSlot()->MakeCurrent();
+        fRhoZView = gEve->SpawnNewViewer("RhoZ View", "");
+        fRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
+        Double_t eqRhoZ[4] = {-1.0, 0.0, 0.0, 0.0};
+        // set clip plane and camera parameters
+        fRhoZView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
+        fRhoZView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRhoZ);
+        fRhoZView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
+        fRhoZView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
+        // switch off left, right and front light sources
+        fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+        fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+        fRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
+        if (!isDarkColor)
+            fRhoZView->GetGLViewer()->UseLightColorSet();
+        fRhoZView->GetGLViewer()->SetClearColor(background_color);
+        // create scene holding projected geometry for the RhoZ view.
+        fRhoZGeomScene  = gEve->SpawnNewScene("RhoZ Geometry", "Scene holding projected geometry for the RhoZ view.");
+        // add axes for scene of RPhoZ view
+        fRhoZGeomScene->AddElement(axes);
+        // create scene holding projected event-data for the RhoZ view
+        fRhoZEventScene = gEve->SpawnNewScene("RhoZ Event Data", "Scene holding projected event-data for the RhoZ view.");
+        // add both scenes to RhoZView
+        fRhoZView->AddScene(fRhoZGeomScene);
+        fRhoZView->AddScene(fRhoZEventScene);
+
+        // add window in EvenDisplay for MultiView
+        TEveWindowSlot *MultiSlot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
+        TEveWindowPack *MultiPack = MultiSlot->MakePack();
+        MultiPack->SetElementName("Multi View");
+        MultiPack->SetHorizontal();
+        MultiPack->SetShowTitleBar(kFALSE);
+        MultiPack->NewSlot()->MakeCurrent();
+        fMulti3DView = gEve->SpawnNewViewer("3D View (multi)", "");
+        // switch off left and right light sources for 3D MultiView
+        fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+        fMulti3DView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+        if (!isDarkColor)
+            fMulti3DView->GetGLViewer()->UseLightColorSet();
+        fMulti3DView->GetGLViewer()->SetClearColor(background_color);
+        // add 3D scenes (first tab) to 3D MultiView
+        fMulti3DView->AddScene(gEve->GetGlobalScene());
+        fMulti3DView->AddScene(gEve->GetEventScene());
+
+        // add slot for RPhi projection on Multi View tab
+        MultiPack = MultiPack->NewSlot()->MakePack();
+        MultiPack->SetShowTitleBar(kFALSE);
+        MultiPack->NewSlot()->MakeCurrent();
+        fMultiRPhiView = gEve->SpawnNewViewer("RPhi View (multi)", "");
+        fMultiRPhiView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
+        // set clip plane and camera parameters
+        fMultiRPhiView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
+        fMultiRPhiView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRPhi);
+        fMultiRPhiView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
+        fMultiRPhiView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
+        // switch off left, right, top and bottom light sources
+        fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+        fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+        fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightTop, false);
+        fMultiRPhiView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightBottom, false);
+        if (!isDarkColor)
+            fMultiRPhiView->GetGLViewer()->UseLightColorSet();
+        fMultiRPhiView->GetGLViewer()->SetClearColor(background_color);
+        // add RPhi scenes (second tab) to RPhi MultiView
+        fMultiRPhiView->AddScene(fRPhiGeomScene);
+        fMultiRPhiView->AddScene(fRPhiEventScene);
+
+        // add slot for RhoZ projection on Multi View tab
+        MultiPack->NewSlot()->MakeCurrent();
+        fMultiRhoZView = gEve->SpawnNewViewer("RhoZ View (multi)", "");
+        fMultiRhoZView->GetGLViewer()->SetCurrentCamera(TGLViewer::kCameraOrthoZOY);
+        // set clip plane and camera parameters
+        fMultiRhoZView->GetGLViewer()->GetClipSet()->SetClipType(TGLClip::kClipPlane);
+        fMultiRhoZView->GetGLViewer()->GetClipSet()->SetClipState(TGLClip::kClipPlane, eqRhoZ);
+        fMultiRhoZView->GetGLViewer()->GetCameraOverlay()->SetOrthographicMode(TGLCameraOverlay::kAxis);
+        fMultiRhoZView->GetGLViewer()->GetCameraOverlay()->SetShowOrthographic(kTRUE);
+        // switch off left, right and front light sources
+        fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightLeft, false);
+        fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightRight, false);
+        fMultiRhoZView->GetGLViewer()->GetLightSet()->SetLight(TGLLightSet::kLightFront, false);
+        if (!isDarkColor)
+            fMultiRhoZView->GetGLViewer()->UseLightColorSet();
+        fMultiRhoZView->GetGLViewer()->SetClearColor(background_color);
+        // add RhoZ scenes (second tab) to RhoZ MultiView
+        fMultiRhoZView->AddScene(fRhoZGeomScene);
+        fMultiRhoZView->AddScene(fRhoZEventScene);
+
+        // copy geometry and event scene for RPhi and RhoZ views from global scene (3D)
+        fRPhiGeomScene->AddElement(gEve->GetGlobalScene());
+        fRPhiEventScene->AddElement(gEve->GetEventScene());
+        fRhoZGeomScene->AddElement(gEve->GetGlobalScene());
+        fRhoZEventScene->AddElement(gEve->GetEventScene());
+
+        // update all scenes
+        fRPhiView->GetGLViewer()->UpdateScene(kTRUE);
+        fRhoZView->GetGLViewer()->UpdateScene(kTRUE);
+        fMulti3DView->GetGLViewer()->UpdateScene(kTRUE);
+        fMultiRPhiView->GetGLViewer()->UpdateScene(kTRUE);
+        fMultiRhoZView->GetGLViewer()->UpdateScene(kTRUE);
+
+        // don't change reposition camera on each update
+        fRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
+        fRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
+        fMulti3DView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
+        fMultiRPhiView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
+        fMultiRhoZView->GetGLViewer()->SetResetCamerasOnUpdate(kFALSE);
+    }//if (!isOnline)
+}//FairEventManager::Init
 
 // changing of geometry color
 void FairEventManager::SelectedGeometryColoring()
@@ -559,7 +437,7 @@ void FairEventManager::SelectedGeometryColoring()
 
 void FairEventManager::RecursiveChangeNodeProperty(TGeoNode* node, Int_t color, int transparency)
 {
-    for(int i = 0; i < node->GetNdaughters(); i++)
+    for (int i = 0; i < node->GetNdaughters(); i++)
     {
         TGeoNode* child = node->GetDaughter(i);
         TGeoVolume* curVolume = child->GetVolume();
@@ -573,6 +451,54 @@ void FairEventManager::RecursiveChangeNodeProperty(TGeoNode* node, Int_t color,
     }
 }
 
+// set transparent geometry
+void FairEventManager::SelectedGeometryTransparent(bool is_on)
+{
+    TGeoVolume* curVolume;
+    for (int i = 0; i < cntSelectedColoring; i++)
+    {
+        curVolume = gGeoManager->GetVolume(arrSelectedColoring[i].detector_name);
+        if (!curVolume)
+        {
+            cout<<"There is no volume with given name: "<< arrSelectedColoring[i].detector_name<<endl;
+            continue;
+        }
+
+        Int_t curTransparency = 80;
+        if (!is_on)
+            curTransparency = arrSelectedColoring[i].detector_transparency;
+
+        curVolume->SetTransparency(curTransparency);
+
+        for (int j = 0; j < curVolume->GetNdaughters(); j++)
+        {
+            TGeoNode* child = curVolume->GetNode(j);
+            TGeoVolume* subVolume = child->GetVolume();
+
+            subVolume->SetTransparency(curTransparency);
+
+            if (child->GetNdaughters() != 0)
+                RecursiveChangeNodeTransparent(child, curTransparency);
+        }
+    }
+
+    return;
+}
+
+void FairEventManager::RecursiveChangeNodeTransparent(TGeoNode* node, int transparency)
+{
+    for (int i = 0; i < node->GetNdaughters(); i++)
+    {
+        TGeoNode* child = node->GetDaughter(i);
+        TGeoVolume* curVolume = child->GetVolume();
+
+        curVolume->SetTransparency(transparency);
+
+        if (child->GetNdaughters() != 0)
+            RecursiveChangeNodeTransparent(child, transparency);
+    }
+}
+
 // hierarchical changing of nodes' properties: visibility, transparency, fill color and line color
 void FairEventManager::LevelChangeNodeProperty(TGeoNode* node, int level)
 {
@@ -597,6 +523,57 @@ void FairEventManager::LevelChangeNodeProperty(TGeoNode* node, int level)
     }
 }
 
+//returns true if successful or false if validation failed
+bool FairEventManager::ValidateXml(const char *XMLFileName, const char *XSDFileName)
+{
+    bool ok = false;
+    xmlDoc* doc = NULL;
+    xmlSchemaPtr schema = NULL;
+    xmlSchemaParserCtxtPtr ctxt;
+    
+    ctxt = xmlSchemaNewParserCtxt(XSDFileName);
+
+    xmlSchemaSetParserErrors(ctxt, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
+    schema = xmlSchemaParse(ctxt);
+    xmlSchemaFreeParserCtxt(ctxt);
+    //xmlSchemaDump(stdout, schema); //To print schema dump
+    doc = xmlReadFile(XMLFileName, NULL, 0);
+    if (doc == NULL)
+    {
+        cout<<"error: could not parse file"<<XMLFileName<<endl;
+        ok=false;
+    }
+    else
+    {
+        xmlSchemaValidCtxtPtr cvalid;
+        int ret;
+
+        cvalid = xmlSchemaNewValidCtxt(schema);
+        xmlSchemaSetValidErrors(cvalid, (xmlSchemaValidityErrorFunc) fprintf, (xmlSchemaValidityWarningFunc) fprintf, stderr);
+        ret = xmlSchemaValidateDoc(cvalid, doc);
+        if (ret == 0)
+        {
+            //cout<<XMLFileName<<" is validated"<<endl;
+            ok=true;
+        }
+        else if (ret > 0)
+        {
+            cout<<XMLFileName<<" failed to validate"<<endl;
+            ok=false;
+        }
+        else
+        {
+            cout<<XMLFileName<<" validation generated an internal error"<<endl;
+            ok=false;
+        }
+        xmlSchemaFreeValidCtxt(cvalid);
+    }
+    if(schema != NULL)
+        xmlSchemaFree(schema);
+    xmlSchemaCleanupTypes();
+    return ok;
+}
+
 // return integer value of color by color name (default, blue)
 // support following colors:
 // white, black, gray,
@@ -644,21 +621,25 @@ void FairEventManager::SetDepth(Float_t d)
     fRPhiMng->SetCurrentDepth(d);
     fRhoZMng->SetCurrentDepth(d);
 }
+
 //______________________________________________________________________________
 void FairEventManager::ImportGeomRPhi(TEveElement* el)
 {
     fRPhiMng->ImportElements(el, fRPhiGeomScene);
 }
+
 //______________________________________________________________________________
 void FairEventManager::ImportGeomRhoZ(TEveElement* el)
 {
     fRhoZMng->ImportElements(el, fRhoZGeomScene);
 }
+
 //______________________________________________________________________________
 void FairEventManager::ImportEventRPhi(TEveElement* el)
 {
     fRPhiMng->ImportElements(el, fRPhiEventScene);
 }
+
 //______________________________________________________________________________
 void FairEventManager::ImportEventRhoZ(TEveElement* el)
 {
@@ -666,191 +647,191 @@ void FairEventManager::ImportEventRhoZ(TEveElement* el)
 }
 
 //______________________________________________________________________________
-void FairEventManager::UpdateEditor()
+void FairEventManager::Open()
 {
 }
 
-// FairEventManager destructor (empty now)
-FairEventManager::~FairEventManager()
+//______________________________________________________________________________
+void FairEventManager::Close()
 {
 }
 
 //______________________________________________________________________________
-void FairEventManager::Open()
+void FairEventManager::DisplaySettings()
 {
 }
 
-// go to FairRunAna event with given number for scene data getting
-void FairEventManager::GotoEvent(Int_t event)
+//______________________________________________________________________________
+void FairEventManager::UpdateEditor()
 {
-  fEntry=event;
-  fRunAna->Run((Long64_t)event);
 }
-// go to next FairRunAna event for scene data getting
-void FairEventManager::NextEvent()
+
+// FairEventManager destructor
+FairEventManager::~FairEventManager()
 {
-  fEntry+=1;
-  fRunAna->Run((Long64_t)fEntry);
+    if (arrSelectedColoring)
+        delete[] arrSelectedColoring;
+    if (arrLevelColoring)
+        delete[] arrLevelColoring;
 }
-// go to previous FairRunAna event for scene data getting
-void FairEventManager::PrevEvent()
+
+// go to FairRunAna event with given number for scene data getting
+void FairEventManager::GotoEvent(Int_t event)
 {
-  fEntry-=1;
-  fRunAna->Run((Long64_t)fEntry);
+    fEntry = event;
+    fRunAna->Run((Long64_t)event);
 }
 
-//______________________________________________________________________________
-void FairEventManager::Close()
+// go to next FairRunAna event for scene data getting
+void FairEventManager::NextEvent()
 {
+    fRunAna->Run((Long64_t)++fEntry);
 }
 
-//______________________________________________________________________________
-
-void FairEventManager::DisplaySettings()
+// go to previous FairRunAna event for scene data getting
+void FairEventManager::PrevEvent()
 {
+    fRunAna->Run((Long64_t)--fEntry);
 }
 
 // return integer value of color for track by particle pdg (default, white)
 Int_t FairEventManager::Color(int pdg)
 {
-  switch(pdg) {
-  case   22     :
-    return  623;    // photon
-  case   -2112  :
-    return  2 ;   // anti-neutron
-  case   -11    :
-    return  3;    // e+
-  case   -3122  :
-    return  4;   // anti-Lambda
-  case   11     :
-    return  5;    // e-
-  case   -3222  :
-    return  6;   // Sigma-
-  case   12     :
-    return  7;    // e-neutrino (NB: flavour undefined by Geant)
-  case   -3212  :
-    return  8;   // Sigma0
-  case   -13    :
-    return  9;    // mu+
-  case   -3112  :
-    return  10;   // Sigma+ (PB)*/
-  case   13     :
-    return  11;    // mu-
-  case   -3322  :
-    return  12;   // Xi0
-  case   111    :
-    return  13;    // pi0
-  case   -3312  :
-    return  14;   // Xi+
-  case   211    :
-    return  15;    // pi+
-  case   -3334  :
-    return  16;   // Omega+ (PB)
-  case   -211   :
-    return  17;    // pi-
-  case   -15    :
-    return  18;   // tau+
-  case   130    :
-    return  19;   // K long
-  case   15     :
-    return  20;   // tau-
-  case   321    :
-    return  21;   // K+
-  case   411    :
-    return  22;   // D+
-  case   -321   :
-    return  23;   // K-
-  case   -411   :
-    return  24;   // D-
-  case   2112   :
-    return  25;   // n
-  case   421    :
-    return  26;   // D0
-  case   2212   :
-    return  27;   // p
-  case   -421   :
-    return  28;   // D0
-  case   -2212  :
-    return  29;   // anti-proton
-  case   431    :
-    return  30;   // Ds+
-  case   310    :
-    return  31;   // K short
-  case   -431   :
-    return  32;   // anti Ds-
-  case   221    :
-    return  33;   // eta
-  case   4122   :
-    return  34;   // Lamba_c+
-  case   3122   :
-    return  35;   // Lambda
-  case   24     :
-    return  36;   // W+
-  case   3222   :
-    return  37;   // Sigma+
-  case   -24    :
-    return  38;   // W-
-  case   3212   :
-    return  39;   // Sigma0
-  case   23     :
-    return  40;   // Z
-  case   3112   :
-    return  41;   // Sigma-
-  case   3322   :
-    return  42;   // Xi0
-  case   3312   :
-    return  43;   // Xi-
-  case   3334   :
-    return  44;   // Omega- (PB)
-  case   50000050   :
-    return  801;   // Cerenkov
-  case   1000010020  :
-    return  45;
-  case   1000010030  :
-    return  48;
-  case   1000020040   :
-    return  50;
-  case   1000020030   :
-    return  55;
-  default  :
-    return 0;
-  }//switch
+    switch (pdg)
+    {
+    case   22     :
+        return  623;    // photon
+    case   -2112  :
+        return  2 ;   // anti-neutron
+    case   -11    :
+        return  3;    // e+
+    case   -3122  :
+        return  4;   // anti-Lambda
+    case   11     :
+        return  5;    // e-
+    case   -3222  :
+        return  6;   // Sigma-
+    case   12     :
+        return  7;    // e-neutrino (NB: flavour undefined by Geant)
+    case   -3212  :
+        return  8;   // Sigma0
+    case   -13    :
+        return  9;    // mu+
+    case   -3112  :
+        return  10;   // Sigma+ (PB)*/
+    case   13     :
+        return  11;    // mu-
+    case   -3322  :
+        return  12;   // Xi0MWPCDigit
+    case   111    :
+        return  13;    // pi0
+    case   -3312  :
+        return  14;   // Xi+
+    case   211    :
+        return  15;    // pi+
+    case   -3334  :
+        return  16;   // Omega+ (PB)
+    case   -211   :
+        return  17;    // pi-
+    case   -15    :
+        return  18;   // tau+
+    case   130    :
+        return  19;   // K long
+    case   15     :
+        return  20;   // tau-
+    case   321    :
+        return  21;   // K+
+    case   411    :
+        return  22;   // D+
+    case   -321   :
+        return  23;   // K-
+    case   -411   :
+        return  24;   // D-
+    case   2112   :
+        return  25;   // n
+    case   421    :
+        return  26;   // D0
+    case   2212   :
+        return  27;   // p
+    case   -421   :
+        return  28;   // D0
+    case   -2212  :
+        return  29;   // anti-proton
+    case   431    :
+        return  30;   // Ds+
+    case   310    :
+        return  31;   // K short
+    case   -431   :
+        return  32;   // anti Ds-
+    case   221    :
+        return  33;   // eta
+    case   4122   :
+        return  34;   // Lamba_c+
+    case   3122   :
+        return  35;   // Lambda
+    case   24     :
+        return  36;   // W+
+    case   3222   :
+        return  37;   // Sigma+
+    case   -24    :
+        return  38;   // W-
+    case   3212   :
+        return  39;   // Sigma0
+    case   23     :
+        return  40;   // Z
+    case   3112   :
+        return  41;   // Sigma-
+    case   3322   :
+        return  42;   // Xi0
+    case   3312   :
+        return  43;   // Xi-
+    case   3334   :
+        return  44;   // Omega- (PB)
+    case   50000050   :
+        return  801;   // Cerenkov
+    case   1000010020  :
+        return  45;
+    case   1000010030  :
+        return  48;
+    case   1000020040   :
+        return  50;
+    case   1000020030   :
+        return  55;
+    case   0:
+        return  27;    // Rootino
+    default  :
+        return 0;
+    }//switch
 }
 
 // add particles to the PDG data base: Deuteron, Triton, Alpha, HE3; Cherenkov, FeedbackPhoton
 void FairEventManager::AddParticlesToPdgDataBase(Int_t pdg)
 {
-  TDatabasePDG* pdgDB = TDatabasePDG::Instance();
-
-  const Double_t kAu2Gev=0.9314943228;
-  const Double_t khSlash = 1.0545726663e-27;
-  const Double_t kErg2Gev = 1/1.6021773349e-3;
-  const Double_t khShGev = khSlash*kErg2Gev;
-  const Double_t kYear2Sec = 3600*24*365.25;
-
-  // Ions
-  if ( !pdgDB->GetParticle(1000010020) )
-    pdgDB->AddParticle("Deuteron","Deuteron",2*kAu2Gev+8.071e-3,kTRUE,
-                       0,3,"Ion",1000010020);
-
-  if ( !pdgDB->GetParticle(1000010030) )
-    pdgDB->AddParticle("Triton","Triton",3*kAu2Gev+14.931e-3,kFALSE,
-                       khShGev/(12.33*kYear2Sec),3,"Ion",1000010030);
-
-  if ( !pdgDB->GetParticle(1000020040) )
-    pdgDB->AddParticle("Alpha","Alpha",4*kAu2Gev+2.424e-3,kTRUE,
-                       khShGev/(12.33*kYear2Sec),6,"Ion",1000020040);
-
-  if ( !pdgDB->GetParticle(1000020030) )
-    pdgDB->AddParticle("HE3","HE3",3*kAu2Gev+14.931e-3,kFALSE,
-                       0,6,"Ion",1000020030);
-
-   // Special particles
-  if ( !pdgDB->GetParticle(50000050) )
-    pdgDB->AddParticle("Cherenkov","Cherenkov",0,kFALSE,
-                       0,0,"Special",50000050);
-
-  if ( !pdgDB->GetParticle(50000051) )
-    pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
-                       0,0,"Special",50000051);
+    TDatabasePDG* pdgDB = TDatabasePDG::Instance();
+
+    const Double_t kAu2Gev = 0.9314943228;
+    const Double_t khSlash = 1.0545726663e-27;
+    const Double_t kErg2Gev = 1/1.6021773349e-3;
+    const Double_t khShGev = khSlash*kErg2Gev;
+    const Double_t kYear2Sec = 3600*24*365.25;
+
+    // Ions
+    if (!pdgDB->GetParticle(1000010020))
+        pdgDB->AddParticle("Deuteron","Deuteron", 2*kAu2Gev+8.071e-3,kTRUE, 0, 3, "Ion", 1000010020);
+
+    if (!pdgDB->GetParticle(1000010030))
+        pdgDB->AddParticle("Triton","Triton", 3*kAu2Gev+14.931e-3, kFALSE, khShGev/(12.33*kYear2Sec), 3, "Ion", 1000010030);
+
+    if (!pdgDB->GetParticle(1000020040))
+        pdgDB->AddParticle("Alpha","Alpha", 4*kAu2Gev+2.424e-3, kTRUE, khShGev/(12.33*kYear2Sec), 6, "Ion", 1000020040);
+
+    if (!pdgDB->GetParticle(1000020030))
+        pdgDB->AddParticle("HE3","HE3", 3*kAu2Gev+14.931e-3, kFALSE, 0, 6, "Ion", 1000020030);
+
+    // Special particles
+    if (!pdgDB->GetParticle(50000050))
+        pdgDB->AddParticle("Cherenkov","Cherenkov", 0, kFALSE, 0, 0, "Special", 50000050);
+
+    if (!pdgDB->GetParticle(50000051))
+        pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton", 0, kFALSE, 0, 0, "Special", 50000051);
 }
diff --git a/eventdisplay/FairEventManager.h b/eventdisplay/FairEventManager.h
index fa05774..83e3684 100644
--- a/eventdisplay/FairEventManager.h
+++ b/eventdisplay/FairEventManager.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /**
 * class for event management and navigation.
 * 06.12.07 M.Al-Turany
@@ -5,22 +12,16 @@
 #ifndef FairEventManager_H
 #define FairEventManager_H
 
-#include "TEveEventManager.h"           // for TEveEventManager
+#include "FairRootManager.h"
+#include "FairRunAna.h"
+#include "FairTask.h"
 
-#include "FairRunAna.h"                 // for FairRunAna
-
-#include "Rtypes.h"                     // for Float_t, Int_t, Bool_t, etc
-
-//new
 #include <TEveViewer.h>
-#include <TGLViewer.h>
+#include "TEveEventManager.h"
 #include <TEveScene.h>
 #include <TGeoNode.h>
 #include <TEveProjectionManager.h>
-
-class FairRootManager; //does not work with streamer, reason unclear
-class FairTask;
-class TGListTreeItem;
+#include "TGListTree.h"
 
 class FairEventManager : public TEveEventManager
 {
@@ -68,32 +69,33 @@ class FairEventManager : public TEveEventManager
     static FairEventManager* Instance();
     FairEventManager();
     virtual ~FairEventManager();
+
     virtual void Open();
     virtual void GotoEvent(Int_t event);    // *MENU*
     virtual void NextEvent();               // *MENU*
     virtual void PrevEvent();               // *MENU*
     virtual void Close();
     virtual void DisplaySettings();         //  *Menu*
+    void UpdateEditor();
     virtual Int_t Color(Int_t pdg);
-    void AddTask(FairTask* t) {fRunAna->AddTask(t);}
+    void AddTask(FairTask* t) { fRunAna->AddTask(t); }
     virtual void Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000);
-    virtual Int_t GetCurrentEvent() {return fEntry;}
-    virtual void SetPriOnly(Bool_t Pri) {fPriOnly=Pri;}
-    virtual Bool_t IsPriOnly() {return fPriOnly;}
-    virtual void SelectPDG(Int_t PDG) {fCurrentPDG=PDG;}
-    virtual Int_t GetCurrentPDG() {return fCurrentPDG;}
-
-    virtual void SetMaxEnergy(Float_t max) {fMaxEnergy = max;}
-    virtual void SetMinEnergy(Float_t min) {fMinEnergy = min;}
-    virtual void SetEvtMaxEnergy(Float_t max) {fEvtMaxEnergy = max;}
-    virtual void SetEvtMinEnergy(Float_t min) {fEvtMinEnergy = min;}
-    virtual Float_t GetEvtMaxEnergy() {return fEvtMaxEnergy;}
-    virtual Float_t GetEvtMinEnergy() {return fEvtMinEnergy;}
-    virtual Float_t GetMaxEnergy() {return fMaxEnergy;}
-    virtual Float_t GetMinEnergy() {return fMinEnergy;}
-
-    void UpdateEditor();
-    virtual void AddParticlesToPdgDataBase(Int_t pdg=0);
+    virtual Int_t GetCurrentEvent() { return fEntry; }
+    virtual void SetPriOnly(Bool_t Pri) { fPriOnly = Pri; }
+    virtual Bool_t IsPriOnly() { return fPriOnly; }
+    virtual void SelectPDG(Int_t PDG) { fCurrentPDG = PDG; }
+    virtual Int_t GetCurrentPDG() { return fCurrentPDG; }
+    virtual void AddParticlesToPdgDataBase( Int_t pdg = 0 );
+
+    virtual void SetCurrentEvent(Int_t event_number) { fEntry = event_number; }
+    virtual void SetMaxEnergy(Float_t max) { fMaxEnergy = max; }
+    virtual void SetMinEnergy(Float_t min) { fMinEnergy = min; }
+    virtual void SetEvtMaxEnergy(Float_t max) { fEvtMaxEnergy = max; }
+    virtual void SetEvtMinEnergy(Float_t min) { fEvtMinEnergy = min; }
+    virtual Float_t GetEvtMaxEnergy() { return fEvtMaxEnergy; }
+    virtual Float_t GetEvtMinEnergy() { return fEvtMinEnergy; }
+    virtual Float_t GetMaxEnergy() { return fMaxEnergy; }
+    virtual Float_t GetMinEnergy() { return fMinEnergy; }
 
     //MultiView features
     void SetDepth(Float_t d);
@@ -126,33 +128,61 @@ class FairEventManager : public TEveEventManager
     // scene for event presenation in RPhoZ plane
     TEveScene* fRhoZEventScene;
 
+    // background color of EVE Viewers
     int background_color;
-
+    // whether background color is dark
+    bool isDarkColor;
+    // event count
+    Long64_t fEntryCount; //!
+    // whether Online of Offline mode
+    bool isOnline;
+    // data source: 0 - simulation data; 1 - raw detector data
+    int iDataSource;
+
+    // Event Elements of Event Scene
     TEveElementList* EveMCPoints, *EveMCTracks, *EveRecoPoints, *EveRecoTracks;
-
-    ClassDef(FairEventManager,1);
+    // ZDC module visibility flags. NULL if there are no ZDC modules to show
+    bool* isZDCModule; //!
+    // require event redraw after "reco points" checkbox value is changed
+    bool fgRedrawRecoPointsReqired;
+    // current value of "reco points" checkbox
+    bool fgShowRecoPointsIsShow;
+
+    // set high (80) transparency for detector geometry
+    void SelectedGeometryTransparent(bool is_on);
+    void RecursiveChangeNodeTransparent(TGeoNode* parentNode, int transparency);
+
+    // FairRunAna to init and to execute visualization tasks
+    FairRunAna* fRunAna; //!
+
+    //returns loaded xml if successful of NULL if validation failed
+    bool ValidateXml(const char *XMLFileName, const char *XSDFileName);
+    //coloring method
+    enum VisualizationColoring {selectedColoring, levelColoring, defaultColoring};
+    VisualizationColoring gVisualizationColoring;
   private:
     FairRootManager* fRootManager; //!
-    Int_t fEntry;                 //!
-    FairRunAna* fRunAna;          //!
-    TGListTreeItem*  fEvent;     //!
-    Bool_t fPriOnly;             //!
-    Int_t fCurrentPDG;           //!
+    TGListTreeItem* fEvent; //!
+    // current event number
+    Int_t fEntry; //!
+    Bool_t fPriOnly; //!
+    Int_t fCurrentPDG; //!
     // the most minimum particle energy for selected event
-    Float_t fMinEnergy;         //!
+    Float_t fMinEnergy; //!
     // the most maximum particle energy for selected event
-    Float_t fMaxEnergy;         //!
+    Float_t fMaxEnergy; //!
     // minimum energy to cut particles by energy in selected event
-    Float_t fEvtMinEnergy;      //!
+    Float_t fEvtMinEnergy; //!
     // maximum energy to cut particles by energy in selected event
-    Float_t fEvtMaxEnergy;      //!
+    Float_t fEvtMaxEnergy; //!
 
+    // skeleton Singleton Instance
     static FairEventManager* fgRinstance; //!
 
     int cntSelectedColoring;
     structSelectedColoring* arrSelectedColoring; //!
     int cntLevelColoring;
-    structLevelColoring* arrLevelColoring;       //!
+    structLevelColoring* arrLevelColoring; //!
 
     FairEventManager(const FairEventManager&);
     FairEventManager& operator=(const FairEventManager&);
@@ -165,6 +195,8 @@ class FairEventManager : public TEveEventManager
     void LevelChangeNodeProperty(TGeoNode* node, int level);
     void SelectedGeometryColoring();
     void RecursiveChangeNodeProperty(TGeoNode* parentNode, Int_t color, int transparency);
+
+    ClassDef(FairEventManager,1);
 };
 
 #endif
diff --git a/eventdisplay/FairEventManagerEditor.cxx b/eventdisplay/FairEventManagerEditor.cxx
index 4ffc0a2..90aa69b 100644
--- a/eventdisplay/FairEventManagerEditor.cxx
+++ b/eventdisplay/FairEventManagerEditor.cxx
@@ -1,45 +1,43 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include "FairEventManagerEditor.h"
-
-#include "FairEventManager.h"           // for FairEventManager
-#include "FairRootManager.h"            // for FairRootManager
-#include "FairRunAna.h"                 // for FairRunAna
-
-#include "TChain.h"                     // for TChain
-#include "TEveGValuators.h"             // for TEveGValuator
-#include "TFile.h"                      // for TFile
-#include "TGButton.h"                   // for TGCheckButton, TGTextButton
-#include "TGLabel.h"                    // for TGLabel
-#include "TGLayout.h"                   // for TGLayoutHints, etc
-#include "TGNumberEntry.h"              // for TGNumberEntry, etc
-#include "TGeoManager.h"                // for TGeoManager, gGeoManager
-#include "TString.h"                    // for TString
-#include "TEveManager.h"                // for TEveManager, gEve
-#include "TEveElement.h"                // for TEveElement
-#include "TPRegexp.h"
-
-#include <stddef.h>                     // for NULL
+#include "FairRootManager.h"
+#include "FairRunAna.h"
+
+#include "TChain.h"
+#include "TFile.h"
+#include "TGLayout.h"
+#include "TGeoManager.h"
+#include "TString.h"
+#include "TEveManager.h"
+#include "TEveElement.h"
+#include "TEvePointSet.h"
+#include "TVector3.h"
+#include "TObject.h"
+#include "TGWindow.h"
+#include <TGLViewer.h>
+#include <TGLScenePad.h>
 
 #include <iostream>
 using namespace std;
 
-class TGWindow;
-class TObject;
-
-#define MAXE 12
+#define MAX_ENERGY 12
 
 //______________________________________________________________________________
 // FairEventManagerEditor
 //
 // Specialization of TGedEditor for proper update propagation to
 // TEveManager.
-
-ClassImp(FairEventManagerEditor)
-
+ClassImp(FairEventManagerEditor);
 
 //______________________________________________________________________________
-FairEventManagerEditor::FairEventManagerEditor(const TGWindow* p, Int_t width, Int_t height,
-    UInt_t options, Pixel_t back)
-  :TGedFrame(p, width, height, options | kVerticalFrame, back),
+FairEventManagerEditor::FairEventManagerEditor(const TGWindow* p, Int_t width, Int_t height, UInt_t options, Pixel_t back)
+  : TGedFrame(p, width, height, options | kVerticalFrame, back),
    fObject(0),
    fManager(FairEventManager::Instance()),
    fCurrentEvent(0),
@@ -47,176 +45,244 @@ FairEventManagerEditor::FairEventManagerEditor(const TGWindow* p, Int_t width, I
    fVizPri(0),
    fMinEnergy(0),
    fMaxEnergy(0),
-   iCurrentEvent(-1)
+   iEventNumber(-1),
+   iEventCount(-1),
+   iThreadState(0)
 {
-  Init();
+    Init();
 }
 
 void FairEventManagerEditor::Init()
 {
-  // get input file
-  FairRootManager* fRootManager=FairRootManager::Instance();
-  TChain* chain =fRootManager->GetInChain();
-  Int_t Entries= chain->GetEntriesFast();
-
-  // create tab for event visualization
-  MakeTitle("FairEventManager  Editor");
-  TGVerticalFrame*      fInfoFrame= CreateEditorTabSubFrame("Event Info");
-  title1 = new TGCompositeFrame(fInfoFrame, 250, 10,
-      kVerticalFrame | kLHintsExpandX |
-      kFixedWidth    | kOwnBackground);
-
-  // display file name
-  TString Infile= "file : ";
-//  TFile* file =FairRunAna::Instance()->GetInputFile();
-  TFile* file =FairRootManager::Instance()->GetInChain()->GetFile();
-  Infile+=file->GetName();
-  TGLabel* TFName=new TGLabel(title1, Infile.Data());
-  title1->AddFrame(TFName);
-
-  // display Run ID
-  UInt_t RunId= FairRunAna::Instance()->getRunId();
-  TString run= "Run Id : ";
-  run += RunId;
-  TGLabel* TRunId=new TGLabel(title1, run.Data());
-  title1->AddFrame(TRunId);
-
-  // display event count
-  TString nevent= "No of events : ";
-  nevent +=Entries ;
-  TGLabel* TEvent=new TGLabel(title1, nevent.Data());
-  title1->AddFrame(TEvent);
-
-  // count of geometry nodes
-  Int_t nodes= gGeoManager->GetNNodes();
-  TString NNodes= "No. of Nodes : ";
-  NNodes += nodes;
-  TGLabel* NoNode=new TGLabel(title1, NNodes.Data());
-  title1->AddFrame(NoNode);
-
-  // setting textbox for event number
-  TGHorizontalFrame* f = new TGHorizontalFrame(title1);
-  TGLabel* l = new TGLabel(f, "Current Event:");
-  f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
-  fCurrentEvent = new TGNumberEntry(f, 0., 6, -1,
-                                    TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative,
-                                    TGNumberFormat::kNELLimitMinMax, 0, Entries-1);
-  f->AddFrame(fCurrentEvent, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
-  fCurrentEvent->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectEvent()");
-  title1->AddFrame(f);
-
-  // textbox for time cutting
-  TGHorizontalFrame* f2 = new TGHorizontalFrame(title1);
-  TGLabel* EventTimeLabel = new TGLabel(f2, "Event Time: ");
-  fEventTime = new TGLabel(f2,"");
-  f2->AddFrame(EventTimeLabel);
-  f2->AddFrame(fEventTime);
-  title1->AddFrame(f2);
-
-  // checkbox to display only primary particles in event
-  fVizPri = new TGCheckButton(title1, "Primary Only");
-  AddFrame(fVizPri, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
-  fVizPri->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "DoVizPri()");
-  title1->AddFrame(fVizPri);
-
-  // textbox to display only particles with given PDG
-  TGHorizontalFrame* f1 = new TGHorizontalFrame(title1);
-  TGLabel* L1 = new TGLabel(f1, "Select PDG :");
-  f1->AddFrame(L1, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 1, 2, 1, 1));
-  fCurrentPDG = new TGNumberEntry(f1, 0., 12, -1,
-                                  TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber,
-                                  TGNumberFormat::kNELNoLimits, 0, 1);
-  f1->AddFrame(fCurrentPDG, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
-  fCurrentPDG->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectPDG()");
-  title1->AddFrame(f1);
-
-
-  // textbox for min energy cutting
-  fMinEnergy = new TEveGValuator(title1, "Min Energy:", 90, 0);
-  fMinEnergy->SetNELength(5);
-  fMinEnergy->SetLabelWidth(80);
-  fMinEnergy->Build();
-  fMinEnergy->SetLimits(0, MAXE, 2501, TGNumberFormat::kNESRealOne);
-  fMinEnergy->SetToolTip("Minimum energy of displayed tracks");
-  fMinEnergy->SetValue(0);
-  fMinEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor", this, "MinEnergy()");
-  title1->AddFrame(fMinEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
-  fManager->SetMinEnergy(0);
-
-  // textbox for max energy cutting
-  fMaxEnergy = new TEveGValuator(title1, "Max Energy:", 90, 0);
-  fMaxEnergy->SetNELength(5);
-  fMaxEnergy->SetLabelWidth(80);
-  fMaxEnergy->Build();
-  fMaxEnergy->SetLimits(0, MAXE, 2501, TGNumberFormat::kNESRealOne);
-  fMaxEnergy->SetToolTip("Maximum energy of displayed tracks");
-  fMaxEnergy->SetValue(MAXE);
-  fMaxEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor", this, "MaxEnergy()");
-  title1->AddFrame(fMaxEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
-  fManager->SetMaxEnergy(MAXE);
-
-  // button: whether show detector geometry or not
-  TGCheckButton* fGeometry = new TGCheckButton(title1, "show geometry");
-  title1->AddFrame(fGeometry, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
-  fGeometry->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowGeometry(Bool_t)");
-  fGeometry->SetOn();
-
-  // button for switching from black to white background
-  TGCheckButton* fBackground = new TGCheckButton(title1, "light background");
-  title1->AddFrame(fBackground, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
-  fBackground->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "SwitchBackground(Bool_t)");
-
-  // group for displaying simulation and reconstruction data
-  groupData = new TGGroupFrame(title1, "Show MC and reco data");
-  groupData->SetTitlePos(TGGroupFrame::kCenter);
-
-  TGHorizontalFrame* framePointsInfo = new TGHorizontalFrame(groupData);
-  // button for show|hide MC points
-  fShowMCPoints = new TGCheckButton(framePointsInfo, "MC points");
-  framePointsInfo->AddFrame(fShowMCPoints, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
-  fShowMCPoints->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowMCPoints(Bool_t)");
-
-  // button for show|hide reconstructed points
-  fShowRecoPoints = new TGCheckButton(framePointsInfo, "Reco points");
-  framePointsInfo->AddFrame(fShowRecoPoints, new TGLayoutHints(kLHintsRight, 0,0,1,0));
-  fShowRecoPoints->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowRecoPoints(Bool_t)");
-  groupData->AddFrame(framePointsInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
-
-  TGHorizontalFrame* frameTracksInfo = new TGHorizontalFrame(groupData);
-  // button for show|hide MC tracks
-  fShowMCTracks = new TGCheckButton(frameTracksInfo, "MC tracks");
-  frameTracksInfo->AddFrame(fShowMCTracks, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
-  fShowMCTracks->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowMCTracks(Bool_t)");
-
-  // button for show|hide reco tracks
-  fShowRecoTracks = new TGCheckButton(frameTracksInfo, "Reco tracks");
-  frameTracksInfo->AddFrame(fShowRecoTracks, new TGLayoutHints(kLHintsRight, 0,0,1,0));
-  fShowRecoTracks->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowRecoTracks(Bool_t)");
-  groupData->AddFrame(frameTracksInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
-
-  title1->AddFrame(groupData, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
-
-  // button for update of event visualization
-  TGTextButton* fUpdate = new TGTextButton(title1, "Update");
-  title1->AddFrame(fUpdate, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
-  fUpdate->Connect("Clicked()", "FairEventManagerEditor", this, "SelectEvent()");
-
-  // add all frame above to "event info" tab
-  fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
+    TChain* chain = FairRootManager::Instance()->GetInChain();
+
+    // create tab for event visualization
+    MakeTitle("FairEventManager  Editor");
+    TGVerticalFrame* fInfoFrame = CreateEditorTabSubFrame("Event Info");
+    title1 = new TGCompositeFrame(fInfoFrame, 250, 10, kVerticalFrame | kLHintsExpandX | kFixedWidth | kOwnBackground);
+
+    // display file name
+    TString Infile = "File: ";
+    Infile += chain->GetFile()->GetName();
+    TGLabel* TFName = new TGLabel(title1, Infile.Data());
+    title1->AddFrame(TFName);
+
+    // textbox for Run ID and time cutting
+    TGHorizontalFrame* f2 = new TGHorizontalFrame(title1);
+    // Run Id
+    UInt_t RunId = FairRunAna::Instance()->getRunId();
+    TString run = TString::Format("Run Id: %d. ", RunId);
+    TGLabel* TRunId = new TGLabel(f2, run.Data());
+    // time cutting
+    TGLabel* EventTimeLabel = new TGLabel(f2, " Event Time: ");
+    fEventTime = new TGLabel(f2,"");
+    f2->AddFrame(TRunId);
+    f2->AddFrame(EventTimeLabel);
+    f2->AddFrame(fEventTime);
+    title1->AddFrame(f2);
+
+    // display event count and count of geometry nodes
+    iEventCount = chain->GetEntriesFast();
+    Int_t nodes = gGeoManager->GetNNodes();
+    TString nevent = TString::Format("No of events: %d. No. of nodes: %d", iEventCount, nodes);
+    TGLabel* TEvent = new TGLabel(title1, nevent.Data());
+    title1->AddFrame(TEvent);
+
+    // setting textbox for event number
+    TGHorizontalFrame* f = new TGHorizontalFrame(title1);
+    TGLabel* l = new TGLabel(f, "Current Event:");
+    f->AddFrame(l, new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 1, 2, 1, 1));
+    fCurrentEvent = new TGNumberEntry(f, 0., 6, -1,
+                        TGNumberFormat::kNESInteger, TGNumberFormat::kNEANonNegative, TGNumberFormat::kNELLimitMinMax, 0, iEventCount-1);
+    f->AddFrame(fCurrentEvent, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+    fCurrentEvent->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectEvent()");
+    if (iEventCount< 1)
+        fCurrentEvent->SetState(kFALSE);
+
+    //Button for save image (EVE screenshot)
+    fSave = new TGPictureButton(f, gClient->GetPicture("save.xpm"), 5);
+    f->AddFrame(fSave, new TGLayoutHints(kLHintsLeft| kLHintsCenterY, 1, 2, 1, 1));
+    fSave->Connect("Clicked()", "FairEventManagerEditor", this, "SaveImage()");
+    title1->AddFrame(f);
+
+    // checkbox to display only primary particles in event
+    fVizPri = new TGCheckButton(title1, "Primary Only");
+    AddFrame(fVizPri, new TGLayoutHints(kLHintsTop, 3, 1, 1, 0));
+    fVizPri->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "DoVizPri()");
+    title1->AddFrame(fVizPri);
+
+    // textbox to display only particles with given PDG
+    TGHorizontalFrame* f1 = new TGHorizontalFrame(title1);
+    TGLabel* L1 = new TGLabel(f1, "Select PDG :");
+    f1->AddFrame(L1, new TGLayoutHints(kLHintsLeft|kLHintsCenterY, 1, 2, 1, 1));
+    fCurrentPDG = new TGNumberEntry(f1, 0., 12, -1,
+                      TGNumberFormat::kNESInteger, TGNumberFormat::kNEAAnyNumber, TGNumberFormat::kNELNoLimits, 0, 1);
+    f1->AddFrame(fCurrentPDG, new TGLayoutHints(kLHintsLeft, 1, 1, 1, 1));
+    fCurrentPDG->Connect("ValueSet(Long_t)","FairEventManagerEditor", this, "SelectPDG()");
+    title1->AddFrame(f1);
+
+    // textbox for min energy cutting
+    fMinEnergy = new TEveGValuator(title1, "Min Energy:", 90, 0);
+    fMinEnergy->SetNELength(5);
+    fMinEnergy->SetLabelWidth(80);
+    fMinEnergy->Build();
+    fMinEnergy->SetLimits(0, MAX_ENERGY, 2501, TGNumberFormat::kNESRealOne);
+    fMinEnergy->SetToolTip("Minimum energy of displayed tracks");
+    fMinEnergy->SetValue(0);
+    fMinEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor", this, "MinEnergy()");
+    title1->AddFrame(fMinEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
+    fManager->SetMinEnergy(0);
+
+    // textbox for max energy cutting
+    fMaxEnergy = new TEveGValuator(title1, "Max Energy:", 90, 0);
+    fMaxEnergy->SetNELength(5);
+    fMaxEnergy->SetLabelWidth(80);
+    fMaxEnergy->Build();
+    fMaxEnergy->SetLimits(0, MAX_ENERGY, 2501, TGNumberFormat::kNESRealOne);
+    fMaxEnergy->SetToolTip("Maximum energy of displayed tracks");
+    fMaxEnergy->SetValue(MAX_ENERGY);
+    fMaxEnergy->Connect("ValueSet(Double_t)", "FairEventManagerEditor", this, "MaxEnergy()");
+    title1->AddFrame(fMaxEnergy, new TGLayoutHints(kLHintsTop, 1, 1, 1, 0));
+    fManager->SetMaxEnergy(MAX_ENERGY);
+
+    TGHorizontalFrame* fGeometryFrame = new TGHorizontalFrame(title1);
+    // button: whether show detector geometry or not
+    fGeometry = new TGCheckButton(fGeometryFrame, "show geometry");
+    fGeometryFrame->AddFrame(fGeometry, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,1,1));
+    fGeometry->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowGeometry(Bool_t)");
+    fGeometry->SetOn();
+    // button: whether show magnet or not
+    TGCheckButton* ShowMagnetButton = new TGCheckButton(fGeometryFrame, "show magnet");
+    fGeometryFrame->AddFrame(ShowMagnetButton, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 5,5,1,1));
+    ShowMagnetButton->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowMagnet(Bool_t)");
+    ShowMagnetButton->SetOn();
+    title1->AddFrame(fGeometryFrame);
+
+    // button for high transparency of detectors' geometry to highlight event objects
+    TGCheckButton* fTransparency = new TGCheckButton(title1, "high transparency");
+    title1->AddFrame(fTransparency, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
+    fTransparency->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "SwitchTransparency(Bool_t)");
+
+    // button for switching from black to white background
+    TGCheckButton* backgroundButton = new TGCheckButton(title1, "light background");
+    title1->AddFrame(backgroundButton, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 5,5,1,1));
+    backgroundButton->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "SwitchBackground(Bool_t)");
+    if (!fManager->isDarkColor)
+    {
+        backgroundButton->SetOn();
+        gEve->GetViewers()->SwitchColorSet();
+    }
+
+    // group for displaying simulation and reconstruction data
+    groupData = new TGGroupFrame(title1, "Show MC and reco data");
+    groupData->SetTitlePos(TGGroupFrame::kCenter);
+
+    TGHorizontalFrame* framePointsInfo = new TGHorizontalFrame(groupData);
+    // button for show|hide MC points
+    fShowMCPoints = new TGCheckButton(framePointsInfo, "MC points");
+    framePointsInfo->AddFrame(fShowMCPoints, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
+    fShowMCPoints->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowMCPoints(Bool_t)");
+    //fShowMCPoints->SetDisabledAndSelected(kFALSE);
+
+    // button for show|hide reconstructed points
+    fShowRecoPoints = new TGCheckButton(framePointsInfo, "Reco points");
+    framePointsInfo->AddFrame(fShowRecoPoints, new TGLayoutHints(kLHintsRight, 0,0,1,0));
+    fShowRecoPoints->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowRecoPoints(Bool_t)");
+    //fShowRecoPoints->SetDisabledAndSelected(kFALSE);
+    groupData->AddFrame(framePointsInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
+
+    TGHorizontalFrame* frameTracksInfo = new TGHorizontalFrame(groupData);
+    // button for show|hide MC tracks
+    fShowMCTracks = new TGCheckButton(frameTracksInfo, "MC tracks");
+    frameTracksInfo->AddFrame(fShowMCTracks, new TGLayoutHints(kLHintsNormal, 0,0,0,0));
+    fShowMCTracks->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowMCTracks(Bool_t)");
+    //fShowMCTracks->SetDisabledAndSelected(kFALSE);
+
+    // button for show|hide reco tracks
+    fShowRecoTracks = new TGCheckButton(frameTracksInfo, "Reco tracks");
+    frameTracksInfo->AddFrame(fShowRecoTracks, new TGLayoutHints(kLHintsRight, 0,0,1,0));
+    fShowRecoTracks->Connect("Toggled(Bool_t)", "FairEventManagerEditor", this, "ShowRecoTracks(Bool_t)");
+    //fShowRecoTracks->SetDisabledAndSelected(kFALSE);
+
+    groupData->AddFrame(frameTracksInfo, new TGLayoutHints(kLHintsNormal | kLHintsExpandX, 1,1,5,0));
+    title1->AddFrame(groupData, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
+
+    // button for update of event visualization
+    if (fManager->isOnline)
+        fUpdate = new TGTextButton(title1, "Start online display");
+    else
+        fUpdate = new TGTextButton(title1, "Update event");
+    title1->AddFrame(fUpdate, new TGLayoutHints(kLHintsRight | kLHintsExpandX, 3,15,1,1));
+    fUpdate->Connect("Clicked()", "FairEventManagerEditor", this, "UpdateEvent()");
+
+    // add all frame above to "event info" tab
+    fInfoFrame->AddFrame(title1, new TGLayoutHints(kLHintsTop, 0, 0, 2, 0));
+
+    if (iEventCount < 1)
+    {
+        fUpdate->SetEnabled(kFALSE);
+        return;
+    }
+
+    // read first event
+    iEventNumber = 0;
+    fManager->GotoEvent(iEventNumber);
+
+    // first time checking for active buttons
+    if (fManager->EveMCPoints == NULL)
+        fShowMCPoints->SetDisabledAndSelected(kFALSE);
+    else
+        fShowMCPoints->SetEnabled(kTRUE);
+    if (fManager->EveMCTracks == NULL)
+        fShowMCTracks->SetDisabledAndSelected(kFALSE);
+    else
+        fShowMCTracks->SetEnabled(kTRUE);
+    if (fManager->EveRecoPoints == NULL)
+        fShowRecoPoints->SetDisabledAndSelected(kFALSE);
+    else
+        fShowRecoPoints->SetEnabled(kTRUE);
+    if (fManager->EveRecoTracks == NULL)
+        fShowRecoTracks->SetDisabledAndSelected(kFALSE);
+    else
+        fShowRecoTracks->SetEnabled(kTRUE);
+
+    // display event time
+    TString time;
+    time.Form("%.2f", FairRootManager::Instance()->GetEventTime());
+    time += " ns";
+    fEventTime->SetText(time.Data());
+
+    // display and set new min and max energy limits given by event energy range
+    fMinEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+    fMinEnergy->SetValue(fManager->GetEvtMinEnergy());
+    MinEnergy();
+    fMaxEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+    fMaxEnergy->SetValue(fManager->GetEvtMaxEnergy());
+    MaxEnergy();
+
+    // update tab controls
+    Update();
 }
 
 //______________________________________________________________________________
-void FairEventManagerEditor::MaxEnergy()
+void FairEventManagerEditor::SetModel(TObject* obj)
 {
-    fManager->SetMaxEnergy(fMaxEnergy->GetValue());
+    fObject = obj;
 }
-//______________________________________________________________________________
+
+// set minimum energy for particle filtering
 void FairEventManagerEditor::MinEnergy()
 {
     fManager->SetMinEnergy(fMinEnergy->GetValue());
 }
 
-//______________________________________________________________________________
+// set maximum energy for particle filtering
+void FairEventManagerEditor::MaxEnergy()
+{
+    fManager->SetMaxEnergy(fMaxEnergy->GetValue());
+}
+
+// set flag: show all particles or only primary
 void FairEventManagerEditor::DoVizPri()
 {
     if (fVizPri->IsOn())
@@ -224,84 +290,69 @@ void FairEventManagerEditor::DoVizPri()
     else
         fManager->SetPriOnly(kFALSE);
 }
-//______________________________________________________________________________
+
+// select displaying particle by PDG code
 void FairEventManagerEditor::SelectPDG()
 {
     fManager->SelectPDG(fCurrentPDG->GetIntNumber());
 }
 
-//______________________________________________________________________________
-void FairEventManagerEditor::SetModel(TObject* obj)
+// show or hide detector geometry
+void FairEventManagerEditor::ShowGeometry(Bool_t is_show)
 {
-    fObject = obj;
+    gEve->GetGlobalScene()->SetRnrState(is_show);
+    if (!fManager->isOnline)
+    {
+        fManager->fRPhiGeomScene->SetRnrState(is_show);
+        fManager->fRhoZGeomScene->SetRnrState(is_show);
+    }
+
+    gEve->Redraw3D();
 }
 
-//______________________________________________________________________________
-void FairEventManagerEditor::SelectEvent()
+// show or hide magnet
+void FairEventManagerEditor::ShowMagnet(Bool_t is_show)
 {
-  int iNewEvent = fCurrentEvent->GetIntNumber();
-  // exec event visualization of selected event
-  fManager->GotoEvent(iNewEvent);
-
-  if (iCurrentEvent == -1)
-  {
-      if (fManager->EveMCPoints == NULL)
-          fShowMCPoints->SetDisabledAndSelected(kFALSE);
-      if (fManager->EveMCTracks == NULL)
-          fShowMCTracks->SetDisabledAndSelected(kFALSE);
-      if (fManager->EveRecoPoints == NULL)
-          fShowRecoPoints->SetDisabledAndSelected(kFALSE);
-      if (fManager->EveRecoTracks == NULL)
-          fShowRecoTracks->SetDisabledAndSelected(kFALSE);
-  }
-
-  if (iCurrentEvent != iNewEvent)
-  {
-      iCurrentEvent = iNewEvent;
-
-      // display event time
-      TString time;
-      time.Form("%.2f", FairRootManager::Instance()->GetEventTime());
-      time += " ns";
-      fEventTime->SetText(time.Data());
-
-      // new min and max energy limits given by event energy range
-      fMinEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
-      fMinEnergy->SetValue(fManager->GetEvtMinEnergy());
-      MinEnergy();
-      fMaxEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
-      fMaxEnergy->SetValue(fManager->GetEvtMaxEnergy());
-      MaxEnergy();
-  }
-
-  // update tab controls
-  Update();
-
-  // update all scenes
-  fManager->fRPhiView->GetGLViewer()->UpdateScene(kTRUE);
-  fManager->fRhoZView->GetGLViewer()->UpdateScene(kTRUE);
-  fManager->fMulti3DView->GetGLViewer()->UpdateScene(kTRUE);
-  fManager->fMultiRPhiView->GetGLViewer()->UpdateScene(kTRUE);
-  fManager->fMultiRhoZView->GetGLViewer()->UpdateScene(kTRUE);
+    TGeoVolume* magnet = gGeoManager->FindVolumeFast("Magnet");
+    if (!magnet)
+    {
+        cout<<"ERROR: There is no magnet with given name: Magnet"<<endl;
+        return;
+    }
+
+    magnet->SetVisibility(is_show);
+    magnet->VisibleDaughters(is_show);
+
+    if (gEve->GetGlobalScene()->GetRnrState())
+    {
+        gEve->GetGlobalScene()->SetRnrState(kFALSE);
+        gEve->GetGlobalScene()->SetRnrState(kTRUE);
+    }
+
+    gEve->Redraw3D();
 }
 
-//______________________________________________________________________________
+// switch between light and dark background
 void FairEventManagerEditor::SwitchBackground(Bool_t is_on)
 {
     gEve->GetViewers()->SwitchColorSet();
 }
 
-//______________________________________________________________________________
-void FairEventManagerEditor::ShowGeometry(Bool_t is_show)
+// set transparency to high value (80%)
+void FairEventManagerEditor::SwitchTransparency(Bool_t is_on)
 {
-    gEve->GetGlobalScene()->SetRnrState(is_show);
-    fManager->fRPhiGeomScene->SetRnrState(is_show);
-    fManager->fRhoZGeomScene->SetRnrState(is_show);
+    fManager->SelectedGeometryTransparent(is_on);
+
+    if (gEve->GetGlobalScene()->GetRnrState())
+    {
+        gEve->GetGlobalScene()->SetRnrState(kFALSE);
+        gEve->GetGlobalScene()->SetRnrState(kTRUE);
+    }
 
     gEve->Redraw3D();
 }
 
-//______________________________________________________________________________
+// show|hide MC points
 void FairEventManagerEditor::ShowMCPoints(Bool_t is_show)
 {
     /*
@@ -319,14 +370,117 @@ void FairEventManagerEditor::ShowMCPoints(Bool_t is_show)
     if (points == NULL)
     {
         cout<<"There is no information about MC points"<<endl;
-        fShowMCPoints->SetOn(kFALSE);
+        fShowMCPoints->SetDisabledAndSelected(kFALSE);
         return;
     }
 
     points->SetRnrState(is_show);
+
+    // highlight ZDC modules if ZDC present
+    if (fManager->isZDCModule)
+    {
+        if (is_show)
+            RedrawZDC();
+        else
+            RestoreZDC();
+    }
+
+    // redraw points
     gEve->Redraw3D();
 }
 
+bool FairEventManagerEditor::RedrawZDC(bool isRedraw)
+{
+    TGeoVolume* curVolume = gGeoManager->GetVolume("VETO");
+    if (!curVolume)
+    {
+        cout<<"ERROR: There is no volume with given name: VETO"<<endl;
+        return false;
+    }
+    else
+    {
+        int i = 0;
+        for (; i < 68; i++)
+        {
+            TGeoNode* child = curVolume->FindNode(Form("VMDL_%d", i+1));
+            if (child == NULL)
+                continue;
+            //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
+
+            child->SetVisibility(fManager->isZDCModule[i]);
+            child->VisibleDaughters(fManager->isZDCModule[i]);
+        }
+
+        for (; i < 104; i++)
+        {
+            TGeoNode* child = curVolume->FindNode(Form("UMDL_%d", i+1-68));
+            if (child == NULL)
+                continue;
+            //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
+
+            child->SetVisibility(fManager->isZDCModule[i]);
+            child->VisibleDaughters(fManager->isZDCModule[i]);
+        }
+
+        if ((isRedraw) && (gEve->GetGlobalScene()->GetRnrState()))
+        {
+            gEve->GetGlobalScene()->SetRnrState(kFALSE);
+            gEve->GetGlobalScene()->SetRnrState(kTRUE);
+
+            return true;
+        }
+    }// else - ZDC detector was found
+
+    return false;
+}
+
+void FairEventManagerEditor::RestoreZDC()
+{
+    TGeoVolume* curVolume = gGeoManager->GetVolume("VETO");
+    if (!curVolume)
+    {
+        cout<<"ERROR: There is no volume with given name: VETO"<<endl;
+        return;
+    }
+    else
+    {
+        int i = 0;
+        for (; i < 68; i++)
+        {
+            TGeoNode* child = curVolume->FindNode(Form("VMDL_%d", i+1));
+            if (child == NULL)
+                continue;
+            //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
+
+            if (fManager->isZDCModule[i] == false)
+            {
+                child->SetVisibility(true);
+                child->VisibleDaughters(true);
+            }
+        }
+
+        for (; i < 104; i++)
+        {
+            TGeoNode* child = curVolume->FindNode(Form("UMDL_%d", i+1-68));
+            if (child == NULL)
+                continue;
+            //cout<<"Node: "<<child->GetName()<<". Number is equal "<<i<<endl;
+
+            if (fManager->isZDCModule[i] == false)
+            {
+                child->SetVisibility(true);
+                child->VisibleDaughters(true);
+            }
+        }
+
+        if (gEve->GetGlobalScene()->GetRnrState())
+        {
+            gEve->GetGlobalScene()->SetRnrState(kFALSE);
+            gEve->GetGlobalScene()->SetRnrState(kTRUE);
+        }
+    }// else - ZDC detector was found
+}
+
 //______________________________________________________________________________
 void FairEventManagerEditor::ShowMCTracks(Bool_t is_show)
 {
@@ -334,7 +488,7 @@ void FairEventManagerEditor::ShowMCTracks(Bool_t is_show)
     if (tracks == NULL)
     {
         cout<<"There is no information about MC tracks"<<endl;
-        fShowMCTracks->SetOn(kFALSE);
+        fShowMCTracks->SetDisabledAndSelected(kFALSE);
         return;
     }
 
@@ -349,10 +503,15 @@ void FairEventManagerEditor::ShowRecoPoints(Bool_t is_show)
     if (points == NULL)
     {
         cout<<"There is no information about reconstructed points"<<endl;
-        fShowRecoPoints->SetOn(kFALSE);
+        fShowRecoPoints->SetDisabledAndSelected(kFALSE);
         return;
     }
 
+    fManager->fgShowRecoPointsIsShow = is_show;
+    // exec event visualization of selected event
+    if (fManager->fgRedrawRecoPointsReqired)
+        fManager->GotoEvent(fCurrentEvent->GetIntNumber());
+
     points->SetRnrState(is_show);
     gEve->Redraw3D();
 }
@@ -364,10 +523,210 @@ void FairEventManagerEditor::ShowRecoTracks(Bool_t is_show)
     if (tracks == NULL)
     {
         cout<<"There is no information about reconstructed tracks"<<endl;
-        fShowRecoTracks->SetOn(kFALSE);
+        fShowRecoTracks->SetDisabledAndSelected(kFALSE);
         return;
     }
 
     tracks->SetRnrState(is_show);
     gEve->Redraw3D();
 }
+
+void FairEventManagerEditor::BlockUI()
+{
+    //fCurrentEvent->SetState(kFALSE);
+    //fUpdate->SetEnabled(kFALSE);
+    fUpdate->SetText("Stop online display");
+    //fGeometry->SetEnabled(kFALSE);
+}
+
+void FairEventManagerEditor::UnblockUI()
+{
+    //fCurrentEvent->SetState(kTRUE);
+    //fUpdate->SetEnabled(kTRUE);
+    fUpdate->SetText("Start online display");
+    //fGeometry->SetEnabled(kTRUE);
+}
+
+// update event display when setting event number in textbox
+void FairEventManagerEditor::SelectEvent()
+{
+    // if OFFLINE mode
+    if (!fManager->isOnline)
+    {
+        int iNewEvent = fCurrentEvent->GetIntNumber();
+        // exec event visualization of selected event
+        fManager->GotoEvent(iNewEvent);
+
+        if ((fManager->isZDCModule) && (fShowMCPoints->IsOn()))
+            RedrawZDC();
+
+        if (iEventNumber != iNewEvent)
+        {
+            iEventNumber = iNewEvent;
+
+            // display event time
+            TString time;
+            time.Form("%.2f", FairRootManager::Instance()->GetEventTime());
+            time += " ns";
+            fEventTime->SetText(time.Data());
+
+            // display and set new min and max energy limits given by event energy range
+            fMinEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+            fMinEnergy->SetValue(fManager->GetEvtMinEnergy());
+            MinEnergy();
+            fMaxEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+            fMaxEnergy->SetValue(fManager->GetEvtMaxEnergy());
+            MaxEnergy();
+        }
+
+        // update tab controls
+        Update();
+
+        return;
+    }
+
+    /*// update all scenes
+    fManager->fRPhiView->GetGLViewer()->UpdateScene(kTRUE);
+    fManager->fRhoZView->GetGLViewer()->UpdateScene(kTRUE);
+    fManager->fMulti3DView->GetGLViewer()->UpdateScene(kTRUE);
+    fManager->fMultiRPhiView->GetGLViewer()->UpdateScene(kTRUE);
+    fManager->fMultiRhoZView->GetGLViewer()->UpdateScene(kTRUE);*/
+}
+
+
+// update event display when clicking Update button
+void FairEventManagerEditor::UpdateEvent()
+{
+    if (iThreadState == 1)
+    {
+        iThreadState = 0;
+        return;
+    }
+
+    // if OFFLINE mode
+    if (!fManager->isOnline)
+    {
+        int iNewEvent = fCurrentEvent->GetIntNumber();
+        // exec event visualization of selected event
+        fManager->GotoEvent(iNewEvent);
+
+        if ((fManager->isZDCModule) && (fShowMCPoints->IsOn()))
+            RedrawZDC();
+
+        if (iEventNumber != iNewEvent)
+        {
+            iEventNumber = iNewEvent;
+
+            // display event time
+            TString time;
+            time.Form("%.2f", FairRootManager::Instance()->GetEventTime());
+            time += " ns";
+            fEventTime->SetText(time.Data());
+
+            // display and set new min and max energy limits given by event energy range
+            fMinEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+            fMinEnergy->SetValue(fManager->GetEvtMinEnergy());
+            MinEnergy();
+            fMaxEnergy->SetLimits(fManager->GetEvtMinEnergy(), fManager->GetEvtMaxEnergy(), 100);
+            fMaxEnergy->SetValue(fManager->GetEvtMaxEnergy());
+            MaxEnergy();
+        }
+
+        // update tab controls
+        Update();
+
+        return;
+    }
+    // if ONLINE mode
+    else
+    {
+        // block user interface to exclude sharing of Redraw access
+        BlockUI();
+
+        // Run separate thread for Online Display
+        ThreadParam_OnlineDisplay* par_online_display = new ThreadParam_OnlineDisplay();
+        par_online_display->fEventManager = fManager;
+        par_online_display->fManagerEditor = this;
+        par_online_display->fRootManager = FairRootManager::Instance();
+        par_online_display->isZDCRedraw = false;
+        if ((fManager->isZDCModule) && (fShowMCPoints->IsOn()))
+            par_online_display->isZDCRedraw = true;
+        par_online_display->iCurrentEvent = fCurrentEvent->GetIntNumber();
+
+        TThread* thread_run_online = new TThread(RunOnlineDisplay, (void*)par_online_display);
+        iThreadState = 1;
+        thread_run_online->Run();
+
+        return;
+    }
+}
+
+void FairEventManagerEditor::SaveImage()
+{
+    const char* filetypes[] = {"PNG", "*.png", "JPG", "*.jpg", 0, 0};
+    TGFileInfo fi;
+    fi.fFileTypes = filetypes;
+    fi.fIniDir    = StrDup(".");
+    new TGFileDialog(gClient->GetRoot(), gEve->GetMainWindow(), kFDSave, &fi);
+
+    printf("Saving file: %s (dir: %s)\n", fi.fFilename, fi.fIniDir);
+    gEve->GetDefaultGLViewer()-> SavePicture(fi.fFilename);
+
+    return;
+}
+
+// thread function for Online Display
+void* RunOnlineDisplay(void* ptr)
+{
+    ThreadParam_OnlineDisplay* thread_par = (ThreadParam_OnlineDisplay*) ptr;
+    FairEventManager* fManager = thread_par->fEventManager;
+    FairEventManagerEditor* fEditor = thread_par->fManagerEditor;
+    FairRootManager* fRootManager = thread_par->fRootManager;
+    int current_event = thread_par->iCurrentEvent;
+    bool isZDCRedraw = thread_par->isZDCRedraw;
+
+    // get all tasks from FairRunAna
+    FairRunAna* pRun = fManager->fRunAna;
+    FairTask* pMainTask = pRun->GetMainTask();
+    TList* taskList = pMainTask->GetListOfTasks();
+
+    int i;
+    for (i = current_event+1; i < fEditor->iEventCount; i++)
+    {
+        if (fEditor->iThreadState == 0)
+            break;
+        do
+        {
+            TThread::Sleep(0, 200000000);
+        } while ((gEve->GetGlobalScene()->GetGLScene()->IsLocked()) || (gEve->GetEventScene()->GetGLScene()->IsLocked()));
+
+        fRootManager->ReadEvent(i);
+        fManager->SetCurrentEvent(i);
+
+        cout<<"Current event: "<<i<<endl;
+
+        int iter = 1;
+        TObjLink *lnk = taskList->FirstLink();
+        while (lnk)
+        {
+            FairTask* pCurTask = (FairTask*) lnk->GetObject();
+            pCurTask->ExecuteTask("");
+            cout<<"Complete task: "<<iter++<<endl;
+            lnk = lnk->Next();
+        }
+
+        fEditor->fCurrentEvent->SetIntNumber(i);
+
+        // highlight ZDC modules if ZDC present
+        if (isZDCRedraw)
+            fEditor->RedrawZDC();
+
+        // redraw points
+        gEve->Redraw3D();
+        //TThread::Sleep(1,0);
+        //gSystem->ProcessEvents();
+    }
+
+    fEditor->UnblockUI();
+    fEditor->iThreadState = 0;
+}
diff --git a/eventdisplay/FairEventManagerEditor.h b/eventdisplay/FairEventManagerEditor.h
index 5f6614b..10b9f45 100644
--- a/eventdisplay/FairEventManagerEditor.h
+++ b/eventdisplay/FairEventManagerEditor.h
@@ -5,44 +5,58 @@
 #ifndef ROOT_FAIREVENTMANAGEREDITOR
 #define ROOT_FAIREVENTMANAGEREDITOR
 
-#include "TGedFrame.h"                  // for TGedFrame
+#include "FairEventManager.h"
 
-#include "GuiTypes.h"                   // for Pixel_t
-#include "Rtypes.h"                     // for ClassDef
-#include "TGFrame.h"                    // for EFrameType::kChildFrame
+#include "TGedFrame.h"
+#include "TGNumberEntry.h"
+#include "TGButton.h"
+#include "TEveGValuators.h"
+#include "TGLabel.h"
+#include "TMutex.h"
+#include "TSemaphore.h"
+#include "TGFileDialog.h"
 
-class FairEventManager;
-class TEveGValuator;
-class TGCheckButton;
-class TGLabel;
-class TGNumberEntry;
-class TGWindow;
-class TObject;
+#include <vector>
 
-class FairEventManagerEditor : public TGedFrame
+class FairEventManagerEditor;
+struct ThreadParam_OnlineDisplay
 {
-    FairEventManagerEditor(const FairEventManagerEditor&);            // Not implemented
-    FairEventManagerEditor& operator=(const FairEventManagerEditor&); // Not implemented
+    FairEventManager* fEventManager;
+    FairEventManagerEditor* fManagerEditor;
+    FairRootManager* fRootManager;
+    int iCurrentEvent;
+    bool isZDCRedraw;
+};
+
+// multithread functions
+void* RunOnlineDisplay(void* ptr);
 
-  protected:
+class FairEventManagerEditor : public TGedFrame
+{
+  private:
     TObject* fObject;
-    FairEventManager*  fManager;
-    TGNumberEntry*  fCurrentEvent, *fCurrentPDG;
-    TGCheckButton*  fVizPri;
-    TEveGValuator *fMinEnergy, *fMaxEnergy;
+    FairEventManager* fManager;
+    TGNumberEntry* fCurrentPDG;
+    TGCheckButton* fVizPri;
+    TEveGValuator* fMinEnergy, *fMaxEnergy;
     TGLabel* fEventTime;
-
-    int iCurrentEvent;
     TGCompositeFrame* title1;
-    TGGroupFrame *groupData;
+    TGGroupFrame* groupData;
     TGCheckButton* fShowMCPoints, *fShowMCTracks, *fShowRecoPoints, *fShowRecoTracks;
 
+    // current event number
+    int iEventNumber;
+
   public:
     FairEventManagerEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30,
                            UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
-    virtual ~FairEventManagerEditor() {}
+    FairEventManagerEditor(const FairEventManagerEditor&);
+    FairEventManagerEditor& operator=(const FairEventManagerEditor&);
+    virtual ~FairEventManagerEditor() { }
+
     void SetModel(TObject* obj);
     virtual void SelectEvent();
+    virtual void UpdateEvent();
     virtual void SelectPDG();
     void DoVizPri();
     virtual void MaxEnergy();
@@ -50,13 +64,35 @@ class FairEventManagerEditor : public TGedFrame
     virtual void Init();
 
     virtual void SwitchBackground(Bool_t is_on);
+    virtual void SwitchTransparency(Bool_t is_on);
     virtual void ShowGeometry(Bool_t is_show);
+    virtual void ShowMagnet(Bool_t is_show);
     virtual void ShowMCPoints(Bool_t is_show);
     virtual void ShowMCTracks(Bool_t is_show);
     virtual void ShowRecoPoints(Bool_t is_show);
     virtual void ShowRecoTracks(Bool_t is_show);
 
-    ClassDef(FairEventManagerEditor, 0); // Specialization of TGedEditor for proper update propagation to TEveManager.
+    bool RedrawZDC(bool isRedraw = true);
+    void RestoreZDC();
+    void BlockUI();
+    void UnblockUI();
+
+    // save screenshot of the eve display
+    virtual void SaveImage();
+
+    // event count
+    int iEventCount;
+    // 'Update' button
+    TGTextButton* fUpdate;
+    TGPictureButton* fSave;
+    // 'Current Event Number' textbox with spin buttons
+    TGNumberEntry* fCurrentEvent;
+    // 'Show Geometry' checkbox
+    TGCheckButton* fGeometry;
+
+    int iThreadState;
+
+    ClassDef(FairEventManagerEditor, 0); // Specialization of TGedEditor for proper update propagation to TEveManager
 };
 
 #endif
diff --git a/eventdisplay/FairHitPointSetDraw.cxx b/eventdisplay/FairHitPointSetDraw.cxx
index 95d99ff..8fc94a9 100644
--- a/eventdisplay/FairHitPointSetDraw.cxx
+++ b/eventdisplay/FairHitPointSetDraw.cxx
@@ -6,36 +6,49 @@
  */
 
 #include "FairHitPointSetDraw.h"
+#include "FairHit.h"
+#include "FairEventManager.h"
 
-#include "FairHit.h"                    // for FairHit
+#include "TEveManager.h"
 
-#include "Riosfwd.h"                    // for ostream
-#include "TVector3.h"                   // for TVector3
-
-#include <iostream>                     // for operator<<, basic_ostream, etc
-
-using std::cout;
-using std::endl;
+#include <iostream>
+using namespace std;
 
 FairHitPointSetDraw::FairHitPointSetDraw()
 {
-  // TODO Auto-generated constructor stub
-
 }
 
 FairHitPointSetDraw::~FairHitPointSetDraw()
 {
-  // TODO Auto-generated destructor stub
 }
 
 TVector3 FairHitPointSetDraw::GetVector(TObject* obj)
 {
-  FairHit* p = (FairHit*)obj;
-  if (fVerbose > 1) {
-    cout << "-I- FairHitPointSetDraw::GetVector: " << p->GetX() << " " << p->GetY() << " " << p->GetZ() << endl;
-  }
-  return TVector3(p->GetX(), p->GetY(), p->GetZ());
+    FairHit* hit = (FairHit*) obj;
+    if (fVerbose > 1)
+      cout<<"-I- FairHitPointSetDraw::GetVector: "<<hit->GetX()<<" "<<hit->GetY()<<" "<<hit->GetZ()<<endl;
+
+    return TVector3(hit->GetX(), hit->GetY(), hit->GetZ());
 }
 
+void FairHitPointSetDraw::AddEveElementList()
+{
+    if (fEventManager->EveRecoPoints == NULL)
+    {
+        fEventManager->EveRecoPoints = new TEveElementList("Reco points");
+        gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
+        fEventManager->EveRecoPoints->SetRnrState(kFALSE);
+    }
+
+    gEve->AddElement(fq, fEventManager->EveRecoPoints);
+
+    return;
+}
+
+void FairHitPointSetDraw::RemoveEveElementList()
+{
+    gEve->RemoveElement(fq, fEventManager->EveRecoPoints);
+    return;
+}
 
 ClassImp(FairHitPointSetDraw)
diff --git a/eventdisplay/FairHitPointSetDraw.h b/eventdisplay/FairHitPointSetDraw.h
index cdbf4ea..05fe734 100644
--- a/eventdisplay/FairHitPointSetDraw.h
+++ b/eventdisplay/FairHitPointSetDraw.h
@@ -8,22 +8,22 @@
 #ifndef FAIRHITPOINTSETDRAW_H_
 #define FAIRHITPOINTSETDRAW_H_
 
-#include "FairPointSetDraw.h"           // for FairPointSetDraw
+#include "FairPointSetDraw.h"
 
-#include "Rtypes.h"                     // for FairHitPointSetDraw::Class, etc
+#include "TVector3.h"
 
-class TObject;
-class TVector3;
-
-class FairHitPointSetDraw: public FairPointSetDraw
+class FairHitPointSetDraw : public FairPointSetDraw
 {
   public:
     FairHitPointSetDraw();
-    FairHitPointSetDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1):FairPointSetDraw(name, color, mstyle, iVerbose) {};
+    FairHitPointSetDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1)
+        : FairPointSetDraw(name, color, mstyle, iVerbose) {}
     virtual ~FairHitPointSetDraw();
 
   protected:
     TVector3 GetVector(TObject* obj);
+    void AddEveElementList();
+    void RemoveEveElementList();
 
     ClassDef(FairHitPointSetDraw,1);
 };
diff --git a/eventdisplay/FairMCPointDraw.cxx b/eventdisplay/FairMCPointDraw.cxx
index b5a466a..ef5caa4 100644
--- a/eventdisplay/FairMCPointDraw.cxx
+++ b/eventdisplay/FairMCPointDraw.cxx
@@ -6,29 +6,43 @@
  */
 
 #include "FairMCPointDraw.h"
+#include "FairMCPoint.h"
+#include "FairEventManager.h"
 
-#include "FairMCPoint.h"                // for FairMCPoint
-
-#include "TVector3.h"                   // for TVector3
-
-class TObject;
+#include "TEveManager.h"
 
 FairMCPointDraw::FairMCPointDraw()
 {
-  // TODO Auto-generated constructor stub
-
 }
 
 FairMCPointDraw::~FairMCPointDraw()
 {
-  // TODO Auto-generated destructor stub
 }
 
 TVector3 FairMCPointDraw::GetVector(TObject* obj)
 {
-  FairMCPoint* p = (FairMCPoint*)obj;
-  return TVector3(p->GetX(), p->GetY(), p->GetZ());
+    FairMCPoint* p = (FairMCPoint*) obj;
+    return TVector3(p->GetX(), p->GetY(), p->GetZ());
+}
+
+void FairMCPointDraw::AddEveElementList()
+{
+    if (fEventManager->EveMCPoints == NULL)
+    {
+        fEventManager->EveMCPoints = new TEveElementList("MC points");
+        gEve->AddElement(fEventManager->EveMCPoints, fEventManager);
+        fEventManager->EveMCPoints->SetRnrState(kFALSE);
+    }
+
+    gEve->AddElement(fq, fEventManager->EveMCPoints);
+
+    return;
 }
 
+void FairMCPointDraw::RemoveEveElementList()
+{
+    gEve->RemoveElement(fq, fEventManager->EveMCPoints);
+    return;
+}
 
 ClassImp(FairMCPointDraw)
diff --git a/eventdisplay/FairMCPointDraw.h b/eventdisplay/FairMCPointDraw.h
index 3150c25..6584dfe 100644
--- a/eventdisplay/FairMCPointDraw.h
+++ b/eventdisplay/FairMCPointDraw.h
@@ -8,22 +8,23 @@
 #ifndef FAIRMCPOINTDRAW_H_
 #define FAIRMCPOINTDRAW_H_
 
-#include "FairPointSetDraw.h"           // for FairPointSetDraw
+#include "FairPointSetDraw.h"
 
-#include "Rtypes.h"                     // for FairMCPointDraw::Class, etc
+#include "TVector3.h"
 
-class TObject;
-class TVector3;
 
-class FairMCPointDraw: public FairPointSetDraw
+class FairMCPointDraw : public FairPointSetDraw
 {
   public:
     FairMCPointDraw();
-    FairMCPointDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1):FairPointSetDraw(name, color, mstyle, iVerbose) {};
+    FairMCPointDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1)
+        : FairPointSetDraw(name, color, mstyle, iVerbose) {}
     virtual ~FairMCPointDraw();
 
   protected:
     TVector3 GetVector(TObject* obj);
+    void AddEveElementList();
+    void RemoveEveElementList();
 
     ClassDef(FairMCPointDraw,1);
 };
diff --git a/eventdisplay/FairMCStack.cxx b/eventdisplay/FairMCStack.cxx
index dce0f85..c54c742 100644
--- a/eventdisplay/FairMCStack.cxx
+++ b/eventdisplay/FairMCStack.cxx
@@ -13,7 +13,11 @@
 #include "TObjArray.h"
 #include "TEveManager.h"
 #include "FairEventManager.h"
+#ifdef BMNROOT
+#include "CbmMCTrack.h"
+#else
 #include "FairMCTrack.h"
+#endif
 #include "TGeant3.h"
 #include "FairGeanePro.h"
 #include "FairTrajFilter.h"
@@ -26,18 +30,16 @@ using std::endl;
 // -----   Default constructor   -------------------------------------------
 FairMCStack::FairMCStack()
 {
-
 }
 // -------------------------------------------------------------------------
 
-
 // -----   Standard constructor   ------------------------------------------
 FairMCStack::FairMCStack(const char* name, Int_t iVerbose)
   : FairTask(name, iVerbose),
     fEveTrList( new TObjArray(16))
 {
-
 }
+
 // -------------------------------------------------------------------------
 InitStatus FairMCStack::Init()
 {
@@ -86,21 +88,25 @@ InitStatus FairMCStack::Init()
   else { return kERROR; }
 
 }
+
 // -------------------------------------------------------------------------
 void FairMCStack::Exec(Option_t* option)
 {
-
-  if (IsActive()) {
-
+  if (IsActive())
+  {
     if(fVerbose>1) { cout << " FairMCStack::Exec "<< endl; }
-    FairMCTrack* tr;
     const Double_t* point;
 
     Reset();
 
     for (Int_t i=0; i<fTrackList->GetEntriesFast(); i++)  {
       if(fVerbose>2) { cout << "FairMCStack::Exec "<< i << endl; }
-      tr=(FairMCTrack*)fTrackList->At(i);
+
+      #ifdef BMNROOT
+        CbmMCTrack* tr = (CbmMCTrack*) fTrackList->At(i);
+      #else
+        FairMCTrack* tr = (FairMCTrack*) fTrackList->At(i);
+      #endif
 
       TVector3 Ptot;
       tr->GetMomentum(Ptot);
@@ -118,7 +124,6 @@ void FairMCStack::Exec(Option_t* option)
       p1[2]=Ptot.Pz();
 
 
-
       //TParticle *P=(TParticle *)tr->GetParticle();
       Double_t mass=0.0;
       Double_t ene=0.0;
@@ -179,29 +184,6 @@ void FairMCStack::Exec(Option_t* option)
       }
       fTrList->AddElement(track);
       if(fVerbose>3) { cout << "track added " << track->GetName() << endl; }
-
-
-//  cout << "CurrentTrack " << fTrajFilter->GetCurrentTrk() << endl;
-
-      /*   for (Int_t n=0; n<Np; n++){
-             point=tr->GetPoint(n);
-             track->SetPoint(n,point[0],point[1],point[2]);
-             TEveVector pos= TEveVector(point[0], point[1],point[2]);
-           TEvePathMark *path = new TEvePathMark();
-         path->fV=pos ;
-         path->fTime= point[3];
-             if(n==0){
-                 TEveVector Mom= TEveVector(P->Px(), P->Py(),P->Pz());
-                 path->fP=Mom;
-             }
-             if(fVerbose>3) cout << "Path marker added " << path << endl;
-             track->AddPathMark(*path);
-             if(fVerbose>3) cout << "Path marker added " << path << endl;
-          }
-
-          fTrList->AddElement(track);
-      if(fVerbose>3)cout << "track added " << track->GetName() << endl;
-      */
     }
     //for (Int_t i=0; i<fEveTrList->GetEntriesFast(); i++) {
     //  TEveTrackList* TrListIn=( TEveTrackList*) fEveTrList->At(i);
@@ -212,6 +194,7 @@ void FairMCStack::Exec(Option_t* option)
     gEve->Redraw3D(kFALSE);
   }
 }
+
 // -----   Destructor   ----------------------------------------------------
 FairMCStack::~FairMCStack()
 {
diff --git a/eventdisplay/FairMCStack.h b/eventdisplay/FairMCStack.h
index 7c4cad2..8775f06 100644
--- a/eventdisplay/FairMCStack.h
+++ b/eventdisplay/FairMCStack.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                      FairMCStack header file                 -----
 // -----                Created 09/10/08  by M. Al-Turany              -----
@@ -18,10 +25,9 @@
 #include "FairTask.h"
 #include "TEveTrackPropagator.h"
 #include "TString.h"
-#include "TParticle.h"
+#include "TEveTrack.h"
 class FairGeanePro;
 class TGeant3;
-class TEveTrackList;
 class FairEventManager;
 class TObjArray;
 class FairTrajFilter;
diff --git a/eventdisplay/FairMCTracks.cxx b/eventdisplay/FairMCTracks.cxx
index 94d75dd..c34f064 100644
--- a/eventdisplay/FairMCTracks.cxx
+++ b/eventdisplay/FairMCTracks.cxx
@@ -6,6 +6,7 @@
 
 #include "FairEventManager.h"           // for FairEventManager
 #include "FairRootManager.h"            // for FairRootManager
+#include "FairLogger.h"
 
 #include "Riosfwd.h"                    // for ostream
 #include "TClonesArray.h"               // for TClonesArray
@@ -22,8 +23,6 @@
 #include <string.h>                     // for NULL, strcmp
 #include <iostream>                     // for operator<<, basic_ostream, etc
 
-using std::cout;
-using std::endl;
 
 // -----   Default constructor   -------------------------------------------
 FairMCTracks::FairMCTracks()
@@ -41,6 +40,7 @@ FairMCTracks::FairMCTracks()
 }
 // -------------------------------------------------------------------------
 
+
 // -----   Standard constructor   ------------------------------------------
 FairMCTracks::FairMCTracks(const char* name, Int_t iVerbose)
   : FairTask(name, iVerbose),
@@ -55,125 +55,86 @@ FairMCTracks::FairMCTracks(const char* name, Int_t iVerbose)
     PEnergy(-1.)
 {
 }
-
 // -------------------------------------------------------------------------
 InitStatus FairMCTracks::Init()
 {
-  if (fVerbose > 1)
-      cout<<  "FairMCTracks::Init()" << endl;
-
+  LOG(DEBUG) <<  "FairMCTracks::Init()" << FairLogger::endl; 
   FairRootManager* fManager = FairRootManager::Instance();
-
   fTrackList = (TClonesArray*)fManager->GetObject("GeoTracks");
-  if (fTrackList == 0)
-  {
-    cout << "FairMCPointDraw::Init()  branch " << GetName() << " Not found! Task will be deactivated "<< endl;
+  if(fTrackList==0) {
+    LOG(ERROR) << "FairMCTracks::Init()  branch " << GetName() << " Not found! Task will be deactivated "<< FairLogger::endl;
     SetActive(kFALSE);
   }
-
-  if (fVerbose > 2)
-      cout<<  "FairMCTracks::Init() get track list" << fTrackList<< endl;
-  if (fVerbose > 2)
-      cout<<  "FairMCTracks::Init()  create propagator" << endl;
-
+  LOG(DEBUG1) <<  "FairMCTracks::Init() get track list" << fTrackList << FairLogger::endl; 
+  LOG(DEBUG1) <<  "FairMCTracks::Init()  create propagator" << FairLogger::endl; 
   fEventManager =FairEventManager::Instance();
-  if (fVerbose > 2)
-      cout<<  "FairMCTracks::Init() get instance of FairEventManager " << endl;
-
+  LOG(DEBUG1) <<  "FairMCTracks::Init() get instance of FairEventManager " << FairLogger::endl; 
   fEvent = "Current Event";
-  MinEnergyLimit = fEventManager->GetEvtMinEnergy();
-  MaxEnergyLimit = fEventManager->GetEvtMaxEnergy();
-  PEnergy = 0;
-
-  if (IsActive())
-      return kSUCCESS;
-  else
-      return kERROR;
+  MinEnergyLimit=fEventManager->GetEvtMinEnergy();
+  MaxEnergyLimit=fEventManager->GetEvtMaxEnergy();
+  PEnergy=0;
+  if(IsActive()) { return kSUCCESS; }
+  else { return kERROR; }
 }
-
 // -------------------------------------------------------------------------
 void FairMCTracks::Exec(Option_t* option)
 {
-  if (IsActive())
-  {
-    Reset();
 
-    if (fVerbose>1)
-        cout << " FairMCTracks::Exec "<< endl;
+  if (IsActive()) {
 
+    LOG(DEBUG1) << " FairMCTracks::Exec "<< FairLogger::endl; 
     TGeoTrack* tr;
     const Double_t* point;
 
-    for (Int_t i = 0; i < fTrackList->GetEntriesFast(); i++)
-    {
-      if (fVerbose > 2)
-          cout << "FairMCTracks::Exec "<< i << endl;
-
-      tr = (TGeoTrack*)fTrackList->At(i);
-      TParticle* P = (TParticle*)tr->GetParticle();
-
-      PEnergy = P->Energy();
-      MinEnergyLimit = TMath::Min(PEnergy, MinEnergyLimit);
-      MaxEnergyLimit = TMath::Max(PEnergy, MaxEnergyLimit);
-
-      if (fVerbose > 2)
-          cout << "MinEnergyLimit " << MinEnergyLimit << " MaxEnergyLimit " << MaxEnergyLimit << endl;
-
-      if (fEventManager->IsPriOnly() && P->GetMother(0) > -1)
-          continue;
-      if (fEventManager->GetCurrentPDG() != 0 && fEventManager->GetCurrentPDG() != tr->GetPDG())
-          continue;
-
-      if (fVerbose > 2)
-          cout << "PEnergy " << PEnergy << " Min "  << fEventManager->GetMinEnergy() << " Max " << fEventManager->GetMaxEnergy() <<endl;
-
-      if ((PEnergy<fEventManager->GetMinEnergy()) || (PEnergy >fEventManager->GetMaxEnergy()))
-          continue;
-
-      Int_t Np = tr->GetNpoints();
-      fTrList = GetTrGroup(P);
+    Reset();
 
-      TEveTrack* track = new TEveTrack(P, tr->GetPDG(), fTrPr);
-      // set track color by particle PDG from FairEventManager
+    for (Int_t i=0; i<fTrackList->GetEntriesFast(); i++)  {
+      LOG(DEBUG3) << "FairMCTracks::Exec "<< i << FairLogger::endl; 
+      tr=(TGeoTrack*)fTrackList->At(i);
+      TParticle* P=(TParticle*)tr->GetParticle();
+      PEnergy=P->Energy();
+      MinEnergyLimit=TMath::Min(PEnergy,MinEnergyLimit) ;
+      MaxEnergyLimit=TMath::Max(PEnergy,MaxEnergyLimit) ;
+      LOG(DEBUG3)<< "MinEnergyLimit " << MinEnergyLimit << " MaxEnergyLimit " << MaxEnergyLimit << FairLogger::endl; 
+      if (fEventManager->IsPriOnly() && P->GetMother(0)>-1) { continue; }
+      if(fEventManager->GetCurrentPDG()!=0 && fEventManager->GetCurrentPDG()!= tr->GetPDG()) { continue; }
+      LOG(DEBUG3) << "PEnergy " << PEnergy << " Min "  << fEventManager->GetMinEnergy() << " Max " << fEventManager->GetMaxEnergy() << FairLogger::endl; 
+      if( (PEnergy<fEventManager->GetMinEnergy()) || (PEnergy >fEventManager->GetMaxEnergy())) { continue; }
+
+      Int_t Np=tr->GetNpoints();
+      fTrList= GetTrGroup(P);
+      TEveTrack* track= new TEveTrack(P, tr->GetPDG(), fTrPr);
       track->SetLineColor(fEventManager->Color(tr->GetPDG()));
-
-      for (Int_t n = 0; n < Np; n++)
-      {
+      for (Int_t n=0; n<Np; n++) {
         point=tr->GetPoint(n);
         track->SetPoint(n,point[0],point[1],point[2]);
-        TEveVector pos = TEveVector(point[0], point[1],point[2]);
+        TEveVector pos= TEveVector(point[0], point[1],point[2]);
         TEvePathMark* path = new TEvePathMark();
-        path->fV = pos;
-        path->fTime = point[3];
-        if (n == 0)
-        {
-          TEveVector Mom = TEveVector(P->Px(), P->Py(),P->Pz());
-          path->fP = Mom;
+        path->fV=pos ;
+        path->fTime= point[3];
+        if(n==0) {
+          TEveVector Mom= TEveVector(P->Px(), P->Py(),P->Pz());
+          path->fP=Mom;
         }
-
-        if (fVerbose > 3)
-            cout << "Path marker added " << path << endl;
+        LOG(DEBUG4) << "Path marker added " << path << FairLogger::endl; 
 
         track->AddPathMark(*path);
 
-        if (fVerbose > 3)
-            cout << "Path marker added " << path << endl;
-      }
+        LOG(DEBUG4) << "Path marker added " << path << FairLogger::endl; 
 
+        delete path;
+      }
       fTrList->AddElement(track);
-      if (fVerbose > 3)
-          cout << "track added " << track->GetName() << endl;
-    }
+      LOG(DEBUG3) << "track added " << track->GetName() << FairLogger::endl; 
 
-    for (Int_t i=0; i < fEveTrList->GetEntriesFast(); i++)
-    {
+    }
+    for (Int_t i=0; i<fEveTrList->GetEntriesFast(); i++) {
       // TEveTrackList *TrListIn=( TEveTrackList *) fEveTrList->At(i);
       //TrListIn->FindMomentumLimits(TrListIn, kFALSE);
     }
-
     fEventManager->SetEvtMaxEnergy(MaxEnergyLimit);
     fEventManager->SetEvtMinEnergy(MinEnergyLimit);
-    gEve->Redraw3D(kFALSE);
+    //gEve->Redraw3D(kFALSE);
   }
 }
 // -----   Destructor   ----------------------------------------------------
@@ -194,48 +155,39 @@ void FairMCTracks::Finish()
 // -------------------------------------------------------------------------
 void FairMCTracks::Reset()
 {
-  for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
-  {
-    TEveTrackList* ele = (TEveTrackList*) fEveTrList->At(i);
+  for (Int_t i=0; i<fEveTrList->GetEntriesFast(); i++) {
+    TEveTrackList*  ele=( TEveTrackList*) fEveTrList->At(i);
     gEve->RemoveElement(ele, fEventManager->EveMCTracks);
   }
-
   fEveTrList->Clear();
 }
 
 TEveTrackList* FairMCTracks::GetTrGroup(TParticle* P)
 {
-  fTrList = 0;
-  for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
-  {
-    TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
 
-    if (strcmp(TrListIn->GetName(), P->GetName()) == 0)
-    {
-      fTrList = TrListIn;
+  fTrList=0;
+  for (Int_t i=0; i<fEveTrList->GetEntriesFast(); i++) {
+    TEveTrackList* TrListIn=( TEveTrackList*) fEveTrList->At(i);
+    if ( strcmp(TrListIn->GetName(),P->GetName())==0 ) {
+      fTrList= TrListIn;
       break;
     }
   }
-
-  if (fTrList == 0)
-  {
-    fTrPr = new TEveTrackPropagator();
-    fTrList = new TEveTrackList(P->GetName(), fTrPr);
+  if(fTrList ==0) {
+    fTrPr=new TEveTrackPropagator();
+    fTrList= new  TEveTrackList(P->GetName(),fTrPr );
     // set track color by particle PDG from FairEventManager
     fTrList->SetMainColor(fEventManager->Color(P->GetPdgCode()));
     fEveTrList->Add(fTrList);
-
     if (fEventManager->EveMCTracks == NULL)
     {
         fEventManager->EveMCTracks = new TEveElementList("MC tracks");
         gEve->AddElement(fEventManager->EveMCTracks, fEventManager);
         fEventManager->EveMCTracks->SetRnrState(kFALSE);
     }
-
     gEve->AddElement(fTrList, fEventManager->EveMCTracks);
     fTrList->SetRnrLine(kTRUE);
   }
-
   return fTrList;
 }
 
diff --git a/eventdisplay/FairPointSetDraw.cxx b/eventdisplay/FairPointSetDraw.cxx
index 08ee414..9b30de2 100644
--- a/eventdisplay/FairPointSetDraw.cxx
+++ b/eventdisplay/FairPointSetDraw.cxx
@@ -1,29 +1,18 @@
-// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
 // -----                        FairPointSetDraw source file                  -----
 // -----                  Created 03/01/08  by M. Al-Turany            -----
 // -------------------------------------------------------------------------
 #include "FairPointSetDraw.h"
 
-#include "FairEventManager.h"           // for FairEventManager
-#include "FairRootManager.h"            // for FairRootManager
-#include "FairMCPointDraw.h"
-
-#include "Riosfwd.h"                    // for ostream
-#include "TClonesArray.h"               // for TClonesArray
-#include "TEveManager.h"                // for TEveManager, gEve
-#include "TEvePointSet.h"               // for TEvePointSet
-#include "TEveTreeTools.h"              // for TEvePointSelectorConsumer, etc
-#include "TNamed.h"                     // for TNamed
-#include "TString.h"                    // for Form
-#include "TVector3.h"                   // for TVector3
+#include "FairRootManager.h"
 
-#include <stddef.h>                     // for NULL
-#include <iostream>                     // for operator<<, basic_ostream, etc
+#include "TEveManager.h"
+#include "TEveTreeTools.h"      // for TEvePointSelectorConsumer, etc
+#include "TString.h"            // for Form
 
-class TObject;
+#include <iostream>
+using namespace std;
 
-using std::cout;
-using std::endl;
 
 // -----   Default constructor   -------------------------------------------
 FairPointSetDraw::FairPointSetDraw()
@@ -76,7 +65,6 @@ InitStatus FairPointSetDraw::Init()
   return kSUCCESS;
 }
 
-// -------------------------------------------------------------------------
 void FairPointSetDraw::Exec(Option_t* option)
 {
   if (IsActive())
@@ -92,7 +80,7 @@ void FairPointSetDraw::Exec(Option_t* option)
     q->SetMarkerStyle(fStyle);
     //std::cout << "fPointList: " << fPointList << " " << fPointList->GetEntries() << std::endl;
 
-    for (Int_t i=0; i < npoints; i++)
+    for (Int_t i = 0; i < npoints; i++)
     {
       TObject* p = (TObject*)fPointList->At(i);
       if(p != 0)
@@ -103,34 +91,11 @@ void FairPointSetDraw::Exec(Option_t* option)
       }
     }
 
-    // check: this point is instance of FairMCPointDraw class
-    FairMCPointDraw* pCheckClass = dynamic_cast<FairMCPointDraw*>(this);
-    if (pCheckClass != NULL)
-    {
-        if (fEventManager->EveMCPoints == NULL)
-        {
-            fEventManager->EveMCPoints = new TEveElementList("MC points");
-            gEve->AddElement(fEventManager->EveMCPoints, fEventManager);
-            fEventManager->EveMCPoints->SetRnrState(kFALSE);
-        }
-
-        gEve->AddElement(q, fEventManager->EveMCPoints);
-    }
-    else
-    {
-        if (fEventManager->EveRecoPoints == NULL)
-        {
-            fEventManager->EveRecoPoints = new TEveElementList("Reco points");
-            gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
-            fEventManager->EveRecoPoints->SetRnrState(kFALSE);
-        }
-
-        gEve->AddElement(q, fEventManager->EveRecoPoints);
-    }
+    fq = q;
 
-    gEve->Redraw3D(kFALSE);
+    AddEveElementList();
 
-    fq = q;
+    //gEve->Redraw3D(kFALSE);
   }
 }
 
@@ -143,28 +108,25 @@ TObject* FairPointSetDraw::GetValue(TObject* obj,Int_t i)
 FairPointSetDraw::~FairPointSetDraw()
 {
 }
+
 // -------------------------------------------------------------------------
 void FairPointSetDraw::SetParContainers()
 {
-
 }
+
 // -------------------------------------------------------------------------
 /** Action after each event**/
 void FairPointSetDraw::Finish()
 {
 }
+
 // -------------------------------------------------------------------------
 void FairPointSetDraw::Reset()
 {
   if (fq != 0)
   {
     fq->Reset();
-
-    FairMCPointDraw* pCheckClass = dynamic_cast<FairMCPointDraw*>(this);
-    if (pCheckClass != NULL)
-        gEve->RemoveElement(fq, fEventManager->EveMCPoints);
-    else
-        gEve->RemoveElement(fq, fEventManager->EveRecoPoints);
+    RemoveEveElementList();
   }
 }
 
diff --git a/eventdisplay/FairPointSetDraw.h b/eventdisplay/FairPointSetDraw.h
index bf05e02..ae4c9d6 100644
--- a/eventdisplay/FairPointSetDraw.h
+++ b/eventdisplay/FairPointSetDraw.h
@@ -13,26 +13,20 @@
 
 #ifndef FAIRPOINTSETDRAW_H
 #define FAIRPOINTSETDRAW_H
+#include "FairTask.h"
+#include "FairEventManager.h"
 
-#include "FairTask.h"                   // for FairTask, InitStatus
+#include "TClonesArray.h"
+#include "TVector3.h"
+#include "TEvePointSet.h"
 
-#include "Rtypes.h"                     // for Int_t, Color_t, etc
-
-class FairEventManager;
-class TClonesArray;
-class TEvePointSet;
-class TObject;
-class TVector3;
 
 class FairPointSetDraw : public FairTask
 {
-
   public:
-
     /** Default constructor **/
     FairPointSetDraw();
 
-
     /** Standard constructor
     *@param name        Name of task
     *@param iVerbose    Verbosity level
@@ -43,33 +37,35 @@ class FairPointSetDraw : public FairTask
     virtual ~FairPointSetDraw();
 
     /** Set verbosity level. For this task and all of the subtasks. **/
-    void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;};
+    void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;}
     /** Executed task **/
     virtual void Exec(Option_t* option);
     void Reset();
-  protected:
 
+  protected:
     virtual TVector3 GetVector(TObject* obj) = 0;
-    virtual TObject* GetValue(TObject* obj,Int_t i);
+    virtual void AddEveElementList() = 0;
+    virtual void RemoveEveElementList() = 0;
+    virtual TObject* GetValue(TObject* obj, Int_t i);
 
-    Int_t   fVerbose;       //  Verbosity level
-    virtual void SetParContainers() ;
+    virtual void SetParContainers();
     virtual InitStatus Init();
     /** Action after each event**/
-    virtual void Finish() ;
-    TClonesArray* fPointList; //!
-    FairEventManager* fEventManager;   //!
-    TEvePointSet* fq;    //!
-    Color_t fColor; //!
-    Style_t fStyle; //!
+    virtual void Finish();
+
+    // Verbosity level
+    Int_t fVerbose;
+    TClonesArray* fPointList;           //!
+    FairEventManager* fEventManager;    //!
+    TEvePointSet* fq;                   //!
+    Color_t fColor;                     //!
+    Style_t fStyle;                     //!
 
   private:
     FairPointSetDraw(const FairPointSetDraw&);
     FairPointSetDraw& operator=(const FairPointSetDraw&);
 
     ClassDef(FairPointSetDraw,1);
-
 };
 
-
 #endif
diff --git a/eventdisplay/FairWebScreenshots.cxx b/eventdisplay/FairWebScreenshots.cxx
new file mode 100755
index 0000000..ad63abf
--- /dev/null
+++ b/eventdisplay/FairWebScreenshots.cxx
@@ -0,0 +1,668 @@
+// -------------------------------------------------------------------------
+// -----                    FairWebScreenshots source file             -----
+// -------------------------------------------------------------------------
+#include "FairWebScreenshots.h"
+
+#include "TEveManager.h"
+#include "TGLViewer.h"
+#include <TThread.h>
+
+#include <sys/stat.h>
+#include <sys/socket.h>
+#include <sys/wait.h>
+#include <netinet/in.h>
+
+#include <iostream>
+
+using namespace std;
+
+// -----   Default constructor (private)  ----------------------------------
+FairWebScreenshots::FairWebScreenshots()
+    : FairTask("FairWebScreenshots", 0)
+{}
+
+// -----   Destructor   ----------------------------------------------------
+FairWebScreenshots::~FairWebScreenshots()
+{}
+
+// -----   Standard constructor   ------------------------------------------
+FairWebScreenshots::FairWebScreenshots(const char* name, char* output_dir, bool isWebServer, Int_t iVerbose)
+    : FairTask(name, iVerbose)
+{
+    outputDir = output_dir;
+    outputDir += "/";
+
+    isWebStarted = false;
+    isWeb = isWebServer;
+    if (isWebServer) return;
+
+    if (strlen(outputDir) > 0)
+    {
+        struct stat st = {0};
+        if (stat(outputDir, &st) == -1) mkdir(outputDir, 0700);
+
+        cout<<"Images of the event display will be saved in directory: "<<outputDir<<endl;
+    }
+}
+
+//--------------------------------------------------------------------------
+void FairWebScreenshots::SetFormatFiles(int i_format_files)
+{
+    iFormatFiles = i_format_files;
+}
+//--------------------------------------------------------------------------
+void FairWebScreenshots::SetPort(int NumberPort)
+{
+    web_port = NumberPort;
+}
+//--------------------------------------------------------------------------
+void FairWebScreenshots::SetMultiFiles(bool is_multi_files)
+{
+    isMultiFiles = is_multi_files;
+}
+
+// -------------------------------------------------------------------------
+InitStatus FairWebScreenshots::Init()
+{
+    if (fVerbose > 1)
+        cout<<"FairWebScreenshots::Init()"<<endl;
+
+    if (!IsActive())
+        return kERROR;
+
+    fMan = FairEventManager::Instance();
+
+    // start web server if required
+    if (isWeb && (!isWebStarted))
+    {
+        // Set daemon to FALSE
+        daemon = 0;
+
+        www_thread_par* pPar = new www_thread_par();
+        pPar->web_port = web_port;
+        pPar->outputDir = outputDir;
+        pPar->daemon = daemon;
+
+        TThread* threadWebServ = new TThread((TThread::VoidFunc_t)&start_server, (void*)pPar, TThread::kNormalPriority);
+        threadWebServ->Run();
+        isWebStarted = true;
+    }
+
+    return kSUCCESS;
+}
+
+// -------------------------------------------------------------------------
+void FairWebScreenshots::Exec(Option_t* option)
+{
+    // redraw event display to capture current event
+    gEve->Redraw3D();
+    gSystem->ProcessEvents();
+
+    TString fileName = outputDir;
+    if (isMultiFiles == 1)
+        fileName += "event_" + TString::Format("%d", fMan->GetCurrentEvent());
+    else
+        fileName += "event";
+
+    if ((iFormatFiles == 0) || (iFormatFiles == 2))
+    {
+        fileName += ".png";
+        gEve->GetDefaultGLViewer()->SavePicture(fileName.Data());
+    }
+
+    if (iFormatFiles > 0)
+    {
+        fileName += ".jpg";
+        gEve->GetDefaultGLViewer()->SavePicture(fileName.Data());
+    }
+
+    return;
+}
+
+// -------------------------------------------------------------------------
+void FairWebScreenshots::SetParContainers()
+{}
+
+// -------------------------------------------------------------------------
+void FairWebScreenshots::Finish()
+{}
+
+// -------------------------------------------------------------------------
+int FairWebScreenshots::daemonize()
+{
+	pid_t pid;
+	// already a daemon
+	if (getppid() == 1)
+		return -1;
+
+	// Fork off the parent process
+	pid = fork();
+	if (pid < 0)
+		return -2;
+
+	// If we got a good PID, then we can exit the parent process.
+	if (pid > 0)
+		return 0;
+
+	// At this point we are executing as the child process
+
+	// Change the file mode mask
+	umask(0);
+
+	// Create a new SID for the child process
+	if (setsid() < 0)
+		return -3;
+
+	// Change the current working directory. This prevents the current directory from being locked; hence not being able to remove it.
+	if ((chdir("/")) < 0)
+		return -4;
+
+	return 0;
+}
+
+int FairWebScreenshots::sendString(const char *message, int socket)
+{
+	return send(socket, message, strlen(message), 0);
+}
+
+void FairWebScreenshots::sendHeader(const char* Status_code, char* Content_Type, int TotalSize, int socket)
+{
+	char *head = (char*)"\r\nHTTP/1.1 ";
+	char *content_head = (char*)"\r\nContent-Type: ";
+	char *server_head = (char*)"\r\nServer: PT06";
+	char *length_head = (char*)"\r\nContent-Length: ";
+	char *date_head = (char*)"\r\nDate: ";
+	char *newline = (char*)"\r\n";
+
+	time_t rawtime;
+	time(&rawtime);
+
+	char contentLength[100];
+	sprintf(contentLength, "%i", TotalSize);
+
+    char* message = (char*)malloc(
+        (strlen(head) +
+         strlen(content_head) +
+         strlen(server_head) +
+         strlen(length_head) +
+         strlen(date_head) +
+         strlen(newline) +
+         strlen(Status_code) +
+         strlen(Content_Type) +
+         strlen(contentLength) +
+         28 +
+         sizeof(char)
+         )
+         * 2
+    );
+
+	if (message != NULL)
+	{
+		strcpy(message, head);
+		strcat(message, Status_code);
+		strcat(message, content_head);
+		strcat(message, Content_Type);
+		strcat(message, server_head);
+		strcat(message, length_head);
+		strcat(message, contentLength);
+		strcat(message, date_head);
+		strcat(message, (char*)ctime(&rawtime));
+		strcat(message, newline);
+
+		sendString(message, socket);
+
+		free(message);
+	}
+}
+
+// send file
+void FairWebScreenshots::sendFile(FILE* fp, int connecting_socket)
+{
+	int current_char = 0;
+	do
+	{
+		current_char = fgetc(fp);
+		// send binary data
+		int bytes_sent = send(connecting_socket, &current_char, sizeof(char), 0);
+	}
+	while (current_char != EOF);
+}
+
+int FairWebScreenshots::scan(char *input, char *output, int start, int max)
+{
+	if (start >= strlen(input))
+		return -1;
+
+	int appending_char_count = 0;
+	int count = 0;
+
+	int i = start;
+	for (; i < strlen(input); i++)
+	{
+		if ( *(input + i) != '\t' && *(input + i) != ' ' && *(input + i) != '\n' && *(input + i) != '\r')
+		{
+			if(count < (max-1))
+			{
+				*(output + appending_char_count) = *(input + i ) ;
+				appending_char_count += 1;
+				count++;
+			}
+		}
+		else
+			break;
+	}
+	*(output + appending_char_count) = '\0';
+
+	// Find next word start
+	i += 1;
+
+	for (; i < strlen(input); i++)
+	{
+		if ( *(input + i ) != '\t' && *(input + i) != ' ' && *(input + i) != '\n' && *(input + i) != '\r')
+			break;
+	}
+
+	return i;
+}
+
+int FairWebScreenshots::checkMime(char *extension, char *mime_type)
+{
+	char *current_word = (char*)malloc(600);
+	char *word_holder = (char*)malloc(600);
+	char *line = (char*)malloc(200);
+	int startline = 0;
+
+	TString mime_file = "mime.types";
+	FILE* mimeFile = fopen(mime_file.Data(), "r");
+
+	free(mime_type);
+	mime_type = (char*)malloc(200);
+
+	memset(mime_type,'\0',200);
+
+	while (fgets(line, 200, mimeFile) != NULL)
+	{
+		if (line[0] != '#')
+		{
+			startline = scan(line, current_word, 0, 600);
+			while (1)
+			{
+				startline = scan(line, word_holder, startline, 600);
+				if (startline != -1)
+				{
+					if (strcmp ( word_holder, extension ) == 0)
+					{
+						memcpy(mime_type, current_word, strlen(current_word));
+						free(current_word);
+						free(word_holder);
+						free(line);
+						return 1;
+					}
+				}
+				else
+					break;
+			}
+		}
+
+		memset (line, '\0', 200);
+	}
+
+	free(current_word);
+	free(word_holder);
+	free(line);
+
+	return 0;
+}
+
+int FairWebScreenshots::getHttpVersion(char *input, char *output)
+{
+	char *filename = (char*)malloc(100);
+	int start = scan(input, filename, 4, 100);
+	if (start > 0)
+	{
+		if (scan(input, output, start, 20))
+		{
+			output[strlen(output)+1] = '\0';
+
+			if (strcmp("HTTP/1.1" , output) == 0)
+				return 1;
+			else
+			{
+				if (strcmp("HTTP/1.0", output) == 0)
+					return 0;
+				else
+					return -1;
+			}
+		}
+		else
+			return -1;
+	}
+
+	return -1;
+}
+
+int FairWebScreenshots::GetExtension(char *input, char *output, int max)
+{
+	int in_position = 0;
+	int appended_position = 0;
+
+	int i = 0, count = 0;
+	for (; i < strlen(input); i++)
+	{
+		if (in_position == 1)
+		{
+			if (count < max)
+			{
+				output[appended_position] = input[i];
+				appended_position +=1;
+				count++;
+			}
+		}
+
+		if ( input[i] == '.' )
+			in_position = 1;
+	}
+	output[appended_position+1] = '\0';
+
+	if (strlen(output) > 0)
+		return 1;
+
+	return -1;
+}
+
+int FairWebScreenshots::Content_Lenght(FILE *fp)
+{
+	fseek(fp, 0, SEEK_END);
+	int filesize = ftell(fp);
+	rewind(fp);
+
+	return filesize;
+}
+
+// IF NOT EXISTS - RETURN -1. IF EXISTS - RETURN 1
+int FairWebScreenshots::handleHttpGET(char *input, TString output_dir, int connecting_socket)
+{
+	char *filename = (char*)malloc(200 * sizeof(char));
+	char *path = (char*)malloc(1000 * sizeof(char));
+	char *extension = (char*)malloc(10 * sizeof(char));
+	char *mime = (char*)malloc(200 * sizeof(char));
+	char *httpVersion = (char*)malloc(20 * sizeof(char));
+
+	int contentLength = 0;
+	int mimeSupported = 0;
+
+	memset(path, '\0', 1000);
+	memset(filename, '\0', 200);
+	memset(extension, '\0', 10);
+	memset(mime, '\0', 200);
+	memset(httpVersion, '\0', 20);
+
+	int fileNameLength = scan(input, filename, 5, 200);
+
+	int i=0;
+	while (filename[i]!='\0' && filename[i]!='?')
+		i++;
+
+	if (filename[i] == '?')
+		filename[i] = '\0';
+	
+	if (fileNameLength <= 0)
+		return -1;
+
+	if (getHttpVersion(input, httpVersion) == -1)
+	{
+		sendString("501 Not Implemented\n", connecting_socket);
+		return -1;
+	}
+
+	if (GetExtension(filename, extension, 10) == -1)
+	{
+		printf("File extension not existing");
+		sendString("400 Bad Request\n", connecting_socket);
+		free(filename);
+		free(mime);
+		free(path);
+		free(extension);
+
+		return -1;
+	}
+
+	mimeSupported = checkMime(extension, mime);
+	if (mimeSupported != 1)
+	{
+		printf("Mime not supported");
+		sendString("400 Bad Request\n", connecting_socket);
+		free(filename);
+		free(mime);
+		free(path);
+		free(extension);
+
+		return -1;
+	}
+
+	// Open the requesting file as binary
+	strcpy(path, output_dir.Data());
+	strcat(path, filename);
+
+	FILE* fp = fopen(path, "rb");
+	if (fp == NULL)
+	{
+		printf("\nUnable to open file %s\n",path);
+
+		sendString("404 Not Found\n", connecting_socket);
+
+		free(filename);
+		free(mime);
+		free(extension);
+		free(path);
+
+		return -1;
+	}
+
+	// Calculate Content Length
+	contentLength = Content_Lenght(fp);
+	if (contentLength < 0)
+	{
+		printf("File size is zero");
+
+		free(filename);
+		free(mime);
+		free(extension);
+		free(path);
+
+		fclose(fp);
+
+		return -1;
+	}
+
+	// Send File Content
+	sendHeader("200 OK", mime, contentLength, connecting_socket);
+
+	sendFile(fp, connecting_socket);
+
+	free(filename);
+	free(mime);
+	free(extension);
+	free(path);
+
+	fclose(fp);
+
+	return 1;
+}
+
+// IF NOT VALID REQUEST - RETURN -1. IF VALID REQUEST - RETURN 1. IF GET - RETURN 2. IF HEAD - RETURN 0.
+int FairWebScreenshots::getRequestType(char *input)
+{
+	int type = -1;
+	if (strlen(input) > 0)
+		type = 1;
+
+	char *requestType = (char *)malloc(5);
+	scan(input, requestType, 0, 5);
+
+	if (type == 1 && strcmp("GET", requestType) == 0)
+		type = 1;
+	else
+		if (type == 1 && strcmp("HEAD", requestType) == 0)
+			type = 2;
+		else
+			if (strlen(input) > 4 && strcmp("POST", requestType) == 0)
+				type = 0;
+			else
+				type = -1;
+
+	return type;
+}
+
+int FairWebScreenshots::receive(int connecting_socket, TString output_dir)
+{
+	char buffer[BUFFER_SIZE];
+	memset(buffer,'\0', BUFFER_SIZE);
+
+	if ((recv(connecting_socket, buffer, BUFFER_SIZE, 0)) == -1)
+	{
+		printf("Error handling incoming request");
+		return -1;
+	}
+
+	int request = getRequestType(buffer);
+	if (request == 1)				// GET
+		handleHttpGET(buffer, output_dir, connecting_socket);
+	else
+		if (request == 2)			// HEAD
+			1; //SendHeader();
+		else
+			if (request == 0)		// POST
+				sendString("501 Not Implemented\n", connecting_socket);
+			else					// GARBAGE
+				sendString("400 Bad Request\n", connecting_socket);
+
+	return 1;
+}
+
+int FairWebScreenshots::acceptConnection(int currentSocket, TString output_dir)
+{
+	sockaddr_storage connectorSocket;
+	socklen_t addressSize = sizeof(connectorSocket);
+
+	int connecting_socket = accept(currentSocket, (struct sockaddr *)&(connectorSocket), &addressSize);
+	if (connecting_socket < 0)
+	{
+		perror("Accepting sockets");
+		return -1;
+	}
+
+	// --- Workflow --- //
+	// 1. Receive ( recv() ) the GET / HEAD
+	// 2. Process the request and see if the file exists
+	// 3. Read the file content
+	// 4. Send out with correct mine and http 1.1
+	if (receive(connecting_socket, output_dir) < 0)
+	{
+		perror("Receive");
+		return -1;
+	}
+
+	close(connecting_socket);
+
+	while (-1 != waitpid(-1, NULL, WNOHANG));
+}
+
+int FairWebScreenshots::start(int webPort, TString output_dir)
+{
+	// Create a socket and assign currentSocket to the descriptor
+	int currentSocket = socket(AF_INET, SOCK_STREAM, 0);
+	if (currentSocket == -1)
+	{
+		perror("Create socket");
+		return -1;
+	}
+
+	// Bind to the currentSocket descriptor and listen to the port in PORT
+	struct sockaddr_in address;
+	address.sin_family = AF_INET;
+	address.sin_addr.s_addr = INADDR_ANY;
+	address.sin_port = htons(webPort);
+
+	if (bind(currentSocket, (struct sockaddr *)&address, sizeof(address)) < 0)
+	{
+		perror("Bind to port");
+		return -2;
+	}
+
+	// Start listening for connections and accept no more than MAX_CONNECTIONS in the Quee
+	if (listen(currentSocket, MAX_CONNECTIONS) < 0)
+	{
+		perror("Listen on port");
+		return -3;
+	}
+
+	while (1)
+		acceptConnection(currentSocket, output_dir);
+}
+
+int FairWebScreenshots::start_server(void* ptr)
+{
+	www_thread_par* pPar = (www_thread_par*)ptr;
+	int webPort = pPar->web_port;
+	TString output_dir = pPar->outputDir;
+	int daemon = pPar->daemon;
+
+	int argc = 0;
+	char** argv = NULL;
+
+	TString log_file;
+	for (int parameterCount = 1; parameterCount < argc; parameterCount++)
+	{
+		// If flag -p is used, set port
+		if (strcmp(argv[parameterCount], "-p") == 0)
+		{
+			// Indicate that we want to jump over the next parameter
+			parameterCount++;
+			printf("Setting port to %i\n", atoi(argv[parameterCount]));
+			webPort = atoi(argv[parameterCount]);
+		}
+		// If flag -d is used, set daemon to TRUE;
+		else
+		{
+			if (strcmp(argv[parameterCount], "-d") == 0)
+			{
+				printf("Setting daemon = TRUE");
+				daemon = 1;
+			}
+			else
+			{
+				if (strcmp(argv[parameterCount], "-l") == 0)
+				{
+					// Indicate that we want to jump over the next parameter
+					parameterCount++;
+					printf("Setting logfile = %s\n", argv[parameterCount]);
+					log_file = (TString) (char*) argv[parameterCount];
+				}
+				else
+				{
+					printf("Usage: %s [-p port] [-d] [-l logfile]\n", argv[0]);
+					printf("\t\t-p port\t\tWhich port to listen to.\n");
+					printf("\t\t-d\t\tEnables  daemon mode.\n");
+					printf("\t\t-l logfile\tWhich file to store the log to.\n");
+					return -1;
+				}
+			}
+		}
+	}
+
+	printf("Settings:\n");
+	printf("Port:\t\t\t%i\n", webPort);
+	printf("Server root:\t\t%s\n", output_dir.Data());
+	printf("Logfile:\t\t%s\n", log_file.Data());
+	printf("daemon:\t\t\t%i\n", daemon);
+
+	if (daemon == 1)
+		daemonize();
+
+	start(webPort, output_dir);
+
+	return 0;
+}
+
+ClassImp(FairWebScreenshots)
diff --git a/eventdisplay/FairWebScreenshots.h b/eventdisplay/FairWebScreenshots.h
new file mode 100755
index 0000000..900f03a
--- /dev/null
+++ b/eventdisplay/FairWebScreenshots.h
@@ -0,0 +1,96 @@
+// -------------------------------------------------------------------------
+// -----                 FairWebScreenshots header file                -----
+// -----                Created 11/12/15  by K. Smirnov                -----
+// ------------------------------------------------------------------------- 
+
+#ifndef FAIRWEBSCREENSHOTS_H
+#define FAIRWEBSCREENSHOTS_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"           // for FairEventManager
+
+#include "TString.h"
+
+///////////////////////////////////////////////////////////////////////////////
+#define BUFFER_SIZE 512
+#define MAX_FILE_SIZE 1024*1024
+#define MAX_CONNECTIONS 3
+///////////////////////////////////////////////////////////////////////////////
+
+struct www_thread_par
+{
+    int web_port;
+    TString outputDir;
+    int daemon;
+};
+
+
+class FairWebScreenshots : public FairTask
+{    
+  public:
+    // Standard constructor
+    //*@param name        Name of task
+    //*@outputDir         Output directory
+    //*@param iVerbose    Verbosity level
+    FairWebScreenshots(const char* name, char* output_dir, bool isWebServer = false, Int_t iVerbose = 1);
+
+    // Destructor 
+    virtual ~FairWebScreenshots();
+
+    // Set verbosity level. For this task and all of the subtasks. 
+    void SetVerbose(Int_t iVerbose) { fVerbose = iVerbose; }
+    // Executed task 
+    virtual void Exec(Option_t* option);
+    virtual InitStatus Init();
+    virtual void SetParContainers();
+    // Action after each event
+    virtual void Finish();
+
+    //Set format of saved files
+    void SetFormatFiles(int i_format_files);
+    //Set quantity of files
+    void SetMultiFiles(bool is_multi_files);
+    //Set Number port
+    void SetPort(int NumberPort);
+    
+  private:
+    // Default constructor
+    FairWebScreenshots();
+    FairWebScreenshots(const FairWebScreenshots&);
+    FairWebScreenshots& operator=(const FairWebScreenshots&);
+
+    static int daemonize();
+    static int sendString(const char *message, int socket);
+    static void sendHeader(const char *Status_code, char *Content_Type, int TotalSize, int socket);
+    static void sendHTML(char *statusCode, char *contentType, char *content, int size, int socket);
+    static void sendFile(FILE *fp, int connecting_socket);
+    static int scan(char *input, char *output, int start, int max);
+    static int checkMime(char *extension, char *mime_type);
+    static int getHttpVersion(char *input, char *output);
+    static int GetExtension(char *input, char *output, int max);
+    static int Content_Lenght(FILE *fp);
+    static int handleHttpGET(char *input, TString output_dir, int connecting_socket);
+    static int getRequestType(char *input);
+    static int receive(int connecting_socket, TString output_dir);
+    static int acceptConnection(int currentSocket, TString output_dir);
+    static int start(int webPort, TString output_dir);
+	static int start_server(void * ptr);
+
+   FairEventManager* fMan;
+
+   // 0 - PNG, 1 -JPG, 2 - both types
+   int iFormatFiles;
+   // 0 - one (the same) file event.png; 1 - multiple files event_nnn.png (event1.png and etc.)
+   bool isMultiFiles;
+
+   TString outputDir;
+   int web_port;
+   int daemon;
+
+   bool isWebStarted;
+   bool isWeb;
+
+ ClassDef(FairWebScreenshots,1);
+};
+
+#endif
diff --git a/eventdisplay/bmn/BmnDigitDraw.cxx b/eventdisplay/bmn/BmnDigitDraw.cxx
new file mode 100644
index 0000000..8262862
--- /dev/null
+++ b/eventdisplay/bmn/BmnDigitDraw.cxx
@@ -0,0 +1,191 @@
+// -------------------------------------------------------------------------
+// -----                        BmnDigitDraw source file               -----
+// -------------------------------------------------------------------------
+#include "BmnDigitDraw.h"
+#include "BmnDchHit.h"
+#include "BmnHitFinderRun1.h"
+#include "RawDataConverter.h"
+
+#include "TEveManager.h"
+#include "TGeoManager.h"
+
+#include <iostream>
+using namespace std;
+
+// -----   Default constructor   -------------------------------------------
+BmnDigitDraw::BmnDigitDraw()
+  : FairTask("BmnDigitDraw", 0),
+    fVerbose(0),
+    fDigitList(NULL),
+    fHitList(NULL),
+    fEventManager(NULL),
+    fq(NULL),
+    fColor(0),
+    fStyle(0),
+    fDetectorID(0)
+{
+}
+
+// -----   Standard constructor   ------------------------------------------
+BmnDigitDraw::BmnDigitDraw(const char* name, Int_t det_id, Color_t color ,Style_t mstyle,Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fVerbose(iVerbose),
+    fDigitList(NULL),
+    fHitList(NULL),
+    fEventManager(NULL),
+    fq(NULL),
+    fColor(color),
+    fStyle(mstyle),
+    fDetectorID(det_id)
+{
+}
+
+// -------------------------------------------------------------------------
+InitStatus BmnDigitDraw::Init()
+{
+    if (fVerbose > 1)
+        cout<<"BmnDigitDraw::Init()"<<endl;
+
+    if (fDetectorID == 0)
+    {
+        cout<<"BmnDigitDraw::Init() detector ID hasn't been set! Task will be deactivated"<<endl;
+        SetActive(kFALSE);
+        return kERROR;
+    }
+
+    fEventManager = FairEventManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnDigitDraw::Init() get instance of EventManager: "<<fEventManager<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnDigitDraw::Init() get instance of FairRootManager: "<<fManager<<endl;
+
+    fDigitList = (TClonesArray*)fManager->GetObject(GetName());
+    if (fVerbose > 2)
+        cout<<"BmnDigitDraw::Init() get digit list: "<<fDigitList<<endl;
+
+    //if (fEventManager->fEntryCount == 0)
+    //    fEventManager->fEntryCount = bmn_digit_tree->GetEntries();
+    //else
+    //    fEventManager->fEntryCount = TMath::Min(fEventManager->fEntryCount, bmn_digit_tree->GetEntries());
+
+    fq = 0;
+    fHitList = new TClonesArray("BmnDchHit");
+
+    return kSUCCESS;
+}
+
+void BmnDigitDraw::Exec(Option_t* option)
+{
+    if (IsActive())
+    {
+        Reset();
+
+        switch (fDetectorID)
+        {
+            // MWPC digits
+            case 1:
+            {
+                RawDataConverter raw_converter;
+                for (int i = 1; i < 4; i++)
+                {
+                    // get MWPC position
+                    TGeoVolume* pVolume = gGeoManager->GetVolume("cave");
+                    if (pVolume != NULL)
+                    {
+                        TString node_name = TString::Format("mwpc%d_0", i);
+                        TGeoNode* pFirstNode = pVolume->FindNode(node_name);
+                        if (pFirstNode != NULL)
+                        {
+                            TGeoMatrix* pMatrix = pFirstNode->GetMatrix();
+                            //cout<<"mwpc_name: "<<node_name<<" X:"<<pMatrix->GetTranslation()[0]<<" Y:"<<pMatrix->GetTranslation()[1]<<" Z:"<<pMatrix->GetTranslation()[2]<<endl;
+                            raw_converter.SetMwpcPosition(i, TVector3(pMatrix->GetTranslation()[0], pMatrix->GetTranslation()[1], pMatrix->GetTranslation()[2]));
+                        }
+                        else
+                            cout<<"MWPC detector ("<<node_name<<") wasn't found. Default MWPC position is used for visual hits"<<endl;
+                    }
+                    else
+                        cout<<"Cave volume wasn't found. Default MWPC position is used for visual hits"<<endl;
+                }
+
+                raw_converter.MwpcDigits2MwpcHits(fDigitList, fHitList);
+                break;
+            }
+            // DCH digits
+            case 2:
+                ProcessDchDigits(fDigitList, fHitList);
+                break;
+        }
+
+        cout<<GetName()<<" count: "<<fDigitList->GetEntries()<<". hit count: "<<fHitList->GetEntries()<<"."<<endl;
+
+        Int_t npoints = fHitList->GetEntriesFast();
+        TEvePointSet* q = new TEvePointSet(GetName(), npoints, TEvePointSelectorConsumer::kTVT_XYZ);
+
+        q->SetOwnIds(kTRUE);
+        q->SetMarkerColor(fColor);
+        q->SetMarkerSize(1.5);
+        q->SetMarkerStyle(fStyle);
+
+        for (Int_t i = 0; i < npoints; i++)
+        {
+            FairHit* p = (FairHit*) fHitList->At(i);
+            if (p != 0)
+            {
+                TVector3 vec(p->GetX(), p->GetY(), p->GetZ());
+                q->SetNextPoint(vec.X(),vec.Y(), vec.Z());
+                q->SetPointId(GetValue(p, i));
+                //cout<<"VEC X: "<<vec.X()<<" Y:"<<vec.Y()<<" Z:"<<vec.Z()<<endl;
+            }
+        }
+
+        if (fEventManager->EveRecoPoints == NULL)
+        {
+            fEventManager->EveRecoPoints = new TEveElementList("Reco points");
+            gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
+            fEventManager->EveRecoPoints->SetRnrState(kFALSE);
+        }
+
+        gEve->AddElement(q, fEventManager->EveRecoPoints);
+
+        gEve->Redraw3D(kFALSE);
+
+        fq = q;
+    }//if (IsActive())
+}
+
+TObject* BmnDigitDraw::GetValue(TObject* obj,Int_t i)
+{
+    return new TNamed(Form("Point %d", i),"");
+}
+
+// -----   Destructor   ----------------------------------------------------
+BmnDigitDraw::~BmnDigitDraw()
+{
+}
+
+// -------------------------------------------------------------------------
+void BmnDigitDraw::SetParContainers()
+{
+}
+
+/** Action after each event**/
+void BmnDigitDraw::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void BmnDigitDraw::Reset()
+{
+    fHitList->Delete();
+
+    if (fq != 0)
+    {
+        fq->Reset();
+
+        gEve->RemoveElement(fq, fEventManager->EveRecoPoints);
+    }
+}
+
+ClassImp(BmnDigitDraw);
diff --git a/eventdisplay/bmn/BmnDigitDraw.h b/eventdisplay/bmn/BmnDigitDraw.h
new file mode 100644
index 0000000..70529e2
--- /dev/null
+++ b/eventdisplay/bmn/BmnDigitDraw.h
@@ -0,0 +1,63 @@
+// -------------------------------------------------------------------------
+// -----                      BmnDigitDraw header file                 -----
+// -------------------------------------------------------------------------
+
+#ifndef BMNDIGITDRAW_H
+#define BMNDIGITDRAW_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+
+#include "TObject.h"
+#include "TVector3.h"
+#include "TClonesArray.h"
+#include "TEvePointSet.h"
+
+class BmnDigitDraw : public FairTask
+{
+  public:
+    /** Default constructor **/
+    BmnDigitDraw();
+
+    /** Standard constructor
+    *@param name        Name of task
+    *@param iVerbose    Verbosity level,
+    *@param det_id      Detector ID:
+    * 1 - MWPC, 2 - DCH **/
+    BmnDigitDraw(const char* name, Int_t det_id, Color_t color, Style_t mstyle, Int_t iVerbose = 1);
+
+    /** Destructor **/
+    virtual ~BmnDigitDraw();
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;}
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+    void Reset();
+
+  protected:
+    virtual TObject* GetValue(TObject* obj,Int_t i);
+
+    //  Verbosity level
+    Int_t   fVerbose;
+    virtual void SetParContainers();
+    virtual InitStatus Init();
+    /** Action after each event**/
+    virtual void Finish();
+    TChain* bmn_digit_tree;  //!
+    TClonesArray* fDigitList; //!
+    TClonesArray* fHitList; //!
+    FairEventManager* fEventManager;   //!
+    TEvePointSet* fq;    //!
+    Color_t fColor; //!
+    Style_t fStyle; //!
+    Int_t fDetectorID; //!
+
+  private:
+    BmnDigitDraw(const BmnDigitDraw&);
+    BmnDigitDraw& operator=(const BmnDigitDraw&);
+
+    ClassDef(BmnDigitDraw,1);
+};
+
+#endif
diff --git a/eventdisplay/bmn/BmnGlobalTrackDraw.cxx b/eventdisplay/bmn/BmnGlobalTrackDraw.cxx
new file mode 100644
index 0000000..0631564
--- /dev/null
+++ b/eventdisplay/bmn/BmnGlobalTrackDraw.cxx
@@ -0,0 +1,341 @@
+// -------------------------------------------------------------------------
+// -----                  BmnGlobalTrackDraw source file                     -----
+// -----            created 10/12/13 by K. Gertsenberger               -----
+// ----- class to visualize reconstructed GlobalTracks in EventDisplay -----
+// -------------------------------------------------------------------------
+
+#include "BmnGlobalTrackDraw.h"
+#include "BmnGlobalTrack.h"
+#include "BmnGemTrack.h"
+
+#include "TEveManager.h"
+#include "TEvePathMark.h"
+#include "TEveVector.h"
+#include "TDatabasePDG.h"
+
+#include <iostream>
+using namespace std;
+
+// default constructor
+BmnGlobalTrackDraw::BmnGlobalTrackDraw()
+  : FairTask("BmnGlobalTrackDraw", 0),
+    fTrackList(NULL),
+    fTrPr(NULL),
+    fEventManager(NULL),
+    fEveTrList(NULL),
+    fEvent(""),
+    fTrList(NULL),
+    MinEnergyLimit(-1.),
+    MaxEnergyLimit(-1.),
+    PEnergy(-1.)
+{
+}
+
+// standard constructor
+BmnGlobalTrackDraw::BmnGlobalTrackDraw(const char* name, Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fTrackList(NULL),
+    fTrPr(NULL),
+    fEventManager(NULL),
+    fEveTrList(new TObjArray(16)),
+    fEvent(""),
+    fTrList(NULL),
+    MinEnergyLimit(-1.),
+    MaxEnergyLimit(-1.),
+    PEnergy(-1.)
+{
+}
+
+// initialization of the track drawing task
+InitStatus BmnGlobalTrackDraw::Init()
+{
+    if (fVerbose > 1)
+        cout<<"BmnGlobalTrackDraw::Init()"<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+
+    fTrackList = (TClonesArray*)fManager->GetObject("GlobalTrack");
+    if (fTrackList == 0)
+    {
+        cout<<"BmnGlobalTrackDraw::Init()  branch GlobalTrack not found! Task will be deactivated"<<endl;
+        SetActive(kFALSE);
+        return kERROR;
+    }
+
+    if (fVerbose > 2)
+        cout<<"BmnGlobalTrackDraw::Init() get track list "<<fTrackList<<endl;
+
+    fGemTrackList = (TClonesArray*) fManager->GetObject("BmnGemTracks");
+    fGemHitList = (TClonesArray*) fManager->GetObject("BmnGemStripHit");
+
+    fTof1HitList = (TClonesArray*) fManager->GetObject("TOF1Hit");
+    fTof2HitList = (TClonesArray*) fManager->GetObject("BmnTof2Hit");
+    fDch1HitList = (TClonesArray*) fManager->GetObject("BmnDch1Hit0");
+    fDch2HitList = (TClonesArray*) fManager->GetObject("BmnDch2Hit0");
+
+    fEventManager = FairEventManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnGlobalTrackDraw::Init() get instance of FairEventManager "<<endl;
+
+    fEvent = "Current Event";
+    MinEnergyLimit = fEventManager->GetEvtMinEnergy();
+    MaxEnergyLimit = fEventManager->GetEvtMaxEnergy();
+    PEnergy = 0;
+
+    return kSUCCESS;
+}
+// -------------------------------------------------------------------------
+void BmnGlobalTrackDraw::Exec(Option_t* option)
+{
+    if (!IsActive())
+        return;
+
+    if (fVerbose > 1)
+        cout<<" BmnGlobalTrackDraw::Exec "<<endl;
+
+    Reset();
+
+    BmnGlobalTrack* tr;
+    //cout<<"fTrackList->GetEntriesFast(): "<<fTrackList->GetEntriesFast()<<". fTrackList->GetEntries(): "<<fTrackList->GetEntries()<<endl;
+    for (Int_t i = 0; i < fTrackList->GetEntriesFast(); i++)
+    {
+        if (fVerbose > 2)
+            cout<<"BmnGlobalTrackDraw::Exec "<<i<<endl;
+
+        tr = (BmnGlobalTrack*)fTrackList->At(i);
+        const FairTrackParam* pParamFirst = tr->GetParamFirst();
+
+        // define whether track is primary
+        bool isPrimary = ( (TMath::Abs(pParamFirst->GetX())<10) && (TMath::Abs(pParamFirst->GetY())<10) && (TMath::Abs(pParamFirst->GetZ())<10) );
+
+        // skip secondary tracks if primary flag is set
+        if (fEventManager->IsPriOnly() && (!isPrimary))
+            continue;
+
+        // get PDG particle code, without identification - Rootino
+        int particlePDG = 0;
+
+        // get momentum
+        TVector3 mom;
+        pParamFirst->Momentum(mom);
+        Double_t px = mom.X(), py = mom.Y(), pz = mom.Z();
+
+        // create particle
+        TParticlePDG* fParticlePDG = TDatabasePDG::Instance()->GetParticle(particlePDG);
+        TParticle* P = new TParticle(particlePDG, i, -1, -1, -1, -1, px, py, pz, 0, pParamFirst->GetX(), pParamFirst->GetY(), pParamFirst->GetZ(), 0);
+
+        // get EVE track list for this particle
+        fTrList = GetTrGroup(P);
+        // create EVE track corresponding global track
+        TEveTrack* track = new TEveTrack(P, particlePDG, fTrPr);
+        // set line color corresponding PDG particle code
+        track->SetLineColor(fEventManager->Color(particlePDG));
+
+        // get GEM track for global track
+        BmnGemTrack* pGemTrack = (BmnGemTrack*) fGemTrackList->UncheckedAt(tr->GetGemTrackIndex());
+        Int_t Np = pGemTrack->GetNHits();
+
+        // cycle: add hits (points) to EVE path for this track
+        Int_t n;
+        for (n = 0; n < Np; n++)
+        {
+            FairHit* pHit = (FairHit*) fGemHitList->UncheckedAt(pGemTrack->GetHitIndex(n));
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+        }
+
+        // add TOF1 hit
+        if (tr->GetTof1HitIndex() > -1)
+        {
+            FairHit* pHit = (FairHit*) fTof1HitList->UncheckedAt(tr->GetTof1HitIndex());
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+
+            n++;
+        }
+
+        // add DCH1 hit
+        if (tr->GetDch1HitIndex() > -1)
+        {
+            FairHit* pHit = (FairHit*) fDch1HitList->UncheckedAt(tr->GetDch1HitIndex());
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+
+            n++;
+        }
+
+        // add DCH2 hit
+        if (tr->GetDch2HitIndex() > -1)
+        {
+            FairHit* pHit = (FairHit*) fDch2HitList->UncheckedAt(tr->GetDch2HitIndex());
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+
+            n++;
+        }
+
+        // add TOF2 hit
+        if (tr->GetTof2HitIndex() > -1)
+        {
+            FairHit* pHit = (FairHit*) fTof2HitList->UncheckedAt(tr->GetTof2HitIndex());
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+
+            n++;
+        }
+
+        // add track to EVE track list
+        fTrList->AddElement(track);
+
+        if (fVerbose > 3)
+            cout<<"track added "<<track->GetName()<<endl;
+    }
+
+    // redraw EVE scenes
+    gEve->Redraw3D(kFALSE);
+}
+
+// destructor
+BmnGlobalTrackDraw::~BmnGlobalTrackDraw()
+{
+}
+
+void BmnGlobalTrackDraw::SetParContainers()
+{
+}
+
+void BmnGlobalTrackDraw::Finish()
+{
+}
+
+void BmnGlobalTrackDraw::Reset()
+{
+    // clear EVE track lists (fEveTrList)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList*  ele = (TEveTrackList*) fEveTrList->At(i);
+        gEve->RemoveElement(ele, fEventManager->EveRecoTracks);
+    }
+
+    fEveTrList->Clear();
+}
+
+// return pointer to EVE track list for given particle name. if list don't exist then create it
+TEveTrackList* BmnGlobalTrackDraw::GetTrGroup(TParticle* P)
+{
+    fTrList = 0;
+
+    // serch if there us existing track list for this particle (with given name)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
+        if (strcmp(TrListIn->GetName(), P->GetName()) == 0)
+        {
+            fTrList = TrListIn;
+            break;
+        }
+    }
+
+    // create new track list for new particle's name
+    if (fTrList == 0)
+    {
+        fTrPr = new TEveTrackPropagator();
+        fTrList = new  TEveTrackList(P->GetName(), fTrPr);
+        fTrList->SetMainColor(fEventManager->Color(P->GetPdgCode()));
+        fEveTrList->Add(fTrList);
+
+        if (fEventManager->EveRecoTracks == NULL)
+        {
+            fEventManager->EveRecoTracks = new TEveElementList("Reco tracks");
+            gEve->AddElement(fEventManager->EveRecoTracks, fEventManager);
+            fEventManager->EveRecoTracks->SetRnrState(kFALSE);
+        }
+
+        gEve->AddElement(fTrList, fEventManager->EveRecoTracks);
+        fTrList->SetRnrLine(kTRUE);
+    }
+
+    return fTrList;
+}
+
+ClassImp(BmnGlobalTrackDraw)
diff --git a/eventdisplay/bmn/BmnGlobalTrackDraw.h b/eventdisplay/bmn/BmnGlobalTrackDraw.h
new file mode 100644
index 0000000..58370b7
--- /dev/null
+++ b/eventdisplay/bmn/BmnGlobalTrackDraw.h
@@ -0,0 +1,81 @@
+// -------------------------------------------------------------------------
+// -----                    BmnGlobalTrackDraw header file                   -----
+// -----              created 10/12/13 by K. Gertsenberger             -----
+// ----- class to visualize reconstructed GlobalTracks in EventDisplay -----
+// -------------------------------------------------------------------------
+
+
+#ifndef BmnGlobalTrackDraw_H
+#define BmnGlobalTrackDraw_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+
+#include "TEveTrackPropagator.h"
+#include "TEveTrack.h"
+#include "TClonesArray.h"
+#include "TObjArray.h"
+#include "TString.h"
+#include "TParticle.h"
+
+
+class BmnGlobalTrackDraw : public FairTask
+{
+  public:
+    // default constructor
+    BmnGlobalTrackDraw();
+
+    // constructor: @name - name of task, @iVerbose- verbosity level
+    BmnGlobalTrackDraw(const char* name, Int_t iVerbose = 1);
+
+    // destructor
+    virtual ~BmnGlobalTrackDraw();
+
+    // set verbosity level for this task and all of the subtasks
+    void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;}
+    // execute function of this task
+    virtual void Exec(Option_t* option);
+    // initialization of the track drawing task
+    virtual InitStatus Init();
+    virtual void SetParContainers();
+
+    // action after each event processing
+    virtual void Finish();
+    void Reset();
+
+    // return pointer to EVE track list for given particle name. if list don't exist then create it
+    TEveTrackList* GetTrGroup(TParticle* P);
+
+  protected:
+    // global tracks collection
+    TClonesArray*  fTrackList;      //!
+    // GEM tracks collection
+    TClonesArray*  fGemTrackList;   //!
+    // GEM hits collection
+    TClonesArray*  fGemHitList;     //!
+    // TOF1 hits collection
+    TClonesArray*  fTof1HitList;     //!
+    // TOF2 hits collection
+    TClonesArray*  fTof2HitList;     //!
+    // DCH1 hits collection
+    TClonesArray*  fDch1HitList;     //!
+    // DCH2 hits collection
+    TClonesArray*  fDch2HitList;     //!
+    // EVE track propagator
+    TEveTrackPropagator* fTrPr;
+    FairEventManager* fEventManager;    //!
+    TObjArray* fEveTrList;
+    TString fEvent;                     //!
+    TEveTrackList* fTrList;             //!
+
+    Double_t MinEnergyLimit;
+    Double_t MaxEnergyLimit;
+    Double_t PEnergy;
+
+  private:
+    BmnGlobalTrackDraw(const BmnGlobalTrackDraw&);
+    BmnGlobalTrackDraw& operator=(const BmnGlobalTrackDraw&);
+
+    ClassDef(BmnGlobalTrackDraw,1);
+};
+#endif
diff --git a/eventdisplay/bmn/BmnTrackDrawH.cxx b/eventdisplay/bmn/BmnTrackDrawH.cxx
new file mode 100644
index 0000000..4615c85
--- /dev/null
+++ b/eventdisplay/bmn/BmnTrackDrawH.cxx
@@ -0,0 +1,239 @@
+// -------------------------------------------------------------------------
+// -----                  BmnTrackDrawH source file                  -----
+// -----            created 05/10/15 by K. Gertsenberger               -----
+// ----- class to visualize GlobalTracks from *.root in EventDisplay   -----
+// -------------------------------------------------------------------------
+
+#include "BmnTrackDrawH.h"
+#include "BmnTrack.h"
+#include "FairHit.h"
+
+#include "TEveManager.h"
+#include "TEvePathMark.h"
+#include "TEveVector.h"
+#include "TDatabasePDG.h"
+
+#include <iostream>
+using namespace std;
+
+// default constructor
+BmnTrackDrawH::BmnTrackDrawH()
+  : FairTask("BmnTrackDrawH", 0),
+    fTrackList(NULL),
+    fHitsBranchName(""),
+    fHitList(NULL),
+    fTrPr(NULL),
+    fEventManager(NULL),
+    fEveTrList(NULL),
+    fTrList(NULL),
+    MinEnergyLimit(-1.),
+    MaxEnergyLimit(-1.),
+    PEnergy(-1.)
+{
+}
+
+// standard constructor
+BmnTrackDrawH::BmnTrackDrawH(const char* name, TString hitsBranchName, Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fTrackList(NULL),
+    fHitsBranchName(hitsBranchName),
+    fHitList(NULL),
+    fTrPr(NULL),
+    fEventManager(NULL),
+    fEveTrList(new TObjArray(16)),
+    fTrList(NULL),
+    MinEnergyLimit(-1.),
+    MaxEnergyLimit(-1.),
+    PEnergy(-1.)
+{
+}
+
+// initialization of the track drawing task
+InitStatus BmnTrackDrawH::Init()
+{
+    if (fVerbose > 1)
+        cout<<"BmnTrackDrawH::Init()"<<endl;
+
+    fEventManager = FairEventManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawH::Init() get instance of EventManager: "<<fEventManager<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawH::Init() get instance of FairRootManager: "<<fManager<<endl;
+
+    fTrackList = (TClonesArray*)fManager->GetObject(GetName());
+    if(fTrackList == 0)
+    {
+      cout<<"BmnTrackDrawH::Init()  branch "<<GetName()<<" Not found! Task will be deactivated "<<endl;
+      SetActive(kFALSE);
+    }
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawH::Init() get track list " <<fTrackList<<" from branch '"<<GetName()<<"'"<<endl;
+
+    fHitList = (TClonesArray*)fManager->GetObject(fHitsBranchName);
+    if(fHitList == 0)
+    {
+      cout<<"BmnTrackDrawH::Init()  branch "<<fHitsBranchName<<" Not found! Task will be deactivated "<<endl;
+      SetActive(kFALSE);
+    }
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawH::Init() get list of hits "<<fHitList<<" from branch '"<<fHitsBranchName<<"'"<<endl;
+
+    MinEnergyLimit = fEventManager->GetEvtMinEnergy();
+    MaxEnergyLimit = fEventManager->GetEvtMaxEnergy();
+    PEnergy = 0;
+
+    return kSUCCESS;
+}
+
+// -------------------------------------------------------------------------
+void BmnTrackDrawH::Exec(Option_t* option)
+{
+    if (!IsActive()) return;
+    if (fVerbose > 1)
+        cout<<" BmnTrackDrawH::Exec "<<endl;
+
+    Reset();
+
+    BmnTrack* current_track;
+    if (fVerbose > 1)
+        cout<<" BmnTrackDrawH::Exec: the number of tracks is "<<fTrackList->GetEntriesFast()<<endl;
+    for (Int_t i = 0; i < fTrackList->GetEntriesFast(); i++)
+    {
+        if (fVerbose > 2)
+            cout<<"BmnTrackDrawH::Exec "<<i<<endl;
+
+        current_track = (BmnTrack*) fTrackList->At(i);
+        const FairTrackParam* pParamFirst = current_track->GetParamFirst();
+
+        // define whether track is primary
+        bool isPrimary = ( (TMath::Abs(pParamFirst->GetX())<10) && (TMath::Abs(pParamFirst->GetY())<10) && (TMath::Abs(pParamFirst->GetZ())<10) );
+
+        // skip secondary tracks if primary flag is set
+        if (fEventManager->IsPriOnly() && (!isPrimary))
+            continue;
+
+        // get PDG particle code, without identification - Rootino
+        int particlePDG = 0;
+
+        // get momentum
+        TVector3 mom;
+        pParamFirst->Momentum(mom);
+        Double_t px = mom.X(), py = mom.Y(), pz = mom.Z();
+
+        // create particle
+        TParticlePDG* fParticlePDG = TDatabasePDG::Instance()->GetParticle(particlePDG);
+        TParticle* P = new TParticle(particlePDG, i, -1, -1, -1, -1, px, py, pz, 0, pParamFirst->GetX(), pParamFirst->GetY(), pParamFirst->GetZ(), 0);
+
+        // get EVE track list for this particle
+        fTrList = GetTrGroup(P);
+        // create EVE track corresponding global track
+        TEveTrack* track = new TEveTrack(P, particlePDG, fTrPr);
+        // set line color corresponding PDG particle code
+        track->SetLineColor(fEventManager->Color(particlePDG));
+
+        Int_t Np = current_track->GetNHits();
+
+        // cycle: add hits (points) to EVE path for this track
+        //cout<<"Points: "<<Np<<endl;
+        for (Int_t n = 0; n < Np; n++)
+        {
+            FairHit* pHit = NULL;
+            pHit = (FairHit*) fHitList->UncheckedAt(current_track->GetHitIndex(n));
+
+            track->SetPoint(n, pHit->GetX(), pHit->GetY(), pHit->GetZ());
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(pHit->GetX(), pHit->GetY(), pHit->GetZ());
+            //cout<<"Point: X="<<pHit->GetX()<<" Y="<<pHit->GetY()<<" Z="<<pHit->GetZ()<<endl;
+            path->fV = pos;
+            path->fTime = pHit->GetTimeStamp();
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            // add path marker for current EVE track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+        }
+
+        // add track to EVE track list
+        fTrList->AddElement(track);
+
+        if (fVerbose > 3)
+            cout<<"track added "<<track->GetName()<<endl;
+    }
+
+    // redraw EVE scenes
+    gEve->Redraw3D(kFALSE);
+}
+
+// destructor
+BmnTrackDrawH::~BmnTrackDrawH()
+{
+}
+
+void BmnTrackDrawH::SetParContainers()
+{
+}
+
+void BmnTrackDrawH::Finish()
+{
+}
+
+void BmnTrackDrawH::Reset()
+{
+    // clear EVE track lists (fEveTrList)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList*  ele = (TEveTrackList*) fEveTrList->At(i);
+        gEve->RemoveElement(ele, fEventManager->EveRecoTracks);
+    }
+
+    fEveTrList->Clear();
+}
+
+// return pointer to EVE track list for given particle name. if list don't exist then create it
+TEveTrackList* BmnTrackDrawH::GetTrGroup(TParticle* P)
+{
+    fTrList = 0;
+
+    // serch if there us existing track list for this particle (with given name)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
+        if (strcmp(TrListIn->GetName(), P->GetName()) == 0)
+        {
+            fTrList = TrListIn;
+            break;
+        }
+    }
+
+    // create new track list for new particle's name
+    if (fTrList == 0)
+    {
+        fTrPr = new TEveTrackPropagator();
+        fTrList = new  TEveTrackList(P->GetName(), fTrPr);
+        fTrList->SetMainColor(fEventManager->Color(P->GetPdgCode()));
+        fEveTrList->Add(fTrList);
+
+        if (fEventManager->EveRecoTracks == NULL)
+        {
+            fEventManager->EveRecoTracks = new TEveElementList("Reco tracks");
+            gEve->AddElement(fEventManager->EveRecoTracks, fEventManager);
+            fEventManager->EveRecoTracks->SetRnrState(kFALSE);
+        }
+
+        gEve->AddElement(fTrList, fEventManager->EveRecoTracks);
+        fTrList->SetRnrLine(kTRUE);
+    }
+
+    return fTrList;
+}
+
+ClassImp(BmnTrackDrawH)
diff --git a/eventdisplay/bmn/BmnTrackDrawH.h b/eventdisplay/bmn/BmnTrackDrawH.h
new file mode 100644
index 0000000..2568383
--- /dev/null
+++ b/eventdisplay/bmn/BmnTrackDrawH.h
@@ -0,0 +1,72 @@
+// ---------------------------------------------------------------------------
+// -----                    BmnTrackDrawH header file
+// -----                created 05/10/15 by K. Gertsenberger
+// ----- class to visualize BmnTrack* collection by hits of neighbour bramch
+// ---------------------------------------------------------------------------
+
+
+#ifndef BMNTRACKDRAWH_H
+#define BMNTRACKDRAWH_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+
+#include "TEveTrackPropagator.h"
+#include "TEveTrack.h"
+#include "TClonesArray.h"
+#include "TObjArray.h"
+#include "TParticle.h"
+
+
+class BmnTrackDrawH : public FairTask
+{
+  public:
+    /** Default constructor **/
+    BmnTrackDrawH();
+
+    /** Standard constructor
+    *@param name        Name of task and branch with BmnTrack* collection
+    *@param iVerbose    Verbosity level
+    **/
+    BmnTrackDrawH(const char* name, TString hitsBranchName, Int_t iVerbose = 1);
+
+    /** Destructor **/
+    virtual ~BmnTrackDrawH();
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;}
+    /** execute function of this task **/
+    virtual void Exec(Option_t* option);
+
+    // initialization of the track drawing task
+    virtual InitStatus Init();
+    virtual void SetParContainers();
+    void Reset();
+    virtual void Finish();
+
+    // return pointer to EVE track list for given particle name. if list don't exist then create it
+    TEveTrackList* GetTrGroup(TParticle* P);
+
+  protected:
+    // tracks collection
+    TClonesArray*  fTrackList;          //!
+    // hits collection corresponding tracks
+    TClonesArray*  fHitList;            //!
+
+    // EVE track propagator
+    TEveTrackPropagator* fTrPr;
+    FairEventManager* fEventManager;    //!
+    TObjArray* fEveTrList;              //!
+    TEveTrackList* fTrList;             //!
+    Double_t MinEnergyLimit;
+    Double_t MaxEnergyLimit;
+    Double_t PEnergy;
+    TString fHitsBranchName;
+    
+  private:
+    BmnTrackDrawH(const BmnTrackDrawH&);
+    BmnTrackDrawH& operator=(const BmnTrackDrawH&);
+
+    ClassDef(BmnTrackDrawH,1);
+};
+#endif
diff --git a/eventdisplay/bmn/BmnTrackDrawP.cxx b/eventdisplay/bmn/BmnTrackDrawP.cxx
new file mode 100644
index 0000000..cc67faf
--- /dev/null
+++ b/eventdisplay/bmn/BmnTrackDrawP.cxx
@@ -0,0 +1,312 @@
+// -------------------------------------------------------------------------
+// -----                        BmnTrackDrawP source file               -----
+// -----                  Created 02/12/15  by K. Gertsenberger        -----
+// -------------------------------------------------------------------------
+
+#include "BmnTrackDrawP.h"
+#include "BmnTrack.h"
+#include "CbmStack.h"
+
+#include "TROOT.h"
+#include "TGeant3.h"
+#include "TGeant3TGeo.h"
+#include "TEveTrackPropagator.h"
+#include "TEveManager.h"
+#include "TDatabasePDG.h"
+
+#include <iostream>
+using namespace std;
+
+// -----   Default constructor   -------------------------------------------
+BmnTrackDrawP::BmnTrackDrawP()
+    : FairTask("BmnTrackDrawP", 0),
+      fTrackList(NULL),
+      fTrPr(NULL),
+      fEventManager(NULL),
+      fEveTrList(NULL),
+      fTrList(NULL),
+      MinEnergyLimit(-1.),
+      MaxEnergyLimit(-1.),
+      PEnergy(-1.)
+{
+}
+// -------------------------------------------------------------------------
+
+// -----   Standard constructor   ------------------------------------------
+BmnTrackDrawP::BmnTrackDrawP(const char* name, Int_t iVerbose)
+    : FairTask(name, iVerbose),
+      fTrackList(NULL),
+      fTrPr(NULL),
+      fEventManager(NULL),
+      fEveTrList(new TObjArray(16)),
+      fTrList(NULL),
+      MinEnergyLimit(-1.),
+      MaxEnergyLimit(-1.),
+      PEnergy(-1.)
+{
+}
+// -------------------------------------------------------------------------
+
+
+InitStatus BmnTrackDrawP::Init()
+{
+    if (fVerbose > 1)
+        cout<<"BmnTrackDrawP::Init()"<<endl;
+
+    fEventManager = FairEventManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawP::Init() get instance of EventManager"<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+    if (fVerbose > 2)
+        cout<<"BmnExpTrackDraw::Init() get instance of FairRootManager: "<<fManager<<endl;
+
+    fTrackList = (TClonesArray*)fManager->GetObject(GetName());
+    if (fVerbose > 2)
+        cout<<"BmnTrackDrawP::Init() get track list " <<fTrackList<<" from branch '"<<GetName()<<"'"<<endl;
+
+    MinEnergyLimit = fEventManager->GetEvtMinEnergy();
+    MaxEnergyLimit = fEventManager->GetEvtMaxEnergy();
+    PEnergy = 0;
+
+    if (gMC == NULL)
+        InitGeant3();
+
+    fPro = new FairGeanePro();
+
+    fTrajFilter = FairTrajFilter::Instance();
+
+    return kSUCCESS;
+}
+
+void BmnTrackDrawP::InitGeant3()
+{
+    /** Private method for setting Geane configuration and cuts*/
+    TString work = getenv("VMCWORKDIR");
+    TString work_config = work + "/gconfig/";
+    TString LibMacro =  work_config + "g3libs.C";
+    TString ConfigMacro = work_config + "g3Config.C";
+    TString cuts = work_config + "SetCuts.C";
+
+    // Now load the Config and Cuts
+    gROOT->LoadMacro(LibMacro.Data());
+    gROOT->ProcessLine("g3libs()");
+
+    //gROOT->LoadMacro(ConfigMacro.Data());
+    //gROOT->ProcessLine("Config()");
+
+    TGeant3* geant3 = new TGeant3TGeo("C++ Interface to Geant3");
+    //TGeant3* geant3 = new  TGeant3("C++ Interface to Geant3");
+    // create Cbm Specific Stack
+    CbmStack *st = new CbmStack();
+    // Set minimum number of points to store the track
+    // The default value is one, which means each track
+    // needs at least 1 point in any detector
+    st->SetMinPoints(1);
+    geant3->SetStack(st);
+    // ******* GEANT3  specific configuration for simulated Runs  *******
+    geant3->SetTRIG(1);         //Number of events to be processed
+    geant3->SetSWIT(4, 100);
+    geant3->SetDEBU(0, 0, 1);
+    geant3->SetRAYL(1);
+    geant3->SetSTRA(0); //1);
+    geant3->SetAUTO(0);         //Select automatic STMIN etc... calc. (AUTO 1) or manual (AUTO 0)
+    geant3->SetABAN(0);         //Restore 3.16 behaviour for abandoned tracks
+    geant3->SetOPTI(2);         //Select optimisation level for GEANT geometry searches (0,1,2)
+    geant3->SetERAN(5.e-7);
+    geant3->SetCKOV(1);     // cerenkov photons
+
+    gROOT->LoadMacro(cuts);
+    gROOT->ProcessLine("SetCuts()");
+
+    //gMC->SetMagField(fxField);
+    //gMC->Init();
+    gMC->BuildPhysics();
+}
+
+// -------------------------------------------------------------------------
+void BmnTrackDrawP::Exec(Option_t* option)
+{
+    if (!IsActive())
+        return;
+
+    if (fVerbose > 1)
+        cout<<"BmnTrackDrawP::Exec"<< endl;
+
+    Reset();
+
+    BmnTrack* current_track;
+    cout<<"Tracks: "<<fTrackList->GetEntriesFast()<<endl;
+    for (Int_t i = 0; i < fTrackList->GetEntriesFast(); i++)
+    {
+        if (fVerbose > 2)
+            cout<<"BmnTrackDrawP::Exec "<<i<<endl;
+
+        current_track = (BmnTrack*) fTrackList->At(i);
+        FairTrackParam* pParamFirst = (FairTrackParam*) current_track->GetParamFirst();
+
+        // define whether track AL-TURAis primary
+        bool isPrimary = ( (TMath::Abs(pParamFirst->GetX())<10) && (TMath::Abs(pParamFirst->GetY())<10) && (TMath::Abs(pParamFirst->GetZ())<10) );
+
+        // skip secondary tracks if primary flag is set
+        if (fEventManager->IsPriOnly() && (!isPrimary))
+            continue;
+
+        // set PDG particle code
+        int particlePDG = 2212; // 0; // without identification - Rootino
+
+        // get momentum
+        TVector3 mom;
+        pParamFirst->SetQp(1);
+        pParamFirst->Momentum(mom);
+        Double_t px = mom.X(), py = mom.Y(), pz = mom.Z();
+
+        // create particle
+        TParticlePDG* fParticlePDG = TDatabasePDG::Instance()->GetParticle(particlePDG);
+        //TParticle(Int_t pdg, Int_t status, Int_t mother1, Int_t mother2, Int_t daughter1, Int_t daughter2, Double_t px, Double_t py, Double_t pz, Double_t etot, Double_t vx, Double_t vy, Double_t vz, Double_t time)
+        TParticle* P = new TParticle(particlePDG, i, -1, -1, -1, -1, px, py, pz, 0, pParamFirst->GetX(), pParamFirst->GetY(), pParamFirst->GetZ(), 0);
+
+        // get EVE track list for this particle
+        fTrList = GetTrGroup(P);
+        // create EVE track corresponding global track
+        TEveTrack* track = new TEveTrack(P, particlePDG, fTrPr);
+        // set line color corresponding PDG particle code
+        track->SetLineColor(fEventManager->Color(particlePDG));
+
+        // propagate the tracks by Geane
+        x1[0] = pParamFirst->GetX();
+        x1[1] = pParamFirst->GetY();
+        x1[2] = pParamFirst->GetZ();
+        p1[0] = px;
+        p1[1] = py;
+        p1[2] = pz;
+
+        x2[0] = 0;
+        x2[1] = 0;
+        x2[2] = 0;
+        p2[0] = 0;
+        p2[1] = 0;
+        p2[2] = 0;
+
+        cout<<"Propagate track from ("<<pParamFirst->GetX()<<","<<pParamFirst->GetY()<<","<<pParamFirst->GetZ()<<") with momentum: ("
+           <<px<<","<<py<<","<<pz<<")"<<endl;
+
+        Bool_t isSuccess = fPro->Propagate(x1, p1, x2, p2, particlePDG);
+
+        cout<<"isSuccess: "<<isSuccess<<". Track end point: ("<<x2[0]<<","<<x2[1]<<","<<x2[2]<<") with momentum: ("<<p2[0]<<","<<p2[1]<<","<<p2[2]<<")"<<endl;
+
+        /*FairTrackParH* fTrackParH = new FairTrackParH(tr1.GetPos()*TMath::Cos(tr1.Theta())*TMath::Cos(tr1.Phi()),
+                                                      tr1.GetPos()*TMath::Cos(tr1.Theta())*TMath::Sin(tr1.Phi()), tr1.GetPos()*TMath::Cos(tr1.Theta()),
+                                                      tr1.Theta(), tr1.Phi(), 1/tr1.Momentum(), tr1.GetCovariance());
+        fGeanePro->Init(fTrackParH);
+        fGeanePro->PropagateToVolume("tof1", 1, 0);
+        fGeanePro->Propagate(211);*/
+
+        TGeoTrack* geo_track = fTrajFilter->GetCurrentTrk();
+        Int_t Np = geo_track->GetNpoints();
+        // cycle: add hits (points) to EVE path for this track
+        cout<<"Points: "<<Np<<endl;
+        for (Int_t n = 0; n < Np; n++)
+        {
+            const Double_t* point = geo_track->GetPoint(n);
+
+            track->SetPoint(n, point[0], point[1], point[2]);
+
+            TEvePathMark* path = new TEvePathMark();
+            TEveVector pos = TEveVector(point[0], point[1],point[2]);
+            //cout<<"Point: X="<<point[0]<<" Y="<<point[1]<<" Z="<<point[2]<<endl;
+            path->fV = pos;
+            path->fTime = point[3];
+            if (n == 0)
+            {
+                TEveVector Mom = TEveVector(px, py, pz);
+                path->fP = Mom;
+            }
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+
+            // add path marker for current EVETChain* bmn_data_tree;  //! track
+            track->AddPathMark(*path);
+
+            if (fVerbose > 3)
+                cout<<"Path marker added "<<path<<endl;
+         }
+
+         // add track to EVE track list
+         fTrList->AddElement(track);
+
+         if (fVerbose > 3)
+             cout<<"track added "<<track->GetName()<<endl;
+    }
+
+    if (fEventManager->EveRecoTracks == NULL)
+    {
+        fEventManager->EveRecoTracks = new TEveElementList("Reco tracks");
+        gEve->AddElement(fEventManager->EveRecoTracks, fEventManager);
+        fEventManager->EveRecoTracks->SetRnrState(kFALSE);
+    }
+
+    // redraw EVE scenes
+    gEve->Redraw3D(kFALSE);
+}
+
+// -----   Destructor   ----------------------------------------------------
+BmnTrackDrawP::~BmnTrackDrawP()
+{
+}
+
+// -------------------------------------------------------------------------
+void BmnTrackDrawP::SetParContainers()
+{
+}
+
+// -------------------------------------------------------------------------
+void BmnTrackDrawP::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void BmnTrackDrawP::Reset()
+{
+    // clear EVE track lists (fEveTrList)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList*  ele = (TEveTrackList*) fEveTrList->At(i);
+        gEve->RemoveElement(ele, fEventManager->EveRecoTracks);
+    }
+
+    fEveTrList->Clear();
+}
+
+TEveTrackList* BmnTrackDrawP::GetTrGroup(TParticle* P)
+{
+    fTrList = 0;
+
+    // serch if there us existing track list for this particle (with given name)
+    for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
+    {
+        TEveTrackList* TrListIn = (TEveTrackList*) fEveTrList->At(i);
+        if (strcmp(TrListIn->GetName(), P->GetName()) == 0)
+        {
+            fTrList = TrListIn;
+            break;
+        }
+    }
+
+    // create new track list for new particle's name
+    if (fTrList == 0)
+    {
+        fTrPr = new TEveTrackPropagator();
+        fTrList = new  TEveTrackList(P->GetName(), fTrPr);
+        fTrList->SetMainColor(fEventManager->Color(P->GetPdgCode()));
+        fEveTrList->Add(fTrList);
+
+        gEve->AddElement(fTrList, fEventManager->EveRecoTracks);
+        fTrList->SetRnrLine(kTRUE);
+    }
+
+    return fTrList;
+}
+
+ClassImp(BmnTrackDrawP)
diff --git a/eventdisplay/bmn/BmnTrackDrawP.h b/eventdisplay/bmn/BmnTrackDrawP.h
new file mode 100644
index 0000000..a8183ea
--- /dev/null
+++ b/eventdisplay/bmn/BmnTrackDrawP.h
@@ -0,0 +1,72 @@
+// -------------------------------------------------------------------------
+// -----                     BmnTrackDrawP header file
+// -----                Created 02/12/15  by K. Gertsenberger
+// -----       class to draw BmnTrack* collection by Geane propagation
+// -------------------------------------------------------------------------
+
+
+#ifndef BMNTRACKDRAWP_H
+#define BMNTRACKDRAWP_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+#include "FairGeanePro.h"
+#include "TEveTrack.h"
+#include "FairTrajFilter.h"
+
+#include "TParticle.h"
+#include "TObjArray.h"
+
+class BmnTrackDrawP : public FairTask
+{
+  public:
+    /** Default constructor **/
+    BmnTrackDrawP();
+
+    /** Standard constructor
+    *@param name        Name of task and branch with BmnTrack* collection
+    *@param iVerbose    Verbosity level
+    **/
+    BmnTrackDrawP(const char* name, Int_t iVerbose = 1);
+
+    /** Destructor **/
+    virtual ~BmnTrackDrawP();
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t iVerbose);
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+
+    virtual InitStatus Init();
+    virtual void SetParContainers();
+    void Reset();
+    virtual void Finish();
+
+    // return pointer to EVE track list for given particle name. if list don't exist then create it
+    TEveTrackList* GetTrGroup(TParticle* P);
+
+    void InitGeant3();
+
+  protected:
+    FairEventManager* fEventManager;//!
+    TClonesArray*  fTrackList;      //!
+    TEveTrackList* fTrList;         //!
+
+    FairGeanePro* fPro;             //!
+    TEveTrackPropagator* fTrPr;     //!
+    TObjArray* fEveTrList;
+    FairTrajFilter* fTrajFilter;    //!
+
+    Float_t x1[3];
+    Float_t p1[3];
+    Float_t x2[3];
+    Float_t p2[3];
+
+    Double_t MinEnergyLimit;
+    Double_t MaxEnergyLimit;
+    Double_t PEnergy;
+
+    ClassDef(BmnTrackDrawP,1);
+};
+
+#endif
diff --git a/eventdisplay/bmn/EventBDLinkDef.h b/eventdisplay/bmn/EventBDLinkDef.h
new file mode 100644
index 0000000..d7ea5a0
--- /dev/null
+++ b/eventdisplay/bmn/EventBDLinkDef.h
@@ -0,0 +1,37 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairWebScreenshots;
+
+// BmnRoot
+#pragma link C++ class FairMCModuleDraw;
+#pragma link C++ class RawDataParser;
+#pragma link C++ class RawDataConverter;
+#pragma link C++ class RawMWPCDigitDraw;
+#pragma link C++ class EventData;
+#pragma link C++ class BmnDigitDraw;
+#pragma link C++ class BmnTrackDrawH;
+#pragma link C++ class BmnTrackDrawP;
+#pragma link C++ class BmnGlobalTrackDraw;
+
+// TDAQ
+//#pragma link C++ class BmnEventMonitor+;
+
+#endif
+
diff --git a/eventdisplay/bmn/EventBLinkDef.h b/eventdisplay/bmn/EventBLinkDef.h
new file mode 100644
index 0000000..98c3c0d
--- /dev/null
+++ b/eventdisplay/bmn/EventBLinkDef.h
@@ -0,0 +1,34 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairWebScreenshots;
+
+// BmnRoot
+#pragma link C++ class FairMCModuleDraw;
+#pragma link C++ class RawDataParser;
+#pragma link C++ class RawDataConverter;
+#pragma link C++ class RawMWPCDigitDraw;
+#pragma link C++ class EventData;
+#pragma link C++ class BmnDigitDraw;
+#pragma link C++ class BmnTrackDrawH;
+#pragma link C++ class BmnTrackDrawP;
+#pragma link C++ class BmnGlobalTrackDraw;
+
+#endif
+
diff --git a/eventdisplay/bmn/FairMCModuleDraw.cxx b/eventdisplay/bmn/FairMCModuleDraw.cxx
new file mode 100644
index 0000000..57ca85f
--- /dev/null
+++ b/eventdisplay/bmn/FairMCModuleDraw.cxx
@@ -0,0 +1,130 @@
+// -------------------------------------------------------------------------
+// -----                        FairMCModuleDraw source file           -----
+// -----                                                               -----
+// -------------------------------------------------------------------------
+#include "FairMCModuleDraw.h"
+#include "FairRootManager.h"
+#include "CbmPsdPoint.h"
+#include "CbmMCTrack.h"
+
+#include "TEvePointSet.h"
+#include "TString.h"
+
+#include <iostream>
+using namespace std;
+
+// -----   Default constructor   -------------------------------------------
+FairMCModuleDraw::FairMCModuleDraw()
+  : FairTask("FairMCModuleDraw", 0),
+    fVerbose(0),
+    fPointList(NULL),
+    fEventManager(NULL),
+    fColor(0),
+    fStyle(0)
+{
+}
+
+// -----   Standard constructor   ------------------------------------------
+FairMCModuleDraw::FairMCModuleDraw(const char* name, Color_t color ,Style_t mstyle,Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fVerbose(iVerbose),
+    fPointList(NULL),
+    fEventManager(NULL),
+    fColor(color),
+    fStyle(mstyle)
+{
+}
+
+// -------------------------------------------------------------------------
+InitStatus FairMCModuleDraw::Init()
+{
+  if (fVerbose > 1)
+      cout<<"FairMCModuleDraw::Init()"<<endl;
+
+  FairRootManager* fManager = FairRootManager::Instance();
+
+  fPointList = (TClonesArray*)fManager->GetObject(GetName());
+  if(fPointList == 0)
+  {
+    cout << "FairMCModuleDraw::Init()  branch " << GetName() << " Not found! Task will be deactivated "<< endl;
+    SetActive(kFALSE);
+  }
+  if (fVerbose > 2)
+      cout<<"FairMCModuleDraw::Init() get point list"<<fPointList<<endl;
+
+  fMCTracks = (TClonesArray*)fManager->GetObject("MCTrack");
+
+  fEventManager = FairEventManager::Instance();
+  if (fVerbose > 2)
+      cout<< "FairMCModuleDraw::Init() get instance of FairEventManager " << endl;
+
+  // create array for ZDC modules' visibility
+  fEventManager->isZDCModule = new bool[104];
+
+  return kSUCCESS;
+}
+
+void FairMCModuleDraw::Exec(Option_t* option)
+{
+  if (IsActive())
+  {
+    Reset();
+
+    bool* pZDCModuleNumber = fEventManager->isZDCModule;
+    Int_t npoints = fPointList->GetEntriesFast();
+    for (int i = 0; i < npoints; i++)
+    {
+        CbmPsdPoint* p = (CbmPsdPoint*) fPointList->At(i);
+
+        CbmMCTrack* pMCTrack = (CbmMCTrack*) fMCTracks->At(p->GetTrackID());
+        if (!pMCTrack)
+        {
+            cout<<"MCTrack is NULL for selected index"<<endl;
+            continue;
+        }
+
+        // filter only forward points
+        Double32_t start_z = pMCTrack->GetStartZ();
+        //cout<<"StartZ: "<<start_z<<cout<<endl;
+        if (start_z < 1000.0)
+            pZDCModuleNumber[p->GetModuleID()] = true;
+    }
+  }
+}
+
+TVector3 FairMCModuleDraw::GetVector(TObject* obj)
+{
+  FairMCPoint* p = (FairMCPoint*)obj;
+  return TVector3(p->GetX(), p->GetY(), p->GetZ());
+}
+
+TObject* FairMCModuleDraw::GetValue(TObject* obj,Int_t i)
+{
+  return new TNamed(Form("Point %d", i),"");
+}
+
+// -----   Destructor   ----------------------------------------------------
+FairMCModuleDraw::~FairMCModuleDraw()
+{
+    delete[] fEventManager->isZDCModule;
+}
+
+// -------------------------------------------------------------------------
+void FairMCModuleDraw::SetParContainers()
+{
+}
+
+/** Action after each event**/
+void FairMCModuleDraw::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void FairMCModuleDraw::Reset()
+{
+    bool* pZDCModuleNumber = fEventManager->isZDCModule;
+    for (int i = 0; i < 104; i++)
+        pZDCModuleNumber[i] = false;
+}
+
+ClassImp(FairMCModuleDraw);
diff --git a/eventdisplay/bmn/FairMCModuleDraw.h b/eventdisplay/bmn/FairMCModuleDraw.h
new file mode 100644
index 0000000..747d86d
--- /dev/null
+++ b/eventdisplay/bmn/FairMCModuleDraw.h
@@ -0,0 +1,61 @@
+// -------------------------------------------------------------------------
+// -----                      FairMCModuleDraw header file             -----
+// -----                                                               -----
+// -------------------------------------------------------------------------
+
+#ifndef FAIRMCMODULEDRAW_H
+#define FAIRMCMODULEDRAW_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+
+#include "TClonesArray.h"
+#include "TObject.h"
+#include "TVector3.h"
+
+class FairMCModuleDraw : public FairTask
+{
+  public:
+    /** Default constructor **/
+    FairMCModuleDraw();
+
+    /** Standard constructor
+    *@param name        Name of task
+    *@param iVerbose    Verbosity level
+    **/
+    FairMCModuleDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1);
+
+    /** Destructor **/
+    virtual ~FairMCModuleDraw();
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t iVerbose) { fVerbose = iVerbose; }
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+    void Reset();
+
+protected:
+    virtual TVector3 GetVector(TObject* obj);
+    virtual TObject* GetValue(TObject* obj,Int_t i);
+    virtual void SetParContainers();
+    virtual InitStatus Init();
+    /** Action after each event**/
+    virtual void Finish();
+
+    // Verbosity level
+    Int_t   fVerbose;
+    FairEventManager* fEventManager; //!
+    TClonesArray* fPointList; //!
+    TClonesArray* fMCTracks; //!
+
+    Color_t fColor; //!
+    Style_t fStyle; //!
+
+  private:
+    FairMCModuleDraw(const FairMCModuleDraw&);
+    FairMCModuleDraw& operator=(const FairMCModuleDraw&);
+
+    ClassDef(FairMCModuleDraw,1);
+};
+
+#endif
diff --git a/eventdisplay/coloring.xsd b/eventdisplay/coloring.xsd
new file mode 100644
index 0000000..a76b830
--- /dev/null
+++ b/eventdisplay/coloring.xsd
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+  <xs:element name="subdetector">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:string">
+          <xs:attribute type="xs:string" name="name" use="optional"/>
+          <xs:attribute type="xs:string" name="color" use="optional"/>
+          <xs:attribute type="xs:byte" name="transparency" use="optional"/>
+          <xs:attribute type="xs:string" name="isRecursiveColoring" use="optional"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="coloring">
+    <xs:annotation>
+      <xs:documentation>// COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+      </xs:documentation>
+    </xs:annotation>
+    <xs:complexType mixed="true">
+      <xs:sequence>
+        <xs:element ref="subdetector" maxOccurs="unbounded" minOccurs="0"/>
+        <xs:element ref="level" maxOccurs="unbounded" minOccurs="0"/>
+      </xs:sequence>
+      <xs:attribute type="xs:string" name="type" use="optional"/>
+    </xs:complexType>
+  </xs:element>
+  <xs:element name="level">
+    <xs:complexType>
+      <xs:simpleContent>
+        <xs:extension base="xs:string">
+          <xs:attribute type="xs:byte" name="number" use="optional"/>
+          <xs:attribute type="xs:string" name="color" use="optional"/>
+          <xs:attribute type="xs:string" name="isFillLine" use="optional"/>
+          <xs:attribute type="xs:string" name="visibility" use="optional"/>
+          <xs:attribute type="xs:byte" name="transparency" use="optional"/>
+        </xs:extension>
+      </xs:simpleContent>
+    </xs:complexType>
+  </xs:element>
+</xs:schema>
\ No newline at end of file
diff --git a/eventdisplay/mpd/EventMDLinkDef.h b/eventdisplay/mpd/EventMDLinkDef.h
new file mode 100644
index 0000000..49ece4e
--- /dev/null
+++ b/eventdisplay/mpd/EventMDLinkDef.h
@@ -0,0 +1,31 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairWebScreenshots;
+
+// MpdRoot
+#pragma link C++ class MpdGlobalTrackDraw;
+#pragma link C++ class MpdEmcTowerDraw;
+#pragma link C++ class MpdZdcTowerDraw;
+
+// TDAQ
+//#pragma link C++ class BmnEventMonitor+;
+
+#endif
+
diff --git a/eventdisplay/mpd/EventMLinkDef.h b/eventdisplay/mpd/EventMLinkDef.h
new file mode 100644
index 0000000..5d6eb4e
--- /dev/null
+++ b/eventdisplay/mpd/EventMLinkDef.h
@@ -0,0 +1,28 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairWebScreenshots;
+
+// MpdRoot
+#pragma link C++ class MpdGlobalTrackDraw;
+#pragma link C++ class MpdEmcTowerDraw;
+#pragma link C++ class MpdZdcTowerDraw;
+
+#endif
+
diff --git a/eventdisplay/mpd/MpdEmcTowerDraw.cxx b/eventdisplay/mpd/MpdEmcTowerDraw.cxx
new file mode 100644
index 0000000..d6e305a
--- /dev/null
+++ b/eventdisplay/mpd/MpdEmcTowerDraw.cxx
@@ -0,0 +1,511 @@
+// -------------------------------------------------------------------------
+// -----                        EmcTowerDraw source file               -----
+// -------------------------------------------------------------------------
+
+//#define DEBUG_EMC_TOWERS
+#include "MpdEmcTowerDraw.h"
+#include "TEveManager.h"                // for TEveManager, gEve
+#include "TEvePointSet.h"               // for TEvePointSet
+#include "TEveTreeTools.h"              // for TEvePointSelectorConsumer, etc
+#include "TGeoManager.h"
+#include "MpdEmcGeoPar.h"
+#include "MpdEmcDigit.h"
+#include "FairEventManagerEditor.h"
+
+#include "FairRunSim.h"
+#include "MpdEmc.h"
+
+#include <TGeoArb8.h>
+#include <TGeoTube.h>
+#include <TMath.h>
+#include <TROOT.h>
+#include <TStopwatch.h>
+
+#include <assert.h>
+#include <iostream>
+using namespace std;
+using namespace TMath;
+
+// -----   Default constructor   -------------------------------------------
+MpdEmcTowerDraw::MpdEmcTowerDraw()
+  : FairTask("MpdEmcTowerDraw", 0),
+    fEmcMinEnergyThreshold(0),
+    fVerboselvl(0),
+    fDigitList(NULL),
+    fEventManager(NULL),
+    fResetRequiredFlag(kFALSE),
+    fRMinEmc(0),
+    fRMaxEmc(0),
+    fBoxHeight(0),
+    fSector1StartAngle(0),
+    fNBoxes(0),
+    fNTubes(0),
+    fNSectors(0),
+    fN3Dbins(0),
+    fEneArr(NULL),
+    fGeoPar(new MpdEmcGeoPar),
+    fq(NULL)
+{
+}
+
+// -----   Standard constructor   ------------------------------------------
+MpdEmcTowerDraw::MpdEmcTowerDraw(const char* name, Double_t emcMinEnergyThreshold, Int_t verbose)
+  : FairTask(name, verbose),
+    fEmcMinEnergyThreshold(emcMinEnergyThreshold),
+    fVerboselvl(verbose),
+    fDigitList(NULL),
+    fEventManager(NULL),
+    fResetRequiredFlag(kFALSE),
+    fRMinEmc(0),
+    fRMaxEmc(0),
+    fBoxHeight(0),
+    fSector1StartAngle(0),
+    fNBoxes(0),
+    fNTubes(0),
+    fNSectors(0),
+    fN3Dbins(0),
+    fEneArr(NULL),
+    fGeoPar(new MpdEmcGeoPar),
+    fq(NULL)
+{
+}
+
+// -------------------------------------------------------------------------
+InitStatus MpdEmcTowerDraw::Init()
+{
+    if (GetVerboselvl() > 1)
+        cout<<"MpdEmcTowerDraw::Init()"<<endl;    
+
+    fEventManager = FairEventManager::Instance();
+    fEventManager->fgRedrawRecoPointsReqired=kTRUE;
+    if (GetVerboselvl() > 1)
+        cout<<"MpdEmcTowerDraw::Init() get instance of EventManager: "<<fEventManager<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+    if (GetVerboselvl() > 1)
+        cout<<"MpdEmcTowerDraw::Init() get instance of FairRootManager: "<<fManager<<endl;    
+
+    fDigitList = (TClonesArray*)fManager->GetObject("EmcDigit");
+    if(fDigitList == 0)
+    {
+        cout << "MpdEmcTowerDraw::Init()  branch EmcDigit Not found! Task will be deactivated "<< endl;
+        SetActive(kFALSE);
+    }
+     
+    SetRMinEmc(GetEmcGeoPar()->GetRmin() * 0.1);
+    SetRMaxEmc(GetEmcGeoPar()->GetRmax() * 0.1);    
+    SetNBoxes(GetEmcGeoPar()->GetNModInSuperModByZ()*GetEmcGeoPar()->GetNModInSuperModByPhi());
+    SetNTubes(GetEmcGeoPar()->GetNsupMod()*GetEmcGeoPar()->GetNrows());
+    SetNSectors(GetEmcGeoPar()->GetNsec());    
+    SetNRowsByPhi(GetEmcGeoPar()->GetNsupMod());//4
+    SetNRowsByZ(GetEmcGeoPar()->GetNrows());//23
+    SetLenSuperModule(GetEmcGeoPar()->GetLengthOfSuperModuleByZ());//12(cm)   
+    SetLenSector(GetEmcGeoPar()->GetLength());//276(cm)
+    SetNRowInSuperModByPhi(GetEmcGeoPar()->GetNModInSuperModByPhi());//3
+    SetNRowInSuperModByZ(GetEmcGeoPar()->GetNModInSuperModByZ());//3
+    SetNMiddleBoxesInSuperMod((GetNRowInSuperModByPhi()-2)*GetNRowInSuperModByZ());//3
+    //values of PHI1 and PHI2 are taken from emc_tr_400_3.geo:
+    SetSector1StartAngle(83.5714285714*DegToRad());
+    SetSector1EndAngle(96.4285714286*DegToRad());
+    SetBoxHeight(FindBoxesHeights());
+    SetN3Dbins(2*GetNSectors()*GetNTubes()*GetNBoxes());//2*28*4*23*3*3
+
+    if (GetVerboselvl() > 1)
+        cout<<"MpdEmcTowerDraw::Init() number of 3d bins = "<<GetN3Dbins()<<endl;
+    //cout<<"GetName()"<<GetName()<<endl;
+    fEneArr = new Double_t[GetN3Dbins()];
+    for (Int_t i = 0; i < GetN3Dbins(); ++i)
+        SetEneArr(i,0);
+    
+    fq = 0;
+    
+    return kSUCCESS;
+}
+
+void MpdEmcTowerDraw::Exec(Option_t* option)
+{   
+    if (IsActive())
+    {   
+        Reset();
+        if (GetVerboselvl() > 1)
+            cout<<"MpdEmcTowerDraw::Exec() current visibility level = "<<gGeoManager->GetVisLevel()<<endl;             
+        if (fEventManager->fgShowRecoPointsIsShow)
+        {
+            if (gGeoManager->GetVisLevel()==6)
+            {
+                //only if the boxes are visible     
+                FillEnergyLossArray();
+                //cut off energies under threshold
+                if (GetEmcMinEnergyThreshold()!=0)
+                    for (UInt_t i = 0; i < GetN3Dbins(); ++i) {           
+                        if (GetEneArrValue(i) < GetEmcMinEnergyThreshold()) SetEneArr(i,0);            
+                    }
+                //search for maximum bin
+                for (UInt_t i = 0; i < GetN3Dbins(); ++i) { 
+                    Double_t E = GetEneArrValue(i);                 
+                    if (E > GetMaxE()) SetMaxE(E);
+                }
+
+                if (GetVerboselvl() > 1)
+                    cout << "MpdEmcTowerDraw::Exec() maxE = " << GetMaxE() << endl;
+
+                DrawBoxTowers();   
+                gGeoManager->cd("/cave_1/emc1EmptyChamber1_1"); 
+                TGeoNode *chamberNode = gGeoManager->GetCurrentNode();
+                chamberNode->GetVolume()->SetTransparency(60);
+                //gGeoManager->cd("/cave_1/emc1EmptyChamber2_1"); 
+                //chamberNode = gGeoManager->GetCurrentNode();
+                //chamberNode->GetVolume()->SetTransparency(60);
+                //FairDetector *Emc1= new MpdEmc("EMC1", kTRUE);
+                //Emc1->SetGeometryFileName("emc_tr_400_3.geo");
+                //((TEveElement*)Emc1)->SetRnrState(kFALSE);
+                //FairRunSim::Instance()->AddModule(Emc1);
+                //gEve->AddGlobalElement(gsre);
+
+                //TEveElement* Emc1Elem = gsre->FindChild("EMC1");
+                //elTRD->SetRnrState(kFALSE);
+                SetResetRequiredFlag(kTRUE);
+            }
+        }
+        else
+        {
+            if (GetResetRequiredFlag())
+            {
+                ResetBoxTowers();
+                SetResetRequiredFlag(kFALSE);
+            }
+        }
+        TEvePointSet* q = new TEvePointSet(GetName(), fDigitList->GetEntriesFast(), TEvePointSelectorConsumer::kTVT_XYZ);
+        q->SetOwnIds(kTRUE);
+        
+        if (fEventManager->EveRecoPoints == NULL)
+        {
+            fEventManager->EveRecoPoints = new TEveElementList("Reco points");
+            gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
+            fEventManager->EveRecoPoints->SetRnrState(kFALSE);
+        }
+        
+        gEve->AddElement(q, fEventManager->EveRecoPoints);
+        
+        gEve->FullRedraw3D();
+        fq = q;
+    }
+}
+
+void MpdEmcTowerDraw::FillEnergyLossArray()
+{ 
+    TStopwatch timer;
+    timer.Start();
+    //calculate energy loss for each bin
+    UInt_t fNhits = fDigitList->GetEntriesFast();
+    if (GetVerboselvl() > 1)
+        cout<<"MpdEmcTowerDraw::FillEnergyLossArray() Number of EMC hits = " << fNhits << endl;            
+    for (UInt_t iPnt = 0; iPnt < fNhits; ++iPnt) {
+        UInt_t iCur;
+        MpdEmcDigit* dgt = (MpdEmcDigit*) fDigitList->At(iPnt);
+        //dgt->Print();              
+        TString binPath = FindBoxPathZPhi(dgt->GetZcenter(),dgt->GetPhiCenter());
+#ifdef DEBUG_EMC_TOWERS  
+        cout<<"w/o  geo:"<<binPath<<endl;            
+        TString binPathGeo = FindBoxPathZPhiWithGeoManager((GetRMaxEmc() + GetRMinEmc())/2.0, dgt->GetZcenter(),dgt->GetPhiCenter());
+        cout<<"with geo:"<<binPathGeo<<endl;
+        cout<<endl;
+        assert(binPath == binPathGeo);
+#endif              
+        iCur = FindN3DbinBoxId(binPath);                
+            
+        if ((iCur>=0) && (iCur<GetN3Dbins()))               
+            SetEneArr(iCur,GetEneArrValue(iCur)+dgt->GetE());
+        else
+            cout<<"MpdEmcTowerDraw::FillEnergyLossArray() wrong path = "<<binPath<< "; at Zcenter = "<<dgt->GetZcenter()<<" and PhiCenter = "<<dgt->GetPhiCenter()<<endl;        
+    }  
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "MpdEmcTowerDraw::FillEnergyLossArray() Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+}
+
+void MpdEmcTowerDraw::DrawBoxTowers()
+{    
+    TStopwatch timer;
+    timer.Start();
+    gGeoManager->cd("/cave_1/emc1Chamber1_1"); 
+    TGeoNode *chamberNode = gGeoManager->GetCurrentNode();
+    TObjArray *chHArr= chamberNode->GetVolume()->GetNodes();
+    TObjArray *boxArr;
+    TObjArray *moduleArr;
+    TObjArray *tubeArr;
+    TObjArray *sectorArr;  
+    for (UInt_t chH = 0; chH < 2; ++chH) {        
+        TGeoNode *chHNode = (TGeoNode*)(chHArr->UncheckedAt(chH));         
+        sectorArr = chHNode->GetVolume()->GetNodes();  
+        TGeoVolume *chHVolumeClone = chHNode->GetVolume()->CloneVolume();
+        for (UInt_t sector = 0; sector < chHNode->GetVolume()->GetNdaughters(); ++sector) {    
+            TGeoNode *sectorNode = (TGeoNode*)(sectorArr->UncheckedAt(sector)); 
+            tubeArr = sectorNode->GetVolume()->GetNodes();     
+            TGeoVolume *sectorVolumeClone = sectorNode->GetVolume()->CloneVolume();
+            for (UInt_t tube = 0; tube < sectorNode->GetVolume()->GetNdaughters(); ++tube) {
+                TGeoNode *tubeNode = (TGeoNode*)(tubeArr->UncheckedAt(tube));
+                if(((TString)tubeNode->GetName()).Contains("St_")) 
+                {
+                    tubeNode->SetVisibility(kFALSE);
+                    continue; //ignore emc1TubeSt_i
+                }
+                moduleArr = tubeNode->GetVolume()->GetNodes();  
+                TGeoVolume *tubeVolumeClone = tubeNode->GetVolume()->CloneVolume();                
+                for (UInt_t module = 0; module < tubeNode->GetVolume()->GetNdaughters(); ++module) {
+                    TGeoNode* moduleNode = (TGeoNode*)(moduleArr->UncheckedAt(module));                    
+                    if(((TString)moduleNode->GetName()).Contains("Pad_")) 
+                    {
+                        moduleNode->SetVisibility(kFALSE);
+                        continue; //ignore emc1ModulePad_i
+                    }
+                    boxArr = moduleNode->GetVolume()->GetNodes();           
+                    TGeoVolume *moduleVolumeClone = moduleNode->GetVolume()->CloneVolume();                    
+                    for (Int_t box = 0; box < moduleNode->GetVolume()->GetNdaughters(); ++box) {
+                        TGeoNode* boxNode = (TGeoNode*)(boxArr->UncheckedAt(box));
+                        TString curPath = Form("/cave_1/emc1Chamber1_1/%s/%s/%s/%s/%s",chHNode->GetName(),sectorNode->GetName(),tubeNode->GetName(),moduleNode->GetName(),boxNode->GetName());                        
+                        if (!gGeoManager->CheckPath(curPath))
+                        {
+                            cout<<"MpdEmcTowerDraw: wrong path: "<<curPath;
+                            continue;
+                        }
+                        UInt_t id = FindN3DbinBoxId(curPath);                        
+                        TGeoTrap *trap = (TGeoTrap*)boxNode->GetVolume()->GetShape()->Clone();        
+                        Double_t (&fXY)[8][2] = *reinterpret_cast<Double_t (*)[8][2]>(trap->GetVertices());                                               
+                        if (GetEneArrValue(id)!=0)
+                        {
+                            //we move only the points below the y=0 plane (outer side)
+                            Double_t h = -GetBoxHeight()/2*(2*GetEneArrValue(id)/GetMaxE()-1);
+                            trap->SetVertex(0, fXY[0][0], h);
+                            trap->SetVertex(3, fXY[3][0], h);
+                            trap->SetVertex(4, fXY[4][0], h);
+                            trap->SetVertex(7, fXY[7][0], h);
+                            //boxNode->GetMatrix()->Print();
+                            moduleVolumeClone->RemoveNode(boxNode);          
+                            TGeoVolume *boxVolumeCopy = boxNode->GetVolume()->MakeCopyVolume((TGeoShape*)trap);
+                            moduleVolumeClone->AddNode(boxVolumeCopy, boxNode->GetNumber(),boxNode->GetMatrix());
+                        }  
+                        else
+                            boxNode->SetVisibility(kFALSE);
+                    }
+                    tubeVolumeClone->RemoveNode(moduleNode);                    
+                    tubeVolumeClone->AddNode(moduleVolumeClone, moduleNode->GetNumber(),moduleNode->GetMatrix());  
+                }               
+                sectorVolumeClone->RemoveNode(tubeNode);                
+                sectorVolumeClone->AddNode(tubeVolumeClone,tubeNode->GetNumber() ,tubeNode->GetMatrix());
+            }            
+            chHVolumeClone->RemoveNode(sectorNode);            
+            chHVolumeClone->AddNode(sectorVolumeClone, sectorNode->GetNumber(),sectorNode->GetMatrix());     
+        }           
+        chamberNode->GetVolume()->AddNode(chHVolumeClone,chHNode->GetNumber(),chHNode->GetMatrix());  
+    }
+
+    TGeoNode* chHNode = (TGeoNode*)(chHArr->UncheckedAt(0));     
+    chamberNode->GetVolume()->RemoveNode(chHNode);
+    chHNode = (TGeoNode*)(chHArr->UncheckedAt(0)); 
+    chamberNode->GetVolume()->RemoveNode(chHNode);  
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "MpdEmcTowerDraw::DrawSectorTowers() Real time " << rtime << " s, CPU time " << ctime << " s" << endl;  
+    return;
+}
+
+void MpdEmcTowerDraw::ResetBoxTowers()
+{
+    TStopwatch timer;
+    timer.Start();    
+    gGeoManager->cd("/cave_1/emc1Chamber1_1"); 
+    TGeoNode *emc1ChamberNode = gGeoManager->GetCurrentNode();
+    TObjArray *chHArr= emc1ChamberNode->GetVolume()->GetNodes();
+    TObjArray *boxArr;
+    TObjArray *moduleArr;
+    TObjArray *tubeArr;
+    TObjArray *sectorArr;  
+    for (UInt_t chH = 0; chH < emc1ChamberNode->GetVolume()->GetNdaughters(); ++chH) {        
+        TGeoNode *chHNode = (TGeoNode*)(chHArr->UncheckedAt(chH));         
+        sectorArr = chHNode->GetVolume()->GetNodes();          
+        for (UInt_t sector = 0; sector < chHNode->GetVolume()->GetNdaughters(); ++sector) {    
+            TGeoNode *sectorNode = (TGeoNode*)(sectorArr->UncheckedAt(sector)); 
+            tubeArr = sectorNode->GetVolume()->GetNodes();                 
+            for (UInt_t tube = 0; tube < sectorNode->GetVolume()->GetNdaughters(); ++tube) {
+                TGeoNode *tubeNode = (TGeoNode*)(tubeArr->UncheckedAt(tube));
+                if(((TString)tubeNode->GetName()).Contains("St_")) 
+                {
+                    tubeNode->SetVisibility(kTRUE);
+                    continue; //ignore emc1TubeSt_i
+                }
+                moduleArr = tubeNode->GetVolume()->GetNodes();                                 
+                for (UInt_t module = 0; module < tubeNode->GetVolume()->GetNdaughters(); ++module) {
+                    TGeoNode* moduleNode = (TGeoNode*)(moduleArr->UncheckedAt(module));                    
+                    if(((TString)moduleNode->GetName()).Contains("Pad_")) 
+                    {
+                        moduleNode->SetVisibility(kTRUE);
+                        continue; //ignore emc1ModulePad_i
+                    }
+                    boxArr = moduleNode->GetVolume()->GetNodes();           
+                    for (Int_t box = 0; box < moduleNode->GetVolume()->GetNdaughters(); ++box) {
+                        TGeoNode* boxNode = (TGeoNode*)(boxArr->UncheckedAt(box));                                       
+                        TGeoTrap *trap = (TGeoTrap*)boxNode->GetVolume()->GetShape()->Clone();        
+                        Double_t (&fXY)[8][2] = *reinterpret_cast<Double_t (*)[8][2]>(trap->GetVertices());                                               
+                        //we move only the points below the y=0 plane (outer side)
+                        Double_t h = -GetBoxHeight()/2;
+                        trap->SetVertex(0, fXY[0][0], h);
+                        trap->SetVertex(3, fXY[3][0], h);
+                        trap->SetVertex(4, fXY[4][0], h);
+                        trap->SetVertex(7, fXY[7][0], h);
+                        //boxNode->GetMatrix()->Print();
+                        boxNode->GetVolume()->SetShape((TGeoShape*)trap);
+                        boxNode->SetVisibility(kTRUE);
+                    } 
+                }               
+            }               
+        }           
+    }
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "MpdEmcTowerDraw::ResetBoxTowers() Real time " << rtime << " s, CPU time " << ctime << " s" << endl;  
+    return;
+}
+
+Double_t MpdEmcTowerDraw::FindBoxesHeights()
+{
+    //get the initial height of the box to be able to reset later
+    gGeoManager->cd("/cave_1/emc1Chamber1_1/emc1ChH_1/emc1Sector_1/emc1Tube_1/emc1Module_1/emc1_box_1");
+    TGeoTrap *trap = (TGeoTrap*)gGeoManager->GetCurrentNode()->GetVolume()->GetShape();        
+    Double_t (&fXY)[8][2] = *reinterpret_cast<Double_t (*)[8][2]>(trap->GetVertices());          
+    //cout<<"Box Height = "<<-fXY[0][1]*2.0<<endl; 
+    return -fXY[0][1]*2.0;        
+}
+
+UInt_t MpdEmcTowerDraw::FindN3DbinBoxId(TString path)
+{
+    Int_t ip = path.Index("ChH");
+    UInt_t chHId = TString(path(ip+4,1)).Atoi();    
+    ip = path.Index("Sector");
+    Int_t ip1 = path.Index("/",ip);
+    UInt_t sectorId = TString(path(ip+7,ip1)).Atoi();    
+    ip = path.Index("Tube");
+    ip1 = path.Index("/",ip);
+    UInt_t tubeId = TString(path(ip+5,ip1)).Atoi();    
+    UInt_t boxId;
+    ip = path.Index("bt_box");
+    //for bt_ boxes (side boxes) we shift the id by the number of middle boxes (3)
+    if (ip!=-1)        
+        boxId= TString(path(ip+7)).Atoi()+GetNMiddleBoxesInSuperMod();
+    else
+    {
+        ip = path.Index("box");
+        boxId= TString(path(ip+4)).Atoi();
+    } 
+    return (GetNBoxes() * GetNTubes() * GetNSectors() * (chHId-1)) + (GetNBoxes() * GetNTubes() * (sectorId-1)) + (GetNBoxes() * (tubeId-1)) + (boxId-1);
+}
+
+TString MpdEmcTowerDraw::FindPathN3DbinBoxId(UInt_t id)
+{
+    UInt_t chHId = (id / (GetNBoxes() * GetNTubes() * GetNSectors()))+1;
+    id -= ((chHId-1) * GetNBoxes() * GetNTubes() * GetNSectors());
+    UInt_t sectorId  = id / (GetNBoxes() * GetNTubes())+1;
+    id -= ((sectorId-1) * GetNBoxes() * GetNTubes());
+    UInt_t tubeId = id / GetNBoxes() +1;
+    UInt_t boxId = id % GetNBoxes() +1;   
+    //for bt_ boxes (side boxes) we shift the id by the number of middle boxes (3)
+    if (boxId>GetNMiddleBoxesInSuperMod())
+        return Form("/cave_1/emc1Chamber1_1/emc1ChH_%d/emc1Sector_%d/emc1Tube_%d/emc1Module_1/emc1_bt_box_%d",chHId,sectorId,tubeId,boxId - GetNMiddleBoxesInSuperMod());
+    else
+        return Form("/cave_1/emc1Chamber1_1/emc1ChH_%d/emc1Sector_%d/emc1Tube_%d/emc1Module_1/emc1_box_%d",chHId,sectorId,tubeId,boxId);
+}
+
+TString MpdEmcTowerDraw::FindBoxPathZPhiWithGeoManager(Double_t r, Double_t z, Double_t phi)
+{
+    Double_t x = r*Cos(phi);
+    Double_t y = r*Sin(phi);    
+    gGeoManager->FindNode(x,y,z); 
+    TString path(gGeoManager->GetPath());    
+    if  (gGeoManager->cd(path))
+    {
+        gGeoManager->CdUp();
+        return gGeoManager->GetPath();
+    }
+    return "";
+}
+
+TString MpdEmcTowerDraw::FindBoxPathZPhi(Double_t z, Double_t phi)
+{
+    UInt_t chHId = (z>0)? 2:1;//current ChH id                
+    Double_t phiAbs; // current angle from starting angle PHI1 of the first sector (emc1Sector_1), radians 0 
+    // (clockwise in emc1ChH_1, counterclockwise in emc1ChH_2)
+    if (chHId==1)  
+        phiAbs = phi>GetSector1StartAngle()?(phi-GetSector1StartAngle()):(TwoPi()+(phi-GetSector1StartAngle()));
+    else        
+        phiAbs = phi>GetSector1EndAngle()?(TwoPi()-(phi-GetSector1EndAngle())):(GetSector1EndAngle()-phi);
+    
+    UInt_t sectorId = UInt_t(phiAbs/ TwoPi() * GetNSectors())+1;
+    //finding tube id
+    //phiT - current angle between PHI1 of the beginning of sector and Phi angle
+    Double_t phiT = phiAbs - TwoPi()*(sectorId-1)/GetNSectors();
+    ///  current id of the row by phi in sector
+    Double_t rowIdByPhi = UInt_t(GetNRowsByPhi()*GetNSectors() * phiT/(TwoPi()))+1;
+    UInt_t tubeId;
+    if (chHId==1)
+        tubeId = UInt_t((GetLenSector()-Abs(z))/GetLenSuperModule())+(rowIdByPhi-1)*GetNRowsByZ()+1;
+    else
+        tubeId = UInt_t(Abs(z)/GetLenSuperModule())+(rowIdByPhi-1)*GetNRowsByZ()+1;
+    
+    //finding box id
+    UInt_t boxId;
+    Double_t phiB = phiT - TwoPi()*(rowIdByPhi-1)/(GetNSectors()*GetNRowsByPhi());
+    UInt_t supModRowIdByPhi = UInt_t(GetNRowInSuperModByPhi()*GetNSectors()*GetNRowsByPhi()*phiB/(TwoPi()))+1;
+    UInt_t supModRowIdByZ;
+    Double_t tubeZ = (tubeId-UInt_t((tubeId-1)/GetNRowsByZ())*GetNRowsByZ()-1)*GetLenSuperModule();
+    if (chHId==1)
+        supModRowIdByZ = UInt_t((GetLenSector()-Abs(z)-tubeZ)/GetLenSuperModule()*GetNRowInSuperModByZ())+1;
+    else
+        supModRowIdByZ = UInt_t((Abs(z) - tubeZ)/GetLenSuperModule()*GetNRowInSuperModByZ())+1;
+    
+    if(supModRowIdByPhi==1)//bt_ box 1-3
+        boxId=supModRowIdByZ+GetNMiddleBoxesInSuperMod();
+    else 
+        if(supModRowIdByPhi==GetNRowInSuperModByPhi())//bt_box 4-6
+            boxId=supModRowIdByZ+GetNRowInSuperModByZ()+GetNMiddleBoxesInSuperMod();
+        else//middle boxes 1-3
+            boxId=UInt_t(GetNMiddleBoxesInSuperMod()/GetNRowInSuperModByZ())*(supModRowIdByPhi-2)+supModRowIdByZ;
+    //for bt_ boxes (side boxes) we shift the id by the number of middle boxes (3)
+    if (boxId>GetNMiddleBoxesInSuperMod())
+        return Form("/cave_1/emc1Chamber1_1/emc1ChH_%d/emc1Sector_%d/emc1Tube_%d/emc1Module_1/emc1_bt_box_%d",chHId,sectorId,tubeId,boxId - GetNMiddleBoxesInSuperMod());
+    else
+        return Form("/cave_1/emc1Chamber1_1/emc1ChH_%d/emc1Sector_%d/emc1Tube_%d/emc1Module_1/emc1_box_%d",chHId,sectorId,tubeId,boxId);
+}
+
+// -----   Destructor   ----------------------------------------------------
+MpdEmcTowerDraw::~MpdEmcTowerDraw()
+{
+    fDigitList->Delete();
+    delete fGeoPar;
+    delete fEneArr;
+}
+
+// -------------------------------------------------------------------------
+
+/** Action after each event**/
+void MpdEmcTowerDraw::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void MpdEmcTowerDraw::Reset()
+{     
+    if (fq != 0)
+    {           
+        fq->Reset();
+        gEve->RemoveElement(fq, fEventManager->EveRecoPoints);       
+        gROOT->Reset();
+    }    
+}
+
+ClassImp(MpdEmcTowerDraw);
diff --git a/eventdisplay/mpd/MpdEmcTowerDraw.h b/eventdisplay/mpd/MpdEmcTowerDraw.h
new file mode 100644
index 0000000..1555b4c
--- /dev/null
+++ b/eventdisplay/mpd/MpdEmcTowerDraw.h
@@ -0,0 +1,134 @@
+// -------------------------------------------------------------------------
+// -----                      EmcTowerDraw header file                 -----
+// -------------------------------------------------------------------------
+
+#ifndef EMCTOWERDRAW_H
+#define EMCTOWERDRAW_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+#include "TEvePointSet.h"               // for TEvePointSet
+#include "MpdEmcGeoPar.h"
+
+#include <TObject.h>
+#include <TString.h>
+#include <TClonesArray.h>
+#include <TMath.h>
+
+using namespace TMath;
+
+class MpdEmcTowerDraw : public FairTask
+{
+  public:
+    /** Default constructor **/
+    MpdEmcTowerDraw();
+
+    /** Standard constructor
+    *@param name        Name of task
+    *@param emcMinEnergyThreshold minimal energy threshold 
+    *@param verbose    Verbosity level   
+    **/
+    MpdEmcTowerDraw(const char* name, Double_t emcMinEnergyThreshold = 0, Int_t verbose = 1);
+
+    /** Destructor **/
+    virtual ~MpdEmcTowerDraw();
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(UInt_t verboselvl) { fVerboselvl = verboselvl; }
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+    void Reset();
+
+  protected:    
+    TClonesArray* fDigitList; //!
+    FairEventManager* fEventManager; //! 
+    TEvePointSet* fq;    //!
+    
+    virtual InitStatus Init();
+    virtual void Finish(); ///< Action after each event
+    TString FindBoxPathZPhiWithGeoManager(Double_t r, Double_t z, Double_t phi); ///< find path to box using Z and Phi with GeoManager
+    TString FindBoxPathZPhi(Double_t z, Double_t phi); ///< find path to box using Z and Phi without GeoManager       
+    UInt_t FindN3DbinBoxId(TString path); ///< find box id (in eneArr) corresponding to given path
+    TString FindPathN3DbinBoxId(UInt_t id); ///< find path corresponding to given box id (in eneArr)  
+    Double_t FindBoxesHeights(); ///<finds box height using GeoManager
+    void FillEnergyLossArray(); ///<fills the fEneArr with values from fDigitList without normalizing
+    void DrawBoxTowers(); ///< adjust box heights
+    void ResetBoxTowers(); ///< reset all box sizes if "reco points" checkbox is now unchecked
+    
+    /** Accessors **/
+    MpdEmcGeoPar* GetEmcGeoPar() { return fGeoPar; } ///< pointer to emc geo parameters
+    Double_t GetEmcMinEnergyThreshold() const { return fEmcMinEnergyThreshold; }
+    Bool_t GetResetRequiredFlag() const { return fResetRequiredFlag; }
+    UInt_t GetVerboselvl() const { return fVerboselvl; }
+    Double_t GetRMinEmc() const { return fRMinEmc; }
+    Double_t GetRMaxEmc() const { return fRMaxEmc; }
+    Double_t GetBoxHeight() const { return fBoxHeight; }
+    Double_t GetSector1StartAngle() const { return fSector1StartAngle; }
+    Double_t GetSector1EndAngle() const { return fSector1EndAngle; }
+    UInt_t GetNBoxes() const { return fNBoxes; }
+    UInt_t GetNTubes() const { return fNTubes; }
+    UInt_t GetNSectors() const { return fNSectors; }
+    UInt_t GetN3Dbins() const { return fN3Dbins; }
+    UInt_t GetNRowsByPhi() const { return fNRowsByPhi; }
+    UInt_t GetNRowsByZ() const { return fNRowsByZ; }
+    UInt_t GetNRowInSuperModByPhi() const { return fNRowInSuperModByPhi; }
+    UInt_t GetNRowInSuperModByZ() const { return fNRowInSuperModByZ; }
+    UInt_t GetNMiddleBoxesInSuperMod() const { return fNMiddleBoxesInSuperMod; }
+    Double_t GetLenSuperModule() const { return fLenSuperModule; }
+    Double_t GetLenSector() const { return fLenSector; }
+    Double_t GetEneArrValue(UInt_t i) const { return fEneArr[i]; }
+    Double_t GetMaxE() const { return fMaxE; }  
+    
+    /** Modifiers **/
+    void SetResetRequiredFlag(Bool_t resetRequiredFlag) { fResetRequiredFlag = resetRequiredFlag; }
+    void SetRMinEmc(Double_t rMinEmc) { fRMinEmc = rMinEmc; }
+    void SetRMaxEmc(Double_t rMaxEmc) { fRMaxEmc = rMaxEmc; }
+    void SetBoxHeight(Double_t boxHeight) { fBoxHeight = boxHeight; }
+    void SetSector1StartAngle(Double_t sector1StartAngle) { fSector1StartAngle = sector1StartAngle; }
+    void SetSector1EndAngle(Double_t sector1EndAngle) { fSector1EndAngle = sector1EndAngle; }    
+    void SetNBoxes(UInt_t nBoxes) { fNBoxes = nBoxes; }
+    void SetNTubes(UInt_t nTubes) { fNTubes = nTubes; }
+    void SetNSectors(UInt_t nSectors) { fNSectors = nSectors; }  
+    void SetN3Dbins(UInt_t n3Dbins) { fN3Dbins = n3Dbins; }
+    void SetNRowsByPhi(UInt_t nRowsByPhi) { fNRowsByPhi = nRowsByPhi; }
+    void SetNRowsByZ(UInt_t nRowsByZ)  { fNRowsByZ = nRowsByZ; }
+    void SetNRowInSuperModByPhi(UInt_t nRowInSuperModByPhi)  { fNRowInSuperModByPhi = nRowInSuperModByPhi; }
+    void SetNRowInSuperModByZ(UInt_t nRowInSuperModByZ)  { fNRowInSuperModByZ = nRowInSuperModByZ; }
+    void SetNMiddleBoxesInSuperMod(UInt_t nMiddleBoxesInSuperMod)  { fNMiddleBoxesInSuperMod = nMiddleBoxesInSuperMod; }
+    void SetLenSuperModule(Double_t lenSuperModule){ fLenSuperModule = lenSuperModule; }
+    void SetLenSector(Double_t lenSector){ fLenSector = lenSector; }
+    void SetEneArr(UInt_t i, Double_t val) { fEneArr[i] = val; } ///< set energy loss array value
+    void SetMaxE(Double_t maxE) { fMaxE = maxE; }
+
+  private:   
+    Double_t fEmcMinEnergyThreshold;///< min energy threshold
+    Int_t fVerboselvl; ///< Verbosity level    
+    Bool_t fResetRequiredFlag; ///< flag true is box sizes are adjusted
+    Double_t fRMinEmc; ///< Inner radius, cm
+    Double_t fRMaxEmc; ///< Outer radius -> module + front plastic and end plastic, cm
+    Double_t fBoxHeight; ///< height of box or bt_box, cm
+    Double_t fSector1StartAngle; ///< starting angle PHI1 of the first sector (emc1Sector_1), radians
+    Double_t fSector1EndAngle; ///< ending angle PHI2 of the first sector (emc1Sector_1), radians
+    UInt_t fNBoxes; ///< number of boxes (box + bt_box) in emc1Module (supermodule)    
+    UInt_t fNTubes; ///< number of tubes in emcSector    
+    UInt_t fNSectors; ///< number of sectors in emcChH
+    UInt_t fN3Dbins; ///< total number of bins (depends on visibility level)
+    UInt_t fNRowsByPhi; ///< number of emc1Module (supermodules) rows in sector by phi
+    UInt_t fNRowsByZ; ///< number of emc1Module (supermodules) rows in sector along z axis
+    UInt_t fNRowInSuperModByPhi; ///< number of box rows in emc1Module (supermodules) in sector by phi
+    UInt_t fNRowInSuperModByZ; ///< number of box rows in emc1Module (supermodules) in sector along z axis
+    UInt_t fNMiddleBoxesInSuperMod; ///< number of middle boxes (not bt_) in emc1Module
+    Double_t fLenSuperModule; ///<length of emc1Module (supermodule) along z or x axis, cm
+    Double_t fLenSector; ///<length of emc1Sector along z axis, cm
+    Double_t* fEneArr; //!< array of energies in each box of EMC
+    ///< boxes array id: (9 * 92 * 28 * (chHId-1)) + (9 * 92 * (sectorId-1)) + (9 * (tubeId-1)) + (boxId-1)
+    Double_t fMaxE; ///< energy loss at the bin with maximum energy loss
+    
+    MpdEmcGeoPar* fGeoPar; ///< pointer to emc geo parameters
+    
+    MpdEmcTowerDraw(const MpdEmcTowerDraw&);
+    MpdEmcTowerDraw& operator=(const MpdEmcTowerDraw&);
+
+    ClassDef(MpdEmcTowerDraw,1);
+};
+
+#endif
diff --git a/eventdisplay/MpdTrackDraw.cxx b/eventdisplay/mpd/MpdGlobalTrackDraw.cxx
similarity index 86%
rename from eventdisplay/MpdTrackDraw.cxx
rename to eventdisplay/mpd/MpdGlobalTrackDraw.cxx
index f7e3926..a89ac77 100644
--- a/eventdisplay/MpdTrackDraw.cxx
+++ b/eventdisplay/mpd/MpdGlobalTrackDraw.cxx
@@ -1,10 +1,10 @@
 // -------------------------------------------------------------------------
-// -----                  MpdTrackDraw source file                     -----
+// -----                  MpdGlobalTrackDraw source file                     -----
 // -----            created 10/12/13 by K. Gertsenberger               -----
 // ----- class to visualize reconstructed GlobalTracks in EventDisplay -----
 // -------------------------------------------------------------------------
 
-#include "MpdTrackDraw.h"
+#include "MpdGlobalTrackDraw.h"
 #include "MpdTrack.h"
 #include "MpdTpcHit.h"
 #include "MpdEvent.h"
@@ -20,8 +20,8 @@ using namespace std;
 
 
 // default constructor
-MpdTrackDraw::MpdTrackDraw()
-  : FairTask("MpdTrackDraw", 0),
+MpdGlobalTrackDraw::MpdGlobalTrackDraw()
+  : FairTask("MpdGlobalTrackDraw", 0),
     fTrackList(NULL),
     fTrPr(NULL),
     fEventManager(NULL),
@@ -35,7 +35,7 @@ MpdTrackDraw::MpdTrackDraw()
 }
 
 // standard constructor
-MpdTrackDraw::MpdTrackDraw(const char* name, Int_t iVerbose)
+MpdGlobalTrackDraw::MpdGlobalTrackDraw(const char* name, Int_t iVerbose)
   : FairTask(name, iVerbose),
     fTrackList(NULL),
     fTrPr(NULL),
@@ -50,10 +50,10 @@ MpdTrackDraw::MpdTrackDraw(const char* name, Int_t iVerbose)
 }
 
 // initialization of the track drawing task
-InitStatus MpdTrackDraw::Init()
+InitStatus MpdGlobalTrackDraw::Init()
 {
     if (fVerbose > 1)
-        cout<<"MpdTrackDraw::Init()"<<endl;
+        cout<<"MpdGlobalTrackDraw::Init()"<<endl;
 
     FairRootManager* fManager = FairRootManager::Instance();
 
@@ -62,20 +62,30 @@ InitStatus MpdTrackDraw::Init()
     fTrackList = fDstEvent->GetGlobalTracks();
     if (fTrackList == 0)
     {
-        cout<<"MpdTrackDraw::Init()  branch "<<GetName()<<" not found! Task will be deactivated"<<endl;
+        cout<<"MpdGlobalTrackDraw::Init() branch "<<GetName()<<" not found! Task will be deactivated"<<endl;
         SetActive(kFALSE);
     }
     fKalmanTrackList = (TClonesArray*)fManager->GetObject("TpcKalmanTrack");
+    if (fKalmanTrackList == 0)
+    {
+        cout<<"MpdGlobalTrackDraw::Init() branch TpcKalmanTrack not found! Task will be deactivated"<<endl;
+        SetActive(kFALSE);
+    }
     fTpcHitList = (TClonesArray*)fManager->GetObject("TpcHit");
+    if (fTpcHitList == 0)
+    {
+        cout<<"MpdGlobalTrackDraw::Init() branch TpcHit not found! Task will be deactivated"<<endl;
+        SetActive(kFALSE);
+    }
 
     if(fVerbose > 2)
-        cout<<"MpdTrackDraw::Init() get track list "<<fTrackList<<endl;
+        cout<<"MpdGlobalTrackDraw::Init() get track list "<<fTrackList<<endl;
     if(fVerbose > 2)
-        cout<<"MpdTrackDraw::Init() create propagator"<<endl;
+        cout<<"MpdGlobalTrackDraw::Init() create propagator"<<endl;
 
     fEventManager = FairEventManager::Instance();
     if(fVerbose > 2)
-        cout<<"MpdTrackDraw::Init() get instance of FairEventManager "<<endl;
+        cout<<"MpdGlobalTrackDraw::Init() get instance of FairEventManager "<<endl;
 
     fEvent = "Current Event";
     MinEnergyLimit = fEventManager->GetEvtMinEnergy();
@@ -88,11 +98,11 @@ InitStatus MpdTrackDraw::Init()
         return kERROR;
 }
 // -------------------------------------------------------------------------
-void MpdTrackDraw::Exec(Option_t* option)
+void MpdGlobalTrackDraw::Exec(Option_t* option)
 {
     if (!IsActive()) return;
     if (fVerbose > 1)
-        cout<<" MpdTrackDraw::Exec "<<endl;
+        cout<<" MpdGlobalTrackDraw::Exec "<<endl;
 
     Reset();
 
@@ -223,19 +233,19 @@ void MpdTrackDraw::Exec(Option_t* option)
 }
 
 // destructor
-MpdTrackDraw::~MpdTrackDraw()
+MpdGlobalTrackDraw::~MpdGlobalTrackDraw()
 {
 }
 
-void MpdTrackDraw::SetParContainers()
+void MpdGlobalTrackDraw::SetParContainers()
 {
 }
 
-void MpdTrackDraw::Finish()
+void MpdGlobalTrackDraw::Finish()
 {
 }
 
-void MpdTrackDraw::Reset()
+void MpdGlobalTrackDraw::Reset()
 {
     // clear EVE track lists (fEveTrList)
     for (Int_t i = 0; i < fEveTrList->GetEntriesFast(); i++)
@@ -248,7 +258,7 @@ void MpdTrackDraw::Reset()
 }
 
 // return pointer to EVE track list for given particle name. if list don't exist then create it
-TEveTrackList* MpdTrackDraw::GetTrGroup(TParticle* P)
+TEveTrackList* MpdGlobalTrackDraw::GetTrGroup(TParticle* P)
 {
     fTrList = 0;
 
@@ -285,4 +295,4 @@ TEveTrackList* MpdTrackDraw::GetTrGroup(TParticle* P)
     return fTrList;
 }
 
-ClassImp(MpdTrackDraw)
+ClassImp(MpdGlobalTrackDraw)
diff --git a/eventdisplay/MpdTrackDraw.h b/eventdisplay/mpd/MpdGlobalTrackDraw.h
similarity index 79%
rename from eventdisplay/MpdTrackDraw.h
rename to eventdisplay/mpd/MpdGlobalTrackDraw.h
index 3787a60..d199e50 100644
--- a/eventdisplay/MpdTrackDraw.h
+++ b/eventdisplay/mpd/MpdGlobalTrackDraw.h
@@ -1,12 +1,12 @@
 // -------------------------------------------------------------------------
-// -----                    MpdTrackDraw header file                   -----
+// -----                    MpdGlobalTrackDraw header file                   -----
 // -----              created 10/12/13 by K. Gertsenberger             -----
 // ----- class to visualize reconstructed GlobalTracks in EventDisplay -----
 // -------------------------------------------------------------------------
 
 
-#ifndef MPDTRACKDRAW_H
-#define MPDTRACKDRAW_H
+#ifndef MPDGLOBALTRACKDRAW_H
+#define MPDGLOBALTRACKDRAW_H
 
 #include "FairTask.h"
 #include "FairEventManager.h"
@@ -19,17 +19,17 @@
 #include "TParticle.h"
 
 
-class MpdTrackDraw : public FairTask
+class MpdGlobalTrackDraw : public FairTask
 {
   public:
     // default constructor
-    MpdTrackDraw();
+    MpdGlobalTrackDraw();
 
     // constructor: @name - name of task, @iVerbose- verbosity level
-    MpdTrackDraw(const char* name, Int_t iVerbose = 1);
+    MpdGlobalTrackDraw(const char* name, Int_t iVerbose = 1);
 
     // destructor
-    virtual ~MpdTrackDraw();
+    virtual ~MpdGlobalTrackDraw();
 
     // set verbosity level for this task and all of the subtasks
     void SetVerbose(Int_t iVerbose) {fVerbose = iVerbose;}
@@ -65,9 +65,9 @@ class MpdTrackDraw : public FairTask
     Double_t PEnergy;
 
   private:
-    MpdTrackDraw(const MpdTrackDraw&);
-    MpdTrackDraw& operator=(const MpdTrackDraw&);
+    MpdGlobalTrackDraw(const MpdGlobalTrackDraw&);
+    MpdGlobalTrackDraw& operator=(const MpdGlobalTrackDraw&);
 
-    ClassDef(MpdTrackDraw,1);
+    ClassDef(MpdGlobalTrackDraw,1);
 };
 #endif
diff --git a/eventdisplay/mpd/MpdZdcTowerDraw.cxx b/eventdisplay/mpd/MpdZdcTowerDraw.cxx
new file mode 100644
index 0000000..7c43f57
--- /dev/null
+++ b/eventdisplay/mpd/MpdZdcTowerDraw.cxx
@@ -0,0 +1,349 @@
+// -------------------------------------------------------------------------
+// -----                        ZdcTowerDraw source file               -----
+// -------------------------------------------------------------------------
+
+//#define DEBUG_ZDC_TOWERS
+#include "MpdZdcTowerDraw.h"
+#include "TEveManager.h"                // for TEveManager, gEve
+#include "TEvePointSet.h"               // for TEvePointSet
+#include "TEveTreeTools.h"              // for TEvePointSelectorConsumer, etc
+#include "TGeoManager.h"
+#include "MpdZdcDigi.h"
+#include "MpdZdcDigiScheme.h"
+#include "FairEventManagerEditor.h"
+
+#include "TEveProjections.h"
+#include "TEveCaloData.h"
+#include "TEveCalo.h"
+#include "TEveBrowser.h"
+#include "TEveViewer.h"
+#include "TH2F.h"
+#include "TRandom.h"
+
+#include "TGeoBBox.h"
+
+#include <TMath.h>
+
+#include <assert.h>
+#include <iostream>
+using namespace std;
+using namespace TMath;
+
+// -----   Default constructor   -------------------------------------------
+MpdZdcTowerDraw::MpdZdcTowerDraw()
+  : FairTask("MpdZdcTowerDraw", 0),
+    fVerboselvl(0),
+    fShadow(kFALSE),
+    fResetRequiredFlag(kFALSE),
+    fDigitList(NULL),
+    fEventManager(NULL),
+    fEneArr(NULL),
+    fZdcMinEnergyThreshold(0),
+    fq(NULL)
+{
+}
+
+// -----   Standard constructor   ------------------------------------------
+MpdZdcTowerDraw::MpdZdcTowerDraw(const char* name, Double_t zdcMinEnergyThreshold, Bool_t shadow, Int_t verbose)
+  : FairTask(name, verbose),
+    fVerboselvl(verbose),
+    fShadow(shadow),
+    fResetRequiredFlag(kFALSE),
+    fDigitList(NULL),
+    fEventManager(NULL),
+    fZdcMinEnergyThreshold(zdcMinEnergyThreshold),
+    fq(NULL)
+{
+}
+
+// -------------------------------------------------------------------------
+InitStatus MpdZdcTowerDraw::Init()
+{
+    if (GetVerboselvl() > 1)
+        cout<<"MpdZdcTowerDraw::Init()"<<endl;    
+
+    fEventManager = FairEventManager::Instance();
+    fEventManager->fgRedrawRecoPointsReqired=kTRUE;
+    if (GetVerboselvl() > 1)
+        cout<<"MpdZdcTowerDraw::Init() get instance of EventManager: "<<fEventManager<<endl;
+
+    FairRootManager* fManager = FairRootManager::Instance();
+    if (GetVerboselvl() > 1)
+        cout<<"MpdZdcTowerDraw::Init() get instance of FairRootManager: "<<fManager<<endl;    
+
+    fDigitList = (TClonesArray*)fManager->GetObject("ZdcDigi");
+    if(fDigitList == 0)
+    {
+        cout << "MpdZdcTowerDraw::Init()  branch ZdcDigit Not found! Task will be deactivated "<< endl;
+        SetActive(kFALSE);
+    }
+    
+    SetNumModules(96);
+    SetModuleZLen(40);
+    
+    fEneArr = new Double_t[GetNumModules()*2];
+    for (Int_t i = 0; i < GetNumModules()*2; ++i)
+        SetEneArr(i,0);
+    
+    
+    fq = 0;
+    
+    return kSUCCESS;
+}
+
+void MpdZdcTowerDraw::Exec(Option_t* option)
+{   
+    if (IsActive())
+    {   
+        Reset();
+        if (GetVerboselvl() > 1)
+            cout<<"MpdZdcTowerDraw::Exec() current visibility level = "<<gGeoManager->GetVisLevel()<<endl;             
+        if (fEventManager->fgShowRecoPointsIsShow)
+        {
+            UInt_t fNhits = fDigitList->GetEntriesFast();
+            if (GetVerboselvl() > 1)
+                cout<<"MpdZdcTowerDraw::Exec() Number of ZDC hits = " << fNhits << endl;  
+            for (Int_t i = 0; i < GetNumModules()*2; ++i)
+                    SetEneArr(i,0);
+            for (UInt_t iPnt = 0; iPnt < fNhits; ++iPnt) {
+                UInt_t iCur;
+                MpdZdcDigi* dgt = (MpdZdcDigi*) fDigitList->At(iPnt);
+                //dgt->Print();
+                //cout<<"GetELoss() = "<<dgt->GetELoss()<<endl;
+
+                //cout<<"GetDetectorID() = "<<dgt->GetDetectorID()<<endl;
+                //cout<<"GetModuleID() = "<<dgt->GetModuleID()<<endl;                
+                iCur =GetNumModules()*(dgt->GetDetectorID()-1)+dgt->GetModuleID()-1;
+                //cout<<"iCur = " <<iCur<<endl;
+                SetEneArr(iCur,GetEneArrValue(iCur)+dgt->GetELoss());
+            }
+            
+            //cut off energies under threshold
+            //if (GetZdcMinEnergyThreshold()!=0)
+            //    for (UInt_t i = 0; i < GetNumModules()*2; ++i) {           
+            //        if (GetEneArrValue(i) < GetZdcMinEnergyThreshold()) SetEneArr(i,0);            
+            //}
+            
+            //search for maximum bin
+            SetMaxE(0);
+            for (UInt_t i = 0; i < 2*GetNumModules(); ++i) { 
+                Double_t E = GetEneArrValue(i); 
+                //cout<<"E = "<<E<<endl;
+                if (E > GetMaxE()) SetMaxE(E);
+            }
+
+            if (GetVerboselvl() > 1)
+                cout << "MpdZdcTowerDraw::Exec() maxE = " << GetMaxE() << endl;
+                        
+            DrawTowers();
+            
+            //gGeoManager->cd("/cave_1/zdc01Empty_1"); 
+            //TGeoNode *zdc01 = gGeoManager->GetCurrentNode();
+            //zdc01->GetVolume()->SetTransparency(60);
+            //gGeoManager->cd("/cave_1/zdc01Empty_2"); 
+            //zdc01 = gGeoManager->GetCurrentNode();
+            //zdc01->GetVolume()->SetTransparency(60);
+            
+            //_test
+            /*TEveCalo3D* calo3d = new TEveCalo3D();
+            //calo3d->SetBarrelRadius(129.00);
+            calo3d->SetBarrelRadius(50.0);
+            //calo3d->SetEndCapPos(268.36);
+            Double_t zdcZPos = 410.5;
+            Double_t zdcZLen = 40.0;
+            
+            calo3d->SetEndCapPos(zdcZPos+zdcZLen);
+            //calo3d->SetEta(-100,100);
+            cout<<"calo3d->GetEndCapPos() = "<<calo3d->GetEndCapPos()<<endl;
+            cout<<"calo3d->GetBackwardEndCapPos() = "<<calo3d->GetBackwardEndCapPos()<<endl;
+            cout<<"calo3d->GetEta() = "<<calo3d->GetEta()<<endl;
+            cout<<"calo3d->GetEtaMax() = "<<calo3d->GetEtaMax()<<endl;//6.28319
+            cout<<"calo3d->GetEtaMin() = "<<calo3d->GetEtaMin()<<endl;//-6.28319
+            cout<<"calo3d->GetEtaRng() = "<<calo3d->GetEtaRng()<<endl;
+            cout<<"calo3d->GetPhi() = "<<calo3d->GetPhi()<<endl;
+            cout<<"calo3d->GetPhiMax() = "<<calo3d->GetPhiMax()<<endl;
+            cout<<"calo3d->GetPhiMin() = "<<calo3d->GetPhiMin()<<endl;
+            cout<<"calo3d->GetPhiRng() = "<<calo3d->GetPhiRng()<<endl;
+            cout<<"calo3d->GetForwardEndCapPos() = "<<calo3d->GetForwardEndCapPos()<<endl;
+            cout<<"calo3d->GetTransitionEta() = "<<calo3d->GetTransitionEta()<<endl;
+            cout<<"calo3d->GetTransitionEtaBackward() = "<<calo3d->GetTransitionEtaBackward()<<endl;
+            cout<<"calo3d->GetTransitionEtaForward() = "<<calo3d->GetTransitionEtaForward()<<endl;
+            cout<<"calo3d->GetTransitionTheta() = "<<calo3d->GetTransitionTheta()<<endl;
+            cout<<"calo3d->GetTransitionThetaBackward() = "<<calo3d->GetTransitionThetaBackward()<<endl;
+            cout<<"calo3d->GetTransitionThetaForward() = "<<calo3d->GetTransitionThetaForward()<<endl;           
+            cout<<"calo3d->GetMaxValAbs() = "<<calo3d->GetMaxValAbs()<<endl;           
+            cout<<"calo3d->GetMaxTowerH() = "<<calo3d->GetMaxTowerH()<<endl;
+            
+            //calo3d->SetFrameTransparency(100);
+            
+            // Create, fill and project a 2D histogram.
+            TH2F *h2 = new TH2F("h2","",200,-10,10,200,-TwoPi(),TwoPi());
+            Float_t px, py;
+            for (Int_t i = 0; i < 160000; i++) {
+                gRandom->Rannor(px,py);
+                if (Abs(px)>calo3d->GetTransitionEta())
+                    h2->Fill(px,py);
+            }
+            
+            TEveCaloDataHist* data = new TEveCaloDataHist();
+            data->AddHistogram(h2);//ecalHist);
+            data->RefSliceInfo(0).Setup("ECAL", 0.3, kRed);
+            //data->RefSliceInfo(1).Setup("HCAL", 0.1, kBlue);
+            data->GetEtaBins()->SetTitleFont(120);
+            data->GetEtaBins()->SetTitle("h");
+            data->GetPhiBins()->SetTitleFont(120);
+            data->GetPhiBins()->SetTitle("f");
+            data->IncDenyDestroy();
+            gEve->AddToListTree(data, kFALSE);
+            
+            TEveViewer* v= gEve->GetDefaultViewer();
+            
+            // Create a scene and a viewer in the given slot.
+            TEveScene* s = gEve->SpawnNewScene("Scene ZDC");
+            v->AddScene(s);
+            calo3d->SetData(data);
+            s->AddElement(calo3d);
+
+            //gEve->GetBrowser()->GetTabRight()->SetTab(1);
+            gEve->Redraw3D(kFALSE);*/
+            //_____
+        }
+        else
+        {
+            if (GetResetRequiredFlag())
+            {               
+                for (Int_t i = 0; i < GetNumModules()*2; ++i)
+                    SetEneArr(i,1);
+                SetMaxE(1);
+                DrawTowers();
+                 for (Int_t i = 0; i < GetNumModules()*2; ++i)
+                    SetEneArr(i,0);
+                SetMaxE(0);
+                SetResetRequiredFlag(kFALSE);
+            }
+        }
+        TEvePointSet* q = new TEvePointSet(GetName(), fDigitList->GetEntriesFast(), TEvePointSelectorConsumer::kTVT_XYZ);
+        q->SetOwnIds(kTRUE);
+        
+        if (fEventManager->EveRecoPoints == NULL)
+        {
+            fEventManager->EveRecoPoints = new TEveElementList("Reco points");
+            gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
+            fEventManager->EveRecoPoints->SetRnrState(kFALSE);
+        }
+        
+        gEve->AddElement(q, fEventManager->EveRecoPoints);
+        
+        gEve->FullRedraw3D();
+        fq = q;
+    }
+}
+
+void MpdZdcTowerDraw::DrawTowers()
+{
+    gGeoManager->cd("/cave_1");
+    TGeoNode *caveNode = gGeoManager->GetCurrentNode();
+    
+    for (UInt_t zdcId = 0; zdcId < 2; ++zdcId) {
+        gGeoManager->cd(Form("/cave_1/zdc01_%d",zdcId+1)); 
+        TGeoNode *zdcNode = gGeoManager->GetCurrentNode();
+        TGeoVolume *zdcVolumeClone = zdcNode->GetVolume()->CloneVolume();               
+        TObjArray *zdcArr= zdcNode->GetVolume()->GetNodes();
+        
+        for (UInt_t module = 0; module < zdcNode->GetVolume()->GetNdaughters(); ++module) {        
+            TGeoNode *moduleNode = (TGeoNode*)(zdcArr->UncheckedAt(module));    
+            TGeoNode*	moduleNodeCopy;
+            if(GetShadowFlag())
+            {
+                RecursiveChangeNodeTransparent(moduleNode, 0);
+                moduleNodeCopy =  moduleNode->MakeCopyNode();
+            }
+            
+            UInt_t iCur = zdcId*GetNumModules()+moduleNode->GetNumber()-1;
+            TGeoBBox *box = (TGeoBBox*)moduleNode->GetVolume()->GetShape()->Clone();
+            TGeoVolume *moduleVolumeCopyInit = moduleNode->GetVolume()->MakeCopyVolume((TGeoShape*)box);
+            //cout<<"GetEneArrValue(iCur) = "<< GetEneArrValue(iCur)<<"; box->GetName() = "<<box->GetName()<<"; moduleNode->GetMotherVolume()->GetName() = "<<moduleNode->GetMotherVolume()->GetName()<<"; moduleNode->GetName() = "<<moduleNode->GetName()<<"; moduleNode->GetNumber() = "<<moduleNode->GetNumber()<<"; iCur = "<<iCur<<endl;
+                                        
+            TGeoMatrix* mat =moduleNode->GetMatrix()->MakeClone();
+            //TGeoMatrix* mat1 =moduleNode->GetMatrix()->MakeClone();
+            if (GetEneArrValue(iCur)!=0)
+            {                 
+                box->SetBoxDimensions(box->GetDX(), box->GetDY(), GetModuleZLen()*GetEneArrValue(iCur)/GetMaxE());                                                
+                ((TGeoTranslation*)mat)->SetDz(GetModuleZLen()*GetEneArrValue(iCur)/GetMaxE()-GetModuleZLen());                       
+            }
+            
+            zdcVolumeClone->RemoveNode(moduleNode); 
+            TGeoVolume *moduleVolumeCopy = moduleNode->GetVolume()->MakeCopyVolume((TGeoShape*)box);
+            moduleVolumeCopy->SetVisibility(kTRUE);
+            if (GetEneArrValue(iCur)==0)            
+                moduleVolumeCopy->SetVisibility(kFALSE);            
+                
+            //the internal structure of Module does note alow to change it's shape, so we delete it for the towers visualization                         
+            TObjArray *arr = moduleVolumeCopy->GetNodes();
+            UInt_t count = moduleVolumeCopy->GetNdaughters();
+            for (UInt_t sa = 0; sa < count; ++sa) {
+                TGeoNode *node = (TGeoNode*)(arr->UncheckedAt(0));
+                moduleVolumeCopy->RemoveNode(node);
+            }  
+            
+            if(GetShadowFlag())
+                RecursiveChangeNodeTransparent(moduleNodeCopy, 98);
+            
+            zdcVolumeClone->AddNode(moduleVolumeCopy, moduleNode->GetNumber(),mat);
+            
+            
+            if(GetShadowFlag())
+                zdcVolumeClone->AddNode(moduleNodeCopy->GetVolume(), moduleNode->GetNumber(),moduleNode->GetMatrix());
+            
+        }
+
+        caveNode->GetVolume()->AddNode(zdcVolumeClone,zdcNode->GetNumber(),zdcNode->GetMatrix());                
+        caveNode->GetVolume()->RemoveNode(zdcNode); 
+        //zdcNode->GetVolume()->SetInvisible();//VisibleDaughters(kTRUE);
+        //zdcNode->SetVisibility(kFALSE);
+        //zdcNode->VisibleDaughters(kTRUE);
+        //RecursiveChangeNodeTransparent(zdcNode, 80);
+        //RecursiveChangeNodeTransparent(zdcNode, 0);
+        
+    }           
+    SetResetRequiredFlag(kTRUE);
+}
+
+void MpdZdcTowerDraw::RecursiveChangeNodeTransparent(TGeoNode* node, int transparency)
+{
+    for (int i = 0; i < node->GetNdaughters(); i++)
+    {
+        TGeoNode* child = node->GetDaughter(i);
+        TGeoVolume* curVolume = child->GetVolume();
+
+        curVolume->SetTransparency(transparency);
+
+        if (child->GetNdaughters() != 0)
+            RecursiveChangeNodeTransparent(child, transparency);
+    }
+}
+
+// -----   Destructor   ----------------------------------------------------
+MpdZdcTowerDraw::~MpdZdcTowerDraw()
+{
+    fDigitList->Delete();
+}
+
+// -------------------------------------------------------------------------
+
+/** Action after each event**/
+void MpdZdcTowerDraw::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void MpdZdcTowerDraw::Reset()
+{     
+    if (fq != 0)
+    {           
+        fq->Reset();
+        gEve->RemoveElement(fq, fEventManager->EveRecoPoints);                
+    }    
+}
+
+ClassImp(MpdZdcTowerDraw);
diff --git a/eventdisplay/mpd/MpdZdcTowerDraw.h b/eventdisplay/mpd/MpdZdcTowerDraw.h
new file mode 100644
index 0000000..ccb8c84
--- /dev/null
+++ b/eventdisplay/mpd/MpdZdcTowerDraw.h
@@ -0,0 +1,85 @@
+// -------------------------------------------------------------------------
+// -----                      ZdcTowerDraw header file                 -----
+// -------------------------------------------------------------------------
+
+#ifndef ZDCTOWERDRAW_H
+#define ZDCTOWERDRAW_H
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+#include "TEvePointSet.h"               // for TEvePointSet
+
+#include <TObject.h>
+#include <TString.h>
+#include <TClonesArray.h>
+#include <TMath.h>
+
+using namespace TMath;
+
+class MpdZdcTowerDraw : public FairTask
+{
+  public:
+    /** Default constructor **/
+    MpdZdcTowerDraw();
+
+    /** Standard constructor
+    *@param name        Name of task
+    *@param verbose    Verbosity level   
+    **/
+    MpdZdcTowerDraw(const char* name,Double_t zdcMinEnergyThreshold = 0, Bool_t shadow = kFALSE,  Int_t verbose = 1);
+
+    /** Destructor **/
+    virtual ~MpdZdcTowerDraw();
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(UInt_t verboselvl) { fVerboselvl = verboselvl; }
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+    void Reset();
+
+  protected:    
+    TClonesArray* fDigitList; //!
+    FairEventManager* fEventManager; //! 
+    TEvePointSet* fq;    //!
+    
+    virtual InitStatus Init();
+    virtual void Finish(); ///< Action after each event
+    void RecursiveChangeNodeTransparent(TGeoNode* node, int transparency);
+    void DrawTowers(); ///< adjust towers heights
+    
+    /** Accessors **/
+    UInt_t GetVerboselvl() const { return fVerboselvl; }
+    Bool_t GetShadowFlag() const { return fShadow; }
+    Bool_t GetResetRequiredFlag() const { return fResetRequiredFlag; }
+    Double_t GetEneArrValue(UInt_t i) const { return fEneArr[i]; }
+    Double_t GetMaxE() const { return fMaxE; }  
+    UInt_t GetNumModules() const { return fNumModules; }  
+    Double_t GetModuleZLen() const { return fModuleZLen; }  
+    Double_t GetZdcMinEnergyThreshold() const { return fZdcMinEnergyThreshold; }
+    
+    /** Modifiers **/
+    void SetResetRequiredFlag(Bool_t resetRequiredFlag) { fResetRequiredFlag = resetRequiredFlag; }
+    void SetEneArr(UInt_t i, Double_t val) { fEneArr[i] = val; } ///< set energy loss array value
+    void SetMaxE(Double_t maxE) { fMaxE = maxE; }
+    void SetNumModules(UInt_t numModules) { fNumModules = numModules; }
+    void SetModuleZLen(Double_t moduleZLen) { fModuleZLen = moduleZLen; }
+    
+  private:   
+    Int_t fVerboselvl; ///< Verbosity level   
+    Bool_t fShadow; ///< kTRUE to display transparent contur of zdc
+    Bool_t fResetRequiredFlag; ///< flag true is box sizes are adjusted
+    
+    Double_t* fEneArr; //!< array of energies in each box of ZDC, GeV
+    Double_t fMaxE; ///< energy loss at the bin with maximum energy loss, GeV
+    
+    UInt_t fNumModules; ///< number of modules in one ZDC detector
+    Double_t fModuleZLen; ///< z lenght of ZDC module, cm    
+    
+    Double_t fZdcMinEnergyThreshold;///< min energy threshold
+    
+    MpdZdcTowerDraw(const MpdZdcTowerDraw&);
+    MpdZdcTowerDraw& operator=(const MpdZdcTowerDraw&);
+
+    ClassDef(MpdZdcTowerDraw,1);
+};
+
+#endif
diff --git a/eventdisplay/raw/RawDataConverter.cxx b/eventdisplay/raw/RawDataConverter.cxx
new file mode 100644
index 0000000..da7f921
--- /dev/null
+++ b/eventdisplay/raw/RawDataConverter.cxx
@@ -0,0 +1,272 @@
+#include "RawDataConverter.h"
+#include "BmnMwpcHit.h"
+
+#include "TGeoManager.h"
+#include "TMath.h"
+using namespace TMath;
+
+#include <iostream>
+using namespace std;
+
+RawDataConverter::RawDataConverter()
+{
+    kTimeBin = 8; // ns
+    kNWires = 96; //in one plane
+    kAngleStep = 60.0; // degrees
+    kWireStep = 0.25; // cm
+    kPlaneWidth = kNWires * kWireStep; // cm
+
+    kMwpcZpos = 50.0; // z-position of the center of MWPC
+
+    MwpcPosition[0] = NULL; MwpcPosition[1] = NULL; MwpcPosition[2] = NULL;
+}
+
+RawDataConverter::~RawDataConverter()
+{
+}
+
+vector<TVector3*> RawDataConverter::MWPCEventToGeoVector(EventData* curEvent)
+{
+    bool isEmptyPlane = false;
+    for (int j = 0; j< 6; j++)
+    {
+        if (curEvent->MWPC1Planes[j].size() == 0)
+            isEmptyPlane = true;
+    }
+
+    if (isEmptyPlane)
+        cout<<"WARNING!!! digits count 0"<<endl;
+
+    cout<<"Search hits: "<<curEvent->MWPC1Planes[0].size()<<" : "<<curEvent->MWPC1Planes[1].size()<<" : "<<curEvent->MWPC1Planes[2].size()<<" : "
+        <<curEvent->MWPC1Planes[3].size()<<" : "<<curEvent->MWPC1Planes[4].size()<<" : "<<curEvent->MWPC1Planes[5].size()<<endl;
+
+    vector<TVector3*> event_hits = SearchHits(curEvent->MWPC1Planes[0], curEvent->MWPC1Planes[1], curEvent->MWPC1Planes[2],
+                                              curEvent->MWPC1Planes[3], curEvent->MWPC1Planes[4], curEvent->MWPC1Planes[5]);
+
+    return event_hits;
+}
+
+TEvePointSet* RawDataConverter::Vector2EvePoints(vector<TVector3*>* pPointVector, TString strSetName, Color_t fColor, Style_t fStyle, Int_t iMarkerSize, bool isDebug)
+{
+    Int_t npoints = pPointVector->size();
+    TEvePointSet* q = new TEvePointSet(strSetName, npoints, TEvePointSelectorConsumer::kTVT_XYZ);
+
+    q->SetOwnIds(kTRUE);
+    q->SetMarkerColor(fColor);
+    q->SetMarkerSize(iMarkerSize);
+    q->SetMarkerStyle(fStyle);
+
+    for (Int_t i = 0; i < npoints; i++)
+    {
+        TVector3* vec = (*pPointVector)[i];
+        if (isDebug)
+            cout<<"Point "<<i<<": x="<<vec->X()<<" y="<<vec->Y()<<" z="<<vec->Z()<<endl;
+
+        q->SetNextPoint(vec->X(), vec->Y(), vec->Z());
+        q->SetPointId(new TNamed(Form("Point %d", i), strSetName.Data()));
+
+        // bug in ROOT with one point drawing
+        if (npoints == 1)
+        {
+            q->SetNextPoint(vec->X()+0.0001, vec->Y(), vec->Z());
+            q->SetPointId(new TNamed("Point 1", strSetName.Data()));
+        }
+    }
+
+    return q;
+}
+
+void RawDataConverter::SetMwpcPosition(int mwpc_number, TVector3 mwpc_position)
+{
+    if ((mwpc_number > 0) && (mwpc_number < 4))
+        MwpcPosition[mwpc_number-1] = new TVector3(mwpc_position);
+    else
+        cout<<"RawDataConverter::SetMwpcPosition function error: incorrect MWPC number - "<<mwpc_number<<endl;
+}
+
+void RawDataConverter::MwpcDigits2MwpcHits(TClonesArray* pMwpcDigits, TClonesArray* pMwpcHits)
+{
+    // divide digits by three MWPC
+    vector<BmnMwpcDigit*> x[3][6];
+    for (int i = 0; i < pMwpcDigits->GetEntriesFast(); i++)
+    {
+        BmnMwpcDigit* pDigit = (BmnMwpcDigit*)pMwpcDigits->At(i);
+        int mwpc_number = pDigit->GetPlane() / 6;
+        int plane_number = pDigit->GetPlane() - mwpc_number*6;
+        pDigit->SetPlane(plane_number);
+        x[mwpc_number][plane_number].push_back(pDigit);
+    }
+
+    // for three MWPC detectors convert to MWPC hits
+    for (int i = 0; i < 3; i++)
+    {
+        vector<TVector3*> hits = SearchHits(x[i][0], x[i][1], x[i][2], x[i][3], x[i][4], x[i][5]);
+
+        // correct MWPC position
+        TVector3* pShift = MwpcPosition[i];
+        if (pShift != NULL)
+        {
+            double dx = pShift->X(), dy = pShift->Y(), dz = pShift->Z();
+            for (int j = 0; j < hits.size(); j++)
+            {
+                *hits[j] += TVector3(dx, dy, dz - kMwpcZpos);
+            }
+        }
+
+        // write to MwpcHits array (TClonesArray)
+        for (int j = 0; j < hits.size(); j++)
+        {
+            new ((*pMwpcHits)[pMwpcHits->GetEntriesFast()]) BmnMwpcHit(0, *hits[j], TVector3(0, 0, 0), i);
+            //cout<<"Hit X: "<<hits[j]->X()<<" Y:"<<hits[j]->Y()<<" Z:"<<hits[j]->Z()<<endl;
+        }
+    }
+
+    return;
+}
+
+TVector3* RawDataConverter::CalcHitPosByTwoDigits(BmnMwpcDigit* dI, BmnMwpcDigit* dJ)
+{
+    Short_t dWireI = dI->GetWireNumber();
+    Short_t dWireJ = dJ->GetWireNumber();
+    Float_t xI = kPlaneWidth * (dWireI * 1.0 / kNWires - 0.5); //local X by wire number
+    Float_t xJ = kPlaneWidth * (dWireJ * 1.0 / kNWires - 0.5); //local X by wire number
+    Float_t aI = (dI->GetPlane() - 1) * kAngleStep * DegToRad(); //rotation angle by plane number
+    Float_t aJ = (dJ->GetPlane() - 1) * kAngleStep * DegToRad(); //rotation angle by plane number
+    Float_t xGlob = (xI * Sin(aJ) - xJ * Sin(aI)) / Sin(aJ - aI);
+    Float_t yGlob = (xI * Cos(aJ) - xJ * Cos(aI)) / Sin(aJ - aI);
+    Float_t zGlob = kMwpcZpos - Float_t(min(dI->GetPlane(), dJ->GetPlane()) - 3); //average position between two neighbor planes
+    TVector3* pos = new TVector3(xGlob, yGlob, zGlob);
+    return pos;
+}
+
+vector<TVector3*> RawDataConverter::CreateHitsByTwoPlanes(vector<BmnMwpcDigit*> x, vector<BmnMwpcDigit*> y) {
+    vector<TVector3*> v;
+    for (Int_t i = 0; i < x.size(); ++i) {
+        BmnMwpcDigit* dI = (BmnMwpcDigit*) x.at(i);
+        for (Int_t j = 0; j < y.size(); ++j) {
+            BmnMwpcDigit* dJ = (BmnMwpcDigit*) y.at(j);
+            //if (dI->GetTime() != dJ->GetTime()) continue;
+            v.push_back(CalcHitPosByTwoDigits(dI, dJ));
+        }
+    }
+    return v;
+}
+
+vector<TVector3*> RawDataConverter::SearchHits(vector<BmnMwpcDigit*> x1, vector<BmnMwpcDigit*> u1, vector<BmnMwpcDigit*> v1, vector<BmnMwpcDigit*> x2, vector<BmnMwpcDigit*> u2, vector<BmnMwpcDigit*> v2)
+{
+    Float_t x = 0.0;
+    Float_t y = 0.0;
+    Float_t z = 0.0;
+
+    //temporary parameter for excluding fakes
+    Float_t delta = 4.0; //cm
+
+    vector<TVector3*> x1u1 = CreateHitsByTwoPlanes(x1, u1);
+    vector<TVector3*> u1v1 = CreateHitsByTwoPlanes(u1, v1);
+    vector<TVector3*> v1x2 = CreateHitsByTwoPlanes(v1, x2);
+    vector<TVector3*> x2u2 = CreateHitsByTwoPlanes(x2, u2);
+    vector<TVector3*> u2v2 = CreateHitsByTwoPlanes(u2, v2);
+    vector<TVector3*> v2x1 = CreateHitsByTwoPlanes(v2, x1);
+
+    TVector3* pos3 = NULL;
+    vector<TVector3*> hits;
+
+    for (Int_t i1 = 0; i1 < x1u1.size(); ++i1) {
+        TVector3* pos1 = x1u1.at(i1);
+        if (pos1->z() < 0) continue;
+        for (Int_t i2 = 0; i2 < v1x2.size(); ++i2) {
+            TVector3* pos2 = v1x2.at(i2);
+            if (pos2->z() < 0 || pos1->z() < 0) continue;
+            if (Sqrt((pos1->x() - pos2->x()) * (pos1->x() - pos2->x()) + (pos1->y() - pos2->y()) * (pos1->y() - pos2->y())) > delta) continue;
+            for (Int_t i3 = 0; i3 < u2v2.size(); ++i3) {
+                pos3 = u2v2.at(i3);
+                if (pos3->z() < 0 || pos2->z() < 0 || pos1->z() < 0) continue;
+                if (Sqrt((pos2->x() - pos3->x()) * (pos2->x() - pos3->x()) + (pos2->y() - pos3->y()) * (pos2->y() - pos3->y())) > delta) continue;
+                //Int_t ref = (dI->GetRefId() == dJ->GetRefId() && dI->GetRefId() == dK->GetRefId()) ? dI->GetRefId() : -1;
+                //cout << "ref = " << ref << " | x1:" << dI->GetRefId() << " | u1:" << dJ->GetRefId() << " | v1:" << dK->GetRefId() << endl;
+                x = (pos1->x() + pos2->x() + pos3->x()) / 3;
+                y = (pos1->y() + pos2->y() + pos3->y()) / 3;
+                z = (pos1->z() + pos2->z() + pos3->z()) / 3;
+                pos1->SetZ(-1.0);
+                pos2->SetZ(-1.0);
+                pos3->SetZ(-1.0);
+                TVector3* coord = new TVector3(x, y, z);
+                hits.push_back(coord);
+            }
+        }
+    }
+
+    Double_t k = Tan(kAngleStep / 2 * DegToRad());
+    Double_t b = kPlaneWidth * k;
+    delta = 0.5; //cm
+
+    //Checking angle s between x1 and u1, x2 and u2
+    for (Int_t i = 0; i < x1u1.size(); ++i)
+    {
+        TVector3* pos1 = x1u1.at(i);
+        if (pos1->z() < 0) continue;
+        if ((pos1->y() < (-k * pos1->x() + b)) && pos1->y() < (-k * pos1->x() - b)) continue;
+        for (Int_t j = 0; j < x2u2.size(); ++j)
+        {
+            TVector3* pos2 = x2u2.at(j);
+            if (pos2->z() < 0 || pos1->z() < 0) continue;
+            if ((pos2->y() < (-k * pos2->x() + b)) && pos2->y() < (-k * pos2->x() - b)) continue;
+            if (Sqrt((pos1->x() - pos2->x()) * (pos1->x() - pos2->x()) + (pos1->y() - pos2->y()) * (pos1->y() - pos2->y())) > delta) continue;
+            x = (pos1->x() + pos2->x()) * 0.5;
+            y = (pos1->y() + pos2->y()) * 0.5;
+            z = (pos1->z() + pos2->z()) * 0.5;
+
+            pos1->SetZ(-1.0);
+            pos2->SetZ(-1.0);
+
+            TVector3* coord = new TVector3(x, y, z);
+            hits.push_back(coord);
+        }
+    }
+
+    //Checking angle s between u1 and v1, u2 and v2
+    for (Int_t i = 0; i < u1v1.size(); ++i) {
+        TVector3* pos1 = u1v1.at(i);
+        if (pos1->z() < 0) continue;
+        if (pos1->x() > (-kPlaneWidth * 0.5) && pos1->x() < (kPlaneWidth * 0.5)) continue;
+        for (Int_t j = 0; j < u2v2.size(); ++j) {
+            TVector3* pos2 = u2v2.at(j);
+            if (pos2->z() < 0 || pos1->z() < 0) continue;
+            if (pos2->x() > (-kPlaneWidth * 0.5) && pos2->x() < (kPlaneWidth * 0.5)) continue;
+            if (Sqrt((pos1->x() - pos2->x()) * (pos1->x() - pos2->x()) + (pos1->y() - pos2->y()) * (pos1->y() - pos2->y())) > delta) continue;
+            x = (pos1->x() + pos2->x()) * 0.5;
+            y = (pos1->y() + pos2->y()) * 0.5;
+            z = (pos1->z() + pos2->z()) * 0.5;
+
+            pos1->SetZ(-1.0);
+            pos2->SetZ(-1.0);
+
+            TVector3* coord = new TVector3(x, y, z);
+            hits.push_back(coord);
+        }
+    }
+
+    //Checking angle s between v1 and x2, v2 and x1
+    for (Int_t i = 0; i < v1x2.size(); ++i) {
+        TVector3* pos1 = v1x2.at(i);
+        if (pos1->z() < 0) continue;
+        if ((pos1->y() < (k * pos1->x() + b)) && pos1->y() < (k * pos1->x() - b)) continue;
+        for (Int_t j = 0; j < v2x1.size(); ++j) {
+            TVector3* pos2 = v2x1.at(j);
+            if (pos2->z() < 0 || pos1->z() < 0) continue;
+            if ((pos2->y() < (k * pos2->x() + b)) && pos2->y() < (k * pos2->x() - b)) continue;
+            if (Sqrt((pos1->x() - pos2->x()) * (pos1->x() - pos2->x()) + (pos1->y() - pos2->y()) * (pos1->y() - pos2->y())) > delta) continue;
+            x = (pos1->x() + pos2->x()) * 0.5;
+            y = (pos1->y() + pos2->y()) * 0.5;
+            z = (pos1->z() + pos2->z()) * 0.5;
+
+            pos1->SetZ(-1.0);
+            pos2->SetZ(-1.0);
+
+            TVector3* coord = new TVector3(x, y, z);
+            hits.push_back(coord);
+        }
+    }
+
+    return hits;
+}
diff --git a/eventdisplay/raw/RawDataConverter.h b/eventdisplay/raw/RawDataConverter.h
new file mode 100644
index 0000000..d0f557c
--- /dev/null
+++ b/eventdisplay/raw/RawDataConverter.h
@@ -0,0 +1,44 @@
+#ifndef RAWDATACONVERTER_H
+#define RAWDATACONVERTER_H
+
+#include "RawDataParser.h"
+
+#include "TVector3.h"
+#include "TClonesArray.h"
+#include "TEvePointSet.h"
+
+class RawDataConverter
+{
+  public:
+    Short_t kTimeBin; // ns
+    Short_t kNWires; //in one plane
+    Float_t kAngleStep; // degrees
+    Float_t kWireStep; // cm
+    Float_t kPlaneWidth; // cm
+
+    Float_t kMwpcZpos; // z-position of the center of MWPC
+
+    // nWire1 - number of the first wire      //from 0 to 102
+    // nWire2 - number of the second wire     //from 0 to 102
+    // nPlane1 - number of the first plane    //from 1 to 6
+    // nPlane2 - number of the second plane   //from 1 to 6
+
+    /** Default constructor **/
+    RawDataConverter();
+    /** Destructor **/
+    virtual ~RawDataConverter();
+
+    vector<TVector3*> SearchHits(vector<BmnMwpcDigit*> x1, vector<BmnMwpcDigit*> u1, vector<BmnMwpcDigit*> v1, vector<BmnMwpcDigit*> x2, vector<BmnMwpcDigit*> u2, vector<BmnMwpcDigit*> v2);
+    vector<TVector3*> MWPCEventToGeoVector(EventData* pEventData);
+    void MwpcDigits2MwpcHits(TClonesArray* pMwpcDigits, TClonesArray* pMwpcHits);
+    void SetMwpcPosition(int mwpc_number, TVector3 mwpc_position);
+
+    static TEvePointSet* Vector2EvePoints(vector<TVector3*>* pPointVector, TString strSetName, Color_t fColor, Style_t fStyle, Int_t iMarkerSize = 1, bool isDebug = false);
+
+  private:
+    TVector3* CalcHitPosByTwoDigits(BmnMwpcDigit* dI, BmnMwpcDigit* dJ);
+    vector<TVector3*> CreateHitsByTwoPlanes(vector<BmnMwpcDigit*> x, vector<BmnMwpcDigit*> y);
+    TVector3* MwpcPosition[3];
+};
+
+#endif // RAWDATACONVERTER_H
diff --git a/eventdisplay/raw/RawDataParser.cxx b/eventdisplay/raw/RawDataParser.cxx
new file mode 100644
index 0000000..6ce6c4a
--- /dev/null
+++ b/eventdisplay/raw/RawDataParser.cxx
@@ -0,0 +1,701 @@
+#include "RawDataParser.h"
+#include "function_set.h"
+
+#include <cerrno>
+#include <iostream>
+using namespace std;
+
+RawDataParser::RawDataParser()
+{
+    device_serial[0x1A8D] = 1;
+    device_serial[0x2950] = 2;
+    device_serial[0x3043] = 3;
+    device_serial[0x304E] = 4;
+    device_serial[0x4514] = 5;
+    device_serial[0x45DF] = 6;
+
+    device_serial1[0x3F8B] = 1;
+    device_serial1[0x2950] = 2;
+    device_serial1[0x4514] = 3;
+    device_serial1[0x4504] = 4;
+    device_serial1[0x3043] = 5;
+    device_serial1[0x304E] = 6;
+
+    device_serial2[0x47CB] = 1;
+    device_serial2[0x2A79] = 2;
+    device_serial2[0x3F1D] = 3;
+    device_serial2[0x4513] = 4;
+    device_serial2[0x3F97] = 5;
+    device_serial2[0x2FFF] = 6;
+}
+
+RawDataParser::~RawDataParser()
+{
+}
+
+//buffer - unsigned int array from file with HRB Raw Data Format 1.0
+//size - size of 'buffer' variable in words (unsigned int)
+//fEventReadData - vector with EventData objects
+int RawDataParser::ParseHRB1Buffer(unsigned int* buffer, long size, vector<EventData*>* fEventData)
+{
+    unsigned char byte_hh;//, byte_hl, byte_lh, byte_ll;
+    unsigned int int_h, int_l;
+    long cur_word = 0, i = 0;
+    //unsigned int max_diff = 0,  = 0;
+    cout<<"enter of parsing file"<<endl;
+    //sleep(1);
+    int max_event_diff = 0, ind = 0;
+    while (cur_word < size)
+    {
+        ind++;
+        // M-Link HEADER - frame type
+        unsigned int x = buffer[cur_word++];
+
+        // check sync word: 0x2A50
+        int_h = x >> 16;
+        if (int_h != 0x2A50)
+        {
+            fputs("sync word error, should be 0x2A50", stderr);
+            return -1;
+        }
+
+        // check frame type: 0x5354 - stream data
+        int_l = x & 0xFFFF;
+        if (int_l != 0x5354)
+        {
+            fputs("frame type error, should be 0x5354", stderr);
+            return -2;
+        }
+
+        // M-Link HEADER - frame info
+        x = buffer[cur_word++];
+
+        unsigned int frame_length = x >> 16;
+        unsigned int frame_number = x & 0xFFFF;
+        //cout<<"frame_length: "<<frame_length<<endl;
+        //cout<<"frame_number: "<<frame_number<<endl;
+
+        // skip destination and source address
+        cur_word++;
+
+        // M-Stream Header - data type and flags
+        x = buffer[cur_word++];
+        byte_hh = *((unsigned char*)&x + 3);
+        if (byte_hh != 0xBC)
+        {
+            fputs("data type error, should be 0xBC", stderr);
+            return -3;
+        }
+        unsigned int fragment_length = x & 0xFFFF;
+        //cout<<"fragment_length: "<<fragment_length<<endl;
+
+        // skip fragment ID and offset
+        cur_word++;
+
+        // M-Stream Payload - device serial (define plane number starting with 1)
+        x = buffer[cur_word++];
+        unsigned int plane_number = device_serial.find(x & 0xFFFF)->second;
+        //cout<<"plane_number: "<<plane_number<<endl;
+
+        // M-Stream Payload - event (0:23 bits) and channel number
+        x = buffer[cur_word++];
+        unsigned int event_number = x & 0xFFFFFF;
+        //cout<<"event_number: "<<event_number<<endl;
+        //if (event_number > max_event)
+        //    max_event = event_number;
+        //if ((max_event - event_number) > max_diff)
+        //    max_diff = max_event - event_number;
+        /*
+        vector<EventData*>::iterator it = fEventReadData->begin();
+        EventData* pCurEvent = NULL;
+        for (i = 0; i < fEventReadData->size(); i++, it++)
+        {
+            pCurEvent = (*fEventReadData)[i];
+
+            if (pCurEvent->uiEventNumber == event_number)
+                break;
+
+            if (pCurEvent->uiEventNumber > event_number)
+            {
+                pCurEvent = new EventData();
+                pCurEvent->uiEventNumber = event_number;
+
+                fEventReadData->insert(it, pCurEvent);
+                //cout<<"event was inner added: "<<i<<" event_number="<<event_number<<endl;
+                break;
+            }
+        }
+        if (i == fEventReadData->size())
+        {
+            pCurEvent = new EventData();
+            pCurEvent->uiEventNumber = event_number;
+
+            fEventReadData->push_back(pCurEvent);
+            //cout<<"event was outer added: "<<i<<" event_number="<<event_number<<endl;
+        }
+        */
+
+        // M-Stream Payload - timestamp (high and low)
+        x = buffer[cur_word++];
+        ULong64_t event_timestamp = x + (((ULong64_t)buffer[cur_word++]) << 32);
+        //ULong64_t event_timestamp = (((ULong64_t)x) << 32) + buffer[cur_word++];
+
+        vector<EventData*>::iterator it = fEventData->end();
+        EventData* pCurEvent = NULL;
+        int cnt = 0;
+        for (i = fEventData->size() - 1; i >= 0; i--, it--, cnt++)
+        {
+            pCurEvent = (*fEventData)[i];
+
+            if (pCurEvent->event_timestamp < event_timestamp)
+            {
+                pCurEvent = new EventData();
+                pCurEvent->event_timestamp = event_timestamp;
+
+                //if (i == (fEventReadData->size()-1))
+                //    fEventReadData->push_back(pCurEvent);
+                //else
+                fEventData->insert(it, pCurEvent);
+
+                break;
+            }
+
+            if (pCurEvent->event_timestamp == event_timestamp)
+                break;
+        }// for
+        if (i < 0)
+        {
+            pCurEvent = new EventData();
+            pCurEvent->event_timestamp = event_timestamp;
+
+            if (fEventData->size() == 0)
+                fEventData->push_back(pCurEvent);
+            else
+            {
+                if (*it != *(fEventData->begin()))
+                {
+                    cout<<"DATA ERROR: it != fEventReadData->begin()"<<endl;
+                    sleep(3);
+                }
+
+                fEventData->insert(it, pCurEvent);
+            }
+        }
+        if (cnt > max_event_diff)
+            max_event_diff = cnt;
+
+        // define vector for digits by plane_number
+        vector<BmnMwpcDigit*>* pDigitsPlane = &pCurEvent->MWPC1Planes[plane_number-1];
+
+        // M-Stream data - searching for "1" bits - working only with 32-bit words ratio, can be generalized
+        if (((fragment_length / 16) * 16) != fragment_length)
+        {
+            fputs("fragment length isn't aligned with 4 32-bit word", stderr);
+            return -4;
+        }
+        int time_bin = 1;   // starting from 1
+        for (unsigned int ui = 16; ui < fragment_length; ui += 16, time_bin++)
+        {
+            // 96 bit for every wire and 32 bit is empty (zero)
+            for (int j = 0; j < 3; j++)
+            {
+                x = buffer[cur_word++];
+
+                int pos = sizeof(unsigned int)*8 - 1;
+                while ((pos--) >= 0)
+                {
+                    if (CHECK_BIT(x, pos))
+                    {
+                        // starting number from 0
+                        int active_wire = j*32 + pos;
+
+                        //cout<<"event timestamp: "<<event_timestamp<<"; plane: "<<plane_number<<"; time: "<<time_bin<<"; wire: "<<active_wire<<endl;
+                        //sleep(1);
+
+                        BmnMwpcDigit* pDigit = new BmnMwpcDigit(plane_number, active_wire, time_bin, -1);
+
+                        pDigitsPlane->push_back(pDigit);
+                    }
+                }
+            }
+            cur_word++;
+        }// for detector's wires
+
+        // skip M-Link CRC
+        cur_word++;
+
+        //cout<<endl<<endl;
+    }// while not end of file
+
+    cout<<"exit of parsing file"<<" iterations count: "<<ind<<endl;
+    //cout<<"event count: "<<fEventReadData->size()<<endl;
+    //cout<<"max_event_diff: "<<max_event_diff<<endl;
+    //sleep(3);
+}
+
+//buffer - unsigned int array from file with HRB Raw Data Format 2.0
+//size - size of 'buffer' variable in words (unsigned int)
+//fEventData - vector with EventData objects
+int RawDataParser::ParseHRB2Buffer(unsigned int* buffer, long size, vector<EventData*>* fEventData)
+{
+    unsigned char byte_hh;  //, byte_hl, byte_lh, byte_ll;
+    unsigned int int_h, int_l;
+    long cur_word = 0, i = 0;
+    //unsigned int max_diff = 0,  = 0;
+    cout<<"enter of parsing file"<<endl;
+    //sleep(1);
+    int max_event_diff = 0, ind = 0;
+    while (cur_word < size)
+    {
+        ind++;
+        // M-Link HEADER - frame type
+        unsigned int x = buffer[cur_word++];
+
+        // check sync word: 0x2A50
+        int_h = x >> 16;
+        if (int_h != 0x2A50)
+        {
+            cout<<"sync word error, should be 0x2A50, but it's equal to "<<int_h<<endl;
+            return -1;
+        }
+
+        // check frame type: 0x2A50 - stream data 2.0
+        int_l = x & 0xFFFF;
+        if (int_l != 0x2A50)
+        {
+            fputs("frame type error, should be 0x2A50", stderr);
+            return -2;
+        }
+
+        // M-Link HEADER - frame info
+        x = buffer[cur_word++];
+
+        unsigned int frame_length = x >> 16;
+        unsigned int frame_number = x & 0xFFFF;
+        //cout<<"frame_length: "<<frame_length<<endl;
+        //cout<<"frame_number: "<<frame_number<<endl;
+
+        // skip destination and source address
+        cur_word++;
+
+        int MWPC_number = -1;
+        unsigned int plane_number = 0;
+        // M-Stream Subtype 0 - device serial id (define plane number starting with 1)
+        x = buffer[cur_word++];
+        int_l = x & 0xFFFF;
+        //cout<<"device_serial: 0x"<<int_to_hex_string(int_l)<<endl;
+        map<int,int>::iterator it_device = device_serial1.find(int_l);
+        if (it_device != device_serial1.end())
+        {
+            MWPC_number = 1;
+            plane_number = it_device->second;
+        }
+        else
+        {
+            MWPC_number = 2;
+            it_device = device_serial2.find(int_l);
+            if (it_device == device_serial2.end())
+            {
+                cout<<"error: device serial wasn't found in the map, exiting of parsing this file"<<endl;
+                return -3;
+            }
+            plane_number = it_device->second;
+        }
+        //cout<<"MWPC number: "<<MWPC_number<<". plane_number: "<<plane_number<<endl;
+
+        // M-Stream Subtype 0 - device_id and fragment_length
+        x = buffer[cur_word++];
+        unsigned int fragment_length = x & 0xFFFF;
+        //cout<<"fragment_length: "<<fragment_length<<endl;
+        unsigned int device_id = x >> 24;
+        //cout<<"device_id: 0x"<<int_to_hex_string(device_id)<<endl;
+
+        // M-Stream Subtype 0 - event (0:23 bits)
+        x = buffer[cur_word++];
+        unsigned int event_number = x & 0xFFFFFF;
+        //cout<<"event_number: "<<event_number<<endl;
+
+        // M-Stream Subtype 0 - trigger timestamps: nanoseconds (32-bit word) and then seconds (32-bit word), e.i. low the high timestamp
+        x = buffer[cur_word++];
+        //unsigned int timestamp_seconds = x;
+        //x = buffer[cur_word++];
+        //unsigned int timestamp_nanoseconds = x;
+        ULong64_t event_timestamp = x + (((ULong64_t)buffer[cur_word++]) << 32);
+        //ULong64_t event_timestamp = (((ULong64_t)x) << 32) + buffer[cur_word++];
+
+        vector<EventData*>::iterator it = fEventData->end();
+        EventData* pCurEvent = NULL;
+        int cnt = 0;
+        for (i = fEventData->size() - 1; i >= 0; i--, it--, cnt++)
+        {
+            pCurEvent = (*fEventData)[i];
+
+            if (pCurEvent->event_timestamp < event_timestamp)
+            {
+                pCurEvent = new EventData();
+                pCurEvent->event_timestamp = event_timestamp;
+
+                //if (i == (fEventData->size()-1))
+                //    fEventData->push_back(pCurEvent);
+                //else
+                fEventData->insert(it, pCurEvent);
+
+                break;
+            }
+
+            if (pCurEvent->event_timestamp == event_timestamp)
+                break;
+        }// for
+        if (i < 0)
+        {
+            pCurEvent = new EventData();
+            pCurEvent->event_timestamp = event_timestamp;
+
+            if (fEventData->size() == 0)
+                fEventData->push_back(pCurEvent);
+            else
+            {
+                if (*it != *(fEventData->begin()))
+                {
+                    cout<<"DATA ERROR: it != fEventData->begin()"<<endl;
+                    sleep(3);
+                }
+
+                fEventData->insert(it, pCurEvent);
+            }
+        }
+        if (cnt > max_event_diff)
+            max_event_diff = cnt;
+
+        // define vector for digits by MWPC and plane number
+        vector<BmnMwpcDigit*>* pDigitsPlane;
+        if (MWPC_number == 1)
+            pDigitsPlane = &pCurEvent->MWPC1Planes[plane_number-1];
+        else
+            pDigitsPlane = &pCurEvent->MWPC2Planes[plane_number-1];
+
+        // M-Stream data - searching for "1" bits - working only with 32-bit words ratio, can be generalized
+        unsigned int start_data = 12;
+        if ((fragment_length - start_data) % 16 != 0)
+        {
+            cout<<"data length isn't aligned with 4 32-bit word"<<endl;
+            return -4;
+        }
+        int time_bin = 1;   // starting from 1
+        int pos_bits = sizeof(unsigned int)*8 - 1, pos;
+        for (unsigned int ui = start_data; ui < fragment_length; ui += 16, time_bin++)
+        {
+            // 96 bit for every wire and 32 bit is empty (zero)
+            for (int j = 0; j < 3; j++)
+            {
+                x = buffer[cur_word++];
+                if (x == 0)
+                    continue;
+
+                pos = pos_bits;
+                while ((pos--) >= 0)
+                {
+                    if (CHECK_BIT(x, pos))
+                    {
+                        // starting number from 0
+                        int active_wire = j*32 + pos;
+
+                        //cout<<"time stamp: "<<event_timestamp<<", bin: "<<time_bin<<"; MWPC: "<<MWPC_number<<"; plane: "<<plane_number<<"; wire: "<<active_wire<<endl;
+                        //sleep(1);
+
+                        BmnMwpcDigit* pDigit = new BmnMwpcDigit(plane_number, active_wire, time_bin, -1);
+
+                        pDigitsPlane->push_back(pDigit);
+                    }
+                }
+            }
+            cur_word++;
+        }// for detector's wires
+
+        // skip M-Link CRC
+        //cur_word++;
+
+        //cout<<endl<<endl;
+    }// while not end of file
+
+    cout<<"exit of parsing file"<<" iterations count: "<<ind<<endl;
+    cout<<"event count: "<<fEventData->size()<<endl;
+    //cout<<"max_event_diff: "<<max_event_diff<<endl;
+    //sleep(1);
+
+    return 0;
+}
+
+//buffer - unsigned int array from file with HRB Raw Data Format 2.0
+//size - size of 'buffer' variable in words (unsigned int)
+//fEventData - vector with EventData objects
+int RawDataParser::ParseWaveBuffer(unsigned int* buffer, long size, vector<EventData*>* fEventData)
+{
+    unsigned char byte_hh;  //, byte_hl, byte_lh, byte_ll;
+    unsigned int int_h, int_l;
+    long cur_word = 0, i = 0;
+    //unsigned int max_diff = 0,  = 0;
+    cout<<"enter of parsing file"<<endl;
+    //sleep(1);
+    int max_event_diff = 0, ind = 0;
+    while (cur_word < size)
+    {
+        ind++;
+        // M-Link HEADER - frame type
+        unsigned int x = buffer[cur_word++];
+
+        // check sync word: 0x2A50
+        int_h = x >> 16;
+        if (int_h != 0x2A50)
+        {
+            cout<<"sync word error, should be 0x2A50, but it's equal to "<<int_h<<endl;
+            return -1;
+        }
+
+        // check frame type: 0x2A50 - stream data 2.0
+        int_l = x & 0xFFFF;
+        if (int_l != 0x2A50)
+        {
+            fputs("frame type error, should be 0x2A50", stderr);
+            return -2;
+        }
+
+        // M-Link HEADER - frame info
+        x = buffer[cur_word++];
+
+        unsigned int frame_length = x >> 16;
+        unsigned int frame_number = x & 0xFFFF;
+        cout<<"frame_length: "<<frame_length<<endl;
+        cout<<"frame_number: "<<frame_number<<endl;
+
+        // M-Stream SUBTYPE 0 Event Header (4 * DWORD)
+        // skip destination and source address
+        cur_word++;
+
+        // M-Stream Subtype 0 - device serial id (define plane number starting with 1)
+        x = buffer[cur_word++];
+        int_h = x >> 16;
+        int_l = x & 0xFFFF;
+        cout<<"device_serial: 0x"<<int_to_hex_string(int_h)<<int_to_hex_string(int_l)<<endl;
+
+        // M-Stream Subtype 0 - device_id and fragment_length
+        x = buffer[cur_word++];
+        unsigned int fragment_length = x & 0xFFFF;
+        cout<<"fragment_length: "<<fragment_length<<endl;
+        unsigned int device_id = x >> 24;
+        cout<<"device_id: 0x"<<int_to_hex_string(device_id)<<endl;
+
+        // M-Stream Subtype 0 - event (0:23 bits)
+        x = buffer[cur_word++];
+        unsigned int event_number = x & 0xFFFFFF;
+        cout<<"event_number: "<<event_number<<endl;
+
+        // M-Stream Subtype 0 - readout channels 31:0 bit mask
+        cur_word++;
+
+        // M-Stream Subtype 0 - readout channels 63:32 bit mask
+        cur_word++;
+
+
+
+
+        // M-Stream SUBTYPE 1 Event Header (4 * DWORD)
+
+
+/*
+        // M-Stream Subtype 0 - trigger timestamps: nanoseconds (32-bit word) and then seconds (32-bit word), e.i. low the high timestamp
+        x = buffer[cur_word++];
+        //unsigned int timestamp_seconds = x;
+        //x = buffer[cur_word++];
+        //unsigned int timestamp_nanoseconds = x;
+        ULong64_t event_timestamp = x + (((ULong64_t)buffer[cur_word++]) << 32);
+        //ULong64_t event_timestamp = (((ULong64_t)x) << 32) + buffer[cur_word++];
+
+        vector<EventData*>::iterator it = fEventData->end();
+        EventData* pCurEvent = NULL;
+        int cnt = 0;
+        for (i = fEventData->size() - 1; i >= 0; i--, it--, cnt++)
+        {
+            pCurEvent = (*fEventData)[i];
+
+            if (pCurEvent->event_timestamp < event_timestamp)
+            {
+                pCurEvent = new EventData();
+                pCurEvent->event_timestamp = event_timestamp;
+
+                //if (i == (fEventData->size()-1))
+                //    fEventData->push_back(pCurEvent);
+                //else
+                fEventData->insert(it, pCurEvent);
+
+                break;
+            }
+
+            if (pCurEvent->event_timestamp == event_timestamp)
+                break;
+        }// for
+        if (i < 0)
+        {
+            pCurEvent = new EventData();
+            pCurEvent->event_timestamp = event_timestamp;
+
+            if (fEventData->size() == 0)
+                fEventData->push_back(pCurEvent);
+            else
+            {
+                if (*it != *(fEventData->begin()))
+                {
+                    cout<<"DATA ERROR: it != fEventData->begin()"<<endl;
+                    sleep(3);
+                }
+
+                fEventData->insert(it, pCurEvent);
+            }
+        }
+        if (cnt > max_event_diff)
+            max_event_diff = cnt;
+
+        // define vector for digits by MWPC and plane number
+        vector<BmnMwpcDigit*>* pDigitsPlane;
+        if (MWPC_number == 1)
+            pDigitsPlane = &pCurEvent->MWPC1Planes[plane_number-1];
+        else
+            pDigitsPlane = &pCurEvent->MWPC2Planes[plane_number-1];
+
+        // M-Stream data - searching for "1" bits - working only with 32-bit words ratio, can be generalized
+        unsigned int start_data = 12;
+        if ((fragment_length - start_data) % 16 != 0)
+        {
+            cout<<"data length isn't aligned with 4 32-bit word"<<endl;
+            return -4;
+        }
+        int time_bin = 1;   // starting from 1
+        int pos_bits = sizeof(unsigned int)*8 - 1, pos;
+        for (unsigned int i = start_data; i < fragment_length; i += 16, time_bin++)
+        {
+            // 96 bit for every wire and 32 bit is empty (zero)
+            for (int j = 0; j < 3; j++)
+            {
+                x = buffer[cur_word++];
+                if (x == 0)
+                    continue;
+
+                pos = pos_bits;
+                while ((pos--) >= 0)
+                {
+                    if (CHECK_BIT(x, pos))
+                    {
+                        // starting number from 0
+                        int active_wire = j*32 + pos;
+
+                        //cout<<"time stamp: "<<event_timestamp<<", bin: "<<time_bin<<"; MWPC: "<<MWPC_number<<"; plane: "<<plane_number<<"; wire: "<<active_wire<<endl;
+                        //sleep(1);
+
+                        BmnMwpcDigit* pDigit = new BmnMwpcDigit(plane_number, active_wire, time_bin, -1);
+
+                        pDigitsPlane->push_back(pDigit);
+                    }
+                }
+            }
+            cur_word++;
+        }// for detector's wires
+*/
+        // skip M-Link CRC
+        //cur_word++;
+
+        //cout<<endl<<endl;
+    }// while not end of file
+
+    cout<<"exit of parsing file"<<" iterations count: "<<ind<<endl;
+    cout<<"event count: "<<fEventData->size()<<endl;
+    //cout<<"max_event_diff: "<<max_event_diff<<endl;
+    //sleep(1);
+
+    return 0;
+}
+
+void RawDataParser::GenerateMWPCFileNames(char* raw_file_name_begin, map<int, int>* p_device_serial, TString* mwpc_file_names)
+{
+    map<int,int>::iterator it_planes = p_device_serial->begin();
+
+    // cycle for six plane (six device identificator)
+    for (int i = 1;  i <= p_device_serial->size(); i++, it_planes++)
+    {
+        mwpc_file_names[i-1] = raw_file_name_begin;
+        mwpc_file_names[i-1] += int_to_hex_string(it_planes->first);
+        mwpc_file_names[i-1] += ".dat";
+        //cout<<"MWPC: "<<mwpc_file_names[i-1]<<endl;
+    }
+}
+
+void RawDataParser::ParseHRBFiles(vector<EventData*>* pEventData, TString* raw_file_names, long* lStart)
+{
+     // buffer with 4-bytes words
+     unsigned int* buffer;
+     long lSize, curStart;
+     size_t size;
+     FILE* pRawFile;
+
+     for (int mwpc_iter = 1; mwpc_iter < 3; mwpc_iter++)
+     {
+         // cycle for six plane (six device identificator)
+         for (int i = 1;  i <= 6; i++)
+         {
+             pRawFile = fopen(replace_vmc_path_linux(raw_file_names[(mwpc_iter-1)*6 + (i-1)].Data()).data(), "rb");
+             if (pRawFile == NULL)
+             {
+                 fprintf(stderr,"Error opening file (%s): %s\n", strerror(errno), raw_file_names[(mwpc_iter-1)*6 + (i-1)].Data());
+                 return;
+             }
+
+             // obtain file size:
+             fseek(pRawFile, 0, SEEK_END);
+             lSize = ftell(pRawFile);
+
+             if (lStart == NULL)
+                 curStart = 0;
+             else
+                 curStart = lStart[(mwpc_iter-1)*6 + (i-1)];
+
+             if (lSize <= curStart)
+             {
+                 fclose(pRawFile);
+                 return;
+             }
+
+             fseek(pRawFile, curStart, SEEK_SET);
+
+             // allocate memory containing new tail of file:
+             buffer =  new unsigned int[(lSize-curStart) / 4];
+             if (buffer == NULL)
+             {
+                 fputs("Memory error", stderr);
+                 fclose(pRawFile);
+                 return;
+             }
+
+             // copy the file into the buffer:
+             size = fread(buffer, 4, (lSize-curStart)/4, pRawFile);
+             if (size != (lSize-curStart)/4)
+             {
+                 fputs("Reading error", stderr);
+                 free(buffer);
+                 fclose(pRawFile);
+                 return;
+             }
+
+             // the whole file is now loaded in the memory 'buffer'
+             fclose(pRawFile);
+
+             //parse the data
+             int result_error = ParseHRB2Buffer(buffer, (lSize-curStart)/4, pEventData);
+
+             free(buffer);
+
+             if (lStart != NULL)
+                lStart[(mwpc_iter-1)*6 + (i-1)] = lSize;
+         }// for cycle for six plane (six device identificator)
+     }// for cycle for MWPC detectors
+
+     return;
+}
diff --git a/eventdisplay/raw/RawDataParser.h b/eventdisplay/raw/RawDataParser.h
new file mode 100644
index 0000000..958f2b6
--- /dev/null
+++ b/eventdisplay/raw/RawDataParser.h
@@ -0,0 +1,69 @@
+#ifndef RAWDATAPARSER_H
+#define RAWDATAPARSER_H
+
+#include "BmnMwpcDigit.h"
+
+#include <map>
+
+class EventData : public TObject
+{
+  public:
+    ULong64_t event_timestamp;
+
+    vector<BmnMwpcDigit*> MWPC1Planes[6];
+    vector<BmnMwpcDigit*> MWPC2Planes[6];
+
+    EventData()
+    {
+    }
+
+    EventData(const EventData& event_data)
+    {
+        //uiEventNumber = event_data.uiEventNumber;
+        event_timestamp = event_data.event_timestamp;
+
+        for (int i = 0; i < 6; i++)
+            MWPC1Planes[i] = event_data.MWPC1Planes[i];
+
+        for (int i = 0; i < 6; i++)
+            MWPC2Planes[i] = event_data.MWPC2Planes[i];
+    }
+
+    virtual ~EventData() {}
+
+    ClassDef(EventData, 0) //EventData
+};
+
+class RawDataParser
+{
+  public:
+    //map with device identificator corresponding plane number (starting with 1)
+    map<int, int> device_serial;     // { {0x1A8D, 1}, {0x2950, 2}, {0x3043, 3}, {0x304E, 4}, {0x4514, 5}, {0x45DF, 6} };
+    map<int, int> device_serial1;    // { {0x3F8B, 1}, {0x2950, 2}, {0x4514, 3}, {0x4504, 4}, {0x3043, 5}, {0x304E, 6} };
+    map<int, int> device_serial2;    // { {0x47CB, 1}, {0x2A79, 2}, {0x3F1D, 3}, {0x4513, 4}, {0x3F97, 5}, {0x2FFF, 6} };
+
+    /** Default constructor **/
+    RawDataParser();
+    /** Destructor **/
+    virtual ~RawDataParser();
+
+    //buffer - unsigned int array from file with HRB Raw Data Format 1.0 (MWPC)
+    //size - size of 'buffer' variable in words (unsigned int)
+    //fEventData - vector with EventData objects
+    int ParseHRB1Buffer(unsigned int* buffer, long size, vector<EventData*>* fEventData);
+
+    //buffer - unsigned int array from file with HRB Raw Data Format 2.0 (MWPC)
+    //size - size of 'buffer' variable in words (unsigned int)
+    //fEventData - vector with EventData objects
+    int ParseHRB2Buffer(unsigned int* buffer, long size, vector<EventData*>* fEventData);
+
+    //buffer - unsigned int array from file with MStreamWaveformDigitizer Format (ZDC + ECAL)
+    //size - size of 'buffer' variable in words (unsigned int)
+    //fEventData - vector with EventData objects
+    int ParseWaveBuffer(unsigned int* buffer, long size, vector<EventData*>* fEventData);
+
+    void GenerateMWPCFileNames(char* raw_file_name_begin, map<int, int>* device_serial, TString* mwpc_file_names);
+    void ParseHRBFiles(vector<EventData*>* pEventData, TString* raw_file_names, long* lStart = NULL);
+};
+
+#endif // RAWDATAPARSER_H
diff --git a/eventdisplay/raw/RawMWPCDigitDraw.cxx b/eventdisplay/raw/RawMWPCDigitDraw.cxx
new file mode 100644
index 0000000..10e3301
--- /dev/null
+++ b/eventdisplay/raw/RawMWPCDigitDraw.cxx
@@ -0,0 +1,156 @@
+// -------------------------------------------------------------------------
+// -----                        RawMWPCDigitDraw source file           -----
+// -----                                                               -----
+// -------------------------------------------------------------------------
+#include "RawMWPCDigitDraw.h"
+
+#include "TEveManager.h"
+#include "TEveTreeTools.h"
+#include "TString.h"
+
+#include <iostream>
+using namespace std;
+
+// -----   Default constructor   -------------------------------------------
+RawMWPCDigitDraw::RawMWPCDigitDraw()
+  : FairTask("RawMWPCDigitDraw", 0),
+    fVerbose(0),
+    fEventManager(NULL),
+    fq(NULL),
+    fColor(0),
+    fStyle(0)
+{
+    pEventData = new vector<EventData*>();
+}
+
+// -----   Standard constructor   ------------------------------------------
+RawMWPCDigitDraw::RawMWPCDigitDraw(const char* name, Color_t color ,Style_t mstyle,Int_t iVerbose)
+  : FairTask(name, iVerbose),
+    fVerbose(iVerbose),
+    fEventManager(NULL),
+    fq(NULL),
+    fColor(color),
+    fStyle(mstyle)
+{
+    pEventData = new vector<EventData*>();
+}
+
+// -------------------------------------------------------------------------
+InitStatus RawMWPCDigitDraw::Init()
+{
+    if (fVerbose > 1)
+        cout<<"RawMWPCDigitDraw::Init()"<<endl;
+
+    // read source files and generate vector of EventData objects
+    RawDataParser raw_parser;
+
+    TString* mwpc_names = new TString[12];
+    raw_parser.GenerateMWPCFileNames(source_file_name, &raw_parser.device_serial1, mwpc_names);
+    raw_parser.GenerateMWPCFileNames(source_file_name, &raw_parser.device_serial2, &mwpc_names[6]);
+
+    raw_parser.ParseHRBFiles(pEventData, mwpc_names);
+
+    delete[] mwpc_names;
+
+    fEventManager = FairEventManager::Instance();
+    if (fVerbose > 2)
+        cout<<"RawMWPCDigitDraw::Init() get instance of FairEventManager "<<endl;
+
+    //cout<<endl<<"fEntryCount "<<fEventManager->fEntryCount<<" Event Count "<<pEventData->size()<<endl;
+    if (fEventManager->fEntryCount == 0)
+        fEventManager->fEntryCount = pEventData->size();
+    else
+        fEventManager->fEntryCount = TMath::Min(fEventManager->fEntryCount, (Long64_t)pEventData->size());
+
+    return kSUCCESS;
+}
+
+void RawMWPCDigitDraw::Exec(Option_t* option)
+{
+    if (IsActive())
+    {
+        Reset();
+
+        Int_t event_number = fEventManager->GetCurrentEvent();
+
+        // convert EventData object to vector of coordinates
+        if (event_number >= pEventData->size())
+        {
+            cout<<"Programming Error: event_number >= EventData vector size : "<<event_number<<" >= "<<pEventData->size()<<endl;
+            return;
+        }
+
+        EventData* curEvent = (*pEventData)[event_number];
+        cout<<"Event processing: "<<event_number<<endl;
+
+        RawDataConverter raw_converter;
+        vector<TVector3*> event_hits = raw_converter.MWPCEventToGeoVector(curEvent);
+
+        Int_t npoints = event_hits.size();
+        cout<<"Point vector size: "<<npoints<<endl;
+
+        TEvePointSet* q = new TEvePointSet(GetName(), npoints, TEvePointSelectorConsumer::kTVT_XYZ);
+        q->SetOwnIds(kTRUE);
+        q->SetMarkerColor(fColor);
+        q->SetMarkerSize(1.5);
+        q->SetMarkerStyle(fStyle);
+
+        for (Int_t i = 0; i < npoints; i++)
+        {
+            TVector3* vec = event_hits.at(i);
+            if (vec != 0)
+            {
+                q->SetNextPoint(vec->X(),vec->Y(), vec->Z());
+                q->SetPointId(new TNamed(Form("Point %d", i),""));
+            }
+        }
+
+        if (fEventManager->EveRecoPoints == NULL)
+        {
+            fEventManager->EveRecoPoints = new TEveElementList("Reco points");
+            gEve->AddElement(fEventManager->EveRecoPoints, fEventManager);
+            fEventManager->EveRecoPoints->SetRnrState(kFALSE);
+        }
+
+        gEve->AddElement(q, fEventManager->EveRecoPoints);
+
+        gEve->Redraw3D(kFALSE);
+
+        fq = q;
+    }//if IsActive()
+}
+
+TObject* RawMWPCDigitDraw::GetValue(TObject* obj,Int_t i)
+{
+    return new TNamed(Form("Point %d", i),"");
+}
+
+// -----   Destructor   ----------------------------------------------------
+RawMWPCDigitDraw::~RawMWPCDigitDraw()
+{
+    delete pEventData;
+}
+
+// -------------------------------------------------------------------------
+void RawMWPCDigitDraw::SetParContainers()
+{
+}
+
+// -------------------------------------------------------------------------
+/** Action after each event**/
+void RawMWPCDigitDraw::Finish()
+{
+}
+
+// -------------------------------------------------------------------------
+void RawMWPCDigitDraw::Reset()
+{
+    if (fq != 0)
+    {
+        fq->Reset();
+
+        gEve->RemoveElement(fq, fEventManager->EveRecoPoints);
+    }
+}
+
+ClassImp(RawMWPCDigitDraw);
diff --git a/eventdisplay/raw/RawMWPCDigitDraw.h b/eventdisplay/raw/RawMWPCDigitDraw.h
new file mode 100644
index 0000000..3faa18a
--- /dev/null
+++ b/eventdisplay/raw/RawMWPCDigitDraw.h
@@ -0,0 +1,68 @@
+// -------------------------------------------------------------------------
+// -----                      RawMWPCDigitDraw header file             -----
+// -----                                                               -----
+// -------------------------------------------------------------------------
+
+
+#ifndef RAWMWPCDIGITDRAW_H
+#define RAWMWPCDIGITDRAW_H
+
+#include "RawDataConverter.h"
+
+#include "FairTask.h"
+#include "FairEventManager.h"
+
+#include "TEvePointSet.h"
+#include "TObject.h"
+#include "TVector3.h"
+
+#include <vector>
+
+class RawMWPCDigitDraw : public FairTask
+{
+  public:
+    /** Default constructor **/
+    RawMWPCDigitDraw();
+
+
+    /** Standard constructor
+    *@param name        Name of task
+    *@param iVerbose    Verbosity level
+    **/
+    RawMWPCDigitDraw(const char* name, Color_t color ,Style_t mstyle, Int_t iVerbose = 1);
+
+    /** Destructor **/
+    virtual ~RawMWPCDigitDraw();
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t iVerbose) { fVerbose = iVerbose; }
+    /** Executed task **/
+    virtual void Exec(Option_t* option);
+    void Reset();
+
+    char* source_file_name;  //!
+
+  protected:
+    //TVector3 GetVector(TObject* obj);
+    TObject* GetValue(TObject* obj,Int_t i);
+
+    Int_t   fVerbose;       //  Verbosity level
+    virtual void SetParContainers() ;
+    virtual InitStatus Init();
+    /** Action after each event**/
+    virtual void Finish();
+
+    FairEventManager* fEventManager;   //!
+    TEvePointSet* fq;    //!
+    Color_t fColor; //!
+    Style_t fStyle; //!
+    vector<EventData*>* pEventData; //!
+
+  private:
+    RawMWPCDigitDraw(const RawMWPCDigitDraw&);
+    RawMWPCDigitDraw& operator=(const RawMWPCDigitDraw&);
+
+    ClassDef(RawMWPCDigitDraw,1);
+};
+
+#endif
diff --git a/eventdisplay/raw/function_set.h b/eventdisplay/raw/function_set.h
new file mode 100644
index 0000000..2036a53
--- /dev/null
+++ b/eventdisplay/raw/function_set.h
@@ -0,0 +1,479 @@
+//============================================================================
+// Name        : function_set.h
+// Author      : Konstantin Gertsenberger (gertsen@jinr.ru)
+// Description : set of common C++ functions
+// Version     : 1.00
+//============================================================================
+
+#ifndef FUNCTION_SET_H
+#define FUNCTION_SET_H
+
+// C++ includes
+#include <unistd.h>
+#include <iostream>
+#include <cstring>
+#include <string>
+#include <stdlib.h>
+#include <stdio.h>
+#include <sstream>
+#include <ctime>
+//#include <sys/types.h>
+#include <sys/stat.h>
+
+using namespace std;
+
+/* declarations */
+
+/* OS FUNCTIONS */
+// execute system command in shell (bash)
+int system_command_linux(string aCommand, string& result);
+// change tilda symbol on HOME in linux path
+string replace_home_symbol_linux(string path);
+// change $VMCWORKDIR symbol in linux path
+string replace_vmc_path_linux(string path);
+// get processor core count on this machine
+int get_linux_processor_count();
+// get maximum available processor count on Sun Grid Engine system
+int get_sge_processor_count();
+// get maximum available processor count on Torque batch system
+int get_torque_processor_count();
+
+/* GLOBAL APPLICATION FUNCTIONS */
+// get application name in linux
+string get_app_name_linux();
+// get aplication directory (path without file name) in linux
+string get_app_dir_linux();
+
+/* NUMBER FUNCTIONS */
+// check bit in 'variable' at 'position'
+#define CHECK_BIT(variable,position) ((variable) & (1ULL<<(position)))
+
+/* STRING FUNCTIONS */
+// convert integer number to string
+string convert_int_to_string(int number);
+// convert integer (hexadecimal value) to string with hexadecimal presentation without "0x"
+string int_to_hex_string(int int_number);
+// convert string with hexadecimal presentation without "0x" to integer
+int hex_string_to_int(string hex_string);
+// is string an integer number?
+bool is_string_number(const string& s);
+// convert array of chars to the new lowercase array
+char* convert_pchar_to_lowercase_new(char* input_char_array);
+// replace string 's' by string 'd' in text
+void replace_string_in_text(string &text, string s, string d);
+// return string without leading and trailing spaces and tabs
+string trim(const string& str, const string& whitespace = " \t\r");
+// return string changing whitespaces and tabs by single whitespace
+string reduce(const string& str, const string& fill = " ", const string& whitespace = " \t\r");
+
+/*   DIR & FILE FUNCTIONS   */
+// check directory exists: 0 - not exists, 1 - exists, -2 - cannot access
+int check_directory_exist(const char* path);
+// check and create directory if not exists: 0 - not existed before, 1 - existed, -1 - errno error, -2 - cannot access
+int create_directory(const char* path);
+// get file name without extension from a path
+string get_file_name(string path);
+// get file name with extension from path
+string get_file_name_with_ext(string path);
+
+/*  TIME FUNCTIONS  */
+// get current date as string
+string get_current_date();
+
+
+#ifndef ONLY_DECLARATIONS
+
+
+/*              */
+/*              */
+/* OS FUNCTIONS */
+/*              */
+/*              */
+
+// execute system command in shell (bash)
+int system_command_linux(string aCommand, string& result)
+{
+    FILE* f;
+    if (!(f = popen(aCommand.c_str(), "r")))
+    {
+    	cout<<"system_command_linux error: popen failed"<<endl;
+        return 1;
+    }
+
+    const int BUFSIZE = 4096;
+    char buf[BUFSIZE];
+    if (fgets(buf,BUFSIZE,f) != NULL)
+    	result = buf;
+
+    pclose(f);
+    return 0;
+}
+
+// change tilda symbol on HOME in linux path
+string replace_home_symbol_linux(string path)
+{
+    size_t np = path.find_first_of('~');
+    if (np != string::npos)
+    {
+        bool isNewPath = false;
+        char* pPath = getenv("HOME");
+        if (pPath == NULL)
+        {
+            pPath = new char[2];
+            pPath[0] = '/';
+            pPath[1] = '\0';
+            isNewPath = true;
+        }
+
+        do
+        {
+        	path.erase(np, 1);
+        	path.insert(np, pPath);
+            np = path.find_first_of('~');
+        } while (np != string::npos);
+
+        if (isNewPath)
+            delete[] pPath;
+    }
+
+    return path;
+}
+
+// change $VMCWORKDIR symbol in linux path
+string replace_vmc_path_linux(string path)
+{
+    char* pPath = getenv("VMCWORKDIR");
+    bool isNewPath = false;
+    if (pPath == NULL)
+    {
+        pPath = new char[2];
+        pPath[0] = '/';
+        pPath[1] = '\0';
+        isNewPath = true;
+    }
+
+    size_t found;
+    while ((found = path.find("$VMCWORKDIR")) != string::npos)
+    {
+        path.replace(found, 11, pPath);
+    }
+
+    if (isNewPath)
+        delete[] pPath;
+
+    return path;
+}
+
+// get processor core count on this machine
+int get_linux_processor_count()
+{
+    return sysconf(_SC_NPROCESSORS_ONLN);
+}
+
+// get maximum available processor count on Sun Grid Engine system
+int get_sge_processor_count()
+{
+    int proc_count = 0;
+
+    const int MAX_BUFFER = 255;
+    char buffer[MAX_BUFFER];
+
+    // define count of processors for all.q queue
+    string data, strDiff;
+    FILE* stream = popen("export SGE_SINGLE_LINE=1; qconf -sq all.q | grep slots", "r");
+    while (fgets(buffer, MAX_BUFFER, stream) != NULL)
+        data.append(buffer);
+    pclose(stream);
+
+    size_t found = data.find("="), found2 = string::npos;
+    while (found != string::npos)
+    {
+        found2 = data.find("]", found);
+        strDiff = data.substr(found+1, found2 - found - 1);
+        proc_count += atoi(strDiff.c_str());
+        strDiff.clear();
+
+        found = data.find("=", found2);
+    }
+
+    data.clear();
+
+    cout<<"SGE processor count: "<<proc_count<<endl;
+
+    return proc_count;
+}
+
+// get maximum available processor count on Torque batch system
+int get_torque_processor_count()
+{
+    int proc_count = 0;
+
+    const int MAX_BUFFER = 255;
+    char buffer[MAX_BUFFER];
+
+    // define count of processors for all.q queue
+    string data, strDiff;
+    FILE* stream = popen("qconf -sq all.q | grep slots", "r");
+    while (fgets(buffer, MAX_BUFFER, stream) != NULL)
+        data.append(buffer);
+    pclose(stream);
+
+    size_t found = data.find("="), found2 = string::npos;
+    while (found != string::npos)
+    {
+        found2 = data.find("]", found);
+        strDiff = data.substr(found+1, found2 - found - 1);
+        proc_count += atoi(strDiff.c_str());
+        strDiff.clear();
+
+        found = data.find("=", found2);
+    }
+
+    data.clear();
+
+    return proc_count;
+}
+
+
+/*                              */
+/*				*/
+/* GLOBAL APPLICATION FUNCTIONS */
+/*				*/
+/*                              */
+
+// get application name in linux
+string get_app_name_linux()
+{
+    pid_t procpid = getpid();
+    stringstream toCom;
+    toCom << "cat /proc/" << procpid << "/comm";
+    string fRes="";
+    system_command_linux(toCom.str(), fRes);
+    size_t last_pos = fRes.find_last_not_of(" \n\r\t") + 1;
+    if (last_pos != string::npos)
+        fRes.erase(last_pos);
+
+    return fRes;
+}
+
+// get aplication directory (path without file name) in linux
+string get_app_dir_linux()
+{
+    pid_t procpid = getpid();
+    string appName = get_app_name_linux();
+    stringstream command;
+    command <<  "readlink /proc/" << procpid << "/exe | sed \"s/\\(\\/" << appName << "\\)$//\"";
+    string fRes;
+    system_command_linux(command.str(),fRes);
+
+    // remove '\n' from end of the string and add final '/'
+    fRes = fRes.erase(fRes.length()-1, 1);
+    fRes.push_back('/');
+
+    return fRes;
+}
+
+
+/*                  */
+/*                  */
+/* NUMBER FUNCTIONS */
+/*                  */
+/*                  */
+
+
+
+/*                  */
+/*                  */
+/* STRING FUNCTIONS */
+/*                  */
+/*                  */
+
+// convert integer number to string
+string convert_int_to_string(int number)
+{
+    stringstream ss;
+    ss<<number;
+    return ss.str();
+}
+
+// convert integer (hexadecimal value) to string with hexadecimal presentation without "0x"
+string int_to_hex_string(int int_number)
+{
+    stringstream stream;
+    stream<<std::hex<<int_number;
+    return stream.str();
+}
+
+// convert string with hexadecimal presentation without "0x" to integer
+int hex_string_to_int(string hex_string)
+{
+    int x;
+    stringstream stream;
+    stream<<std::hex<<hex_string;
+    stream>>x;
+    return x;
+}
+
+// is string an integer number?
+bool is_string_number(const string& s)
+{
+    string::const_iterator it = s.begin();
+    while (it != s.end() && std::isdigit(*it)) ++it;
+    return !s.empty() && it == s.end();
+}
+
+// convert array of chars to the new lowercase array
+char* convert_pchar_to_lowercase_new(char* input_char_array)
+{
+    if (input_char_array == NULL)
+        return NULL;
+
+    const int length = strlen(input_char_array);	// get the length of the text
+    char* lower = new char[length + 1];		// allocate 'length' bytes + 1 (for null terminator) and cast to char*
+    lower[length] = 0;						// set the last byte to a null terminator
+
+    // copy all character bytes to the new buffer using tolower
+    for( int i = 0; i < length; i++ )
+        lower[i] = tolower(input_char_array[i]);
+
+
+    return lower;
+}
+
+// replace string 's' by string 'd' in text
+void replace_string_in_text(string &text, string old_substring, string new_substring)
+{
+    int start = -1;
+
+    do
+    {
+        start = text.find(old_substring, start + 1);
+        if (start > -1)
+            text.replace(start, old_substring.length(), new_substring.c_str());
+    }
+    while (start > -1);
+}
+
+// return string without leading and trailing spaces and tabs
+string trim(const string& str, const string& whitespace)
+{
+    size_t strBegin = str.find_first_not_of(whitespace);
+    if (strBegin == string::npos)
+        return ""; // no content
+
+    size_t strEnd = str.find_last_not_of(whitespace);
+    size_t strRange = strEnd - strBegin + 1;
+
+    return str.substr(strBegin, strRange);
+}
+
+// return string changing whitespaces and tabs by single whitespace
+string reduce(const string& str, const string& fill, const string& whitespace)
+{
+    // trim first
+    string result = trim(str, whitespace);
+
+    // replace sub ranges
+    size_t beginSpace = result.find_first_of(whitespace);
+    while (beginSpace != string::npos)
+    {
+        size_t endSpace = result.find_first_not_of(whitespace, beginSpace);
+        size_t range = endSpace - beginSpace;
+
+        result.replace(beginSpace, range, fill);
+
+        size_t newStart = beginSpace + fill.length();
+        beginSpace = result.find_first_of(whitespace, newStart);
+    }
+
+    return result;
+}
+
+
+/*                          */
+/*                          */
+/*   DIR & FILE FUNCTIONS   */
+/*                          */
+/*                          */
+
+// check directory exists: 0 - not exists, 1 - exists, -2 - cannot access
+int check_directory_exist(const char* path)
+{
+    struct stat info;
+
+    if (stat(path, &info) != 0)
+        return -2;
+    else if (info.st_mode & S_IFDIR)
+        return 1;
+    else
+        return 0;
+}
+
+// check and create directory if not exists: 0 - not existed before, 1 - existed, -1 - errno error, -2 - cannot access
+int create_directory(const char* path)
+{
+    struct stat info;
+
+    if (stat(path, &info) != 0)
+        return -2;
+    else if (info.st_mode & S_IFDIR)
+        return 1;
+    else
+    {
+        int status = mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
+        return status;
+    }
+}
+
+// get file name without extension from a path
+string get_file_name(string path)
+{
+    // Remove directory if present.
+    size_t last_slash_idx = path.find_last_of("/");
+    if (string::npos != last_slash_idx)
+        path.erase(0, last_slash_idx + 1);
+
+    // Remove extension if present.
+    size_t period_idx = path.rfind('.');
+    if (string::npos != period_idx)
+        path.erase(period_idx);
+
+    return path;
+}
+
+// get file name with extension from path
+string get_file_name_with_ext(string path)
+{
+    // Remove directory if present.
+    size_t last_slash_idx = path.find_last_of("/");
+    if (string::npos != last_slash_idx)
+        path.erase(0, last_slash_idx + 1);
+
+    return path;
+}
+
+
+/*                  */
+/*                  */
+/*  TIME FUNCTIONS  */
+/*                  */
+/*                  */
+
+// get current date as string
+string get_current_date()
+{
+    time_t rawtime;
+    time(&rawtime);
+
+    struct tm* timeinfo;
+    timeinfo = localtime(&rawtime);
+
+    char buffer[80];
+    strftime(buffer, 80, "%d-%m-%Y", timeinfo);
+    string str(buffer);
+
+    return str;
+}
+
+#endif /* ONLY_DECLARATIONS */
+#endif /* FUNCTION_SET_H */
diff --git a/eventdisplay/tdaq/BmnEventMonitor.cxx b/eventdisplay/tdaq/BmnEventMonitor.cxx
new file mode 100755
index 0000000..5abd65d
--- /dev/null
+++ b/eventdisplay/tdaq/BmnEventMonitor.cxx
@@ -0,0 +1,230 @@
+////////////////////////////////////////////
+//    BmnEventMonitor.cxx
+//    BM@N Event Monitoring Task implementation
+//    Konstantin Gertsenberger
+//    Created: Sep. 28 2016
+////////////////////////////////////////////
+
+#include <BmnEventMonitor.h>
+
+#include <signal.h>
+#include <iostream>
+
+using namespace std;
+
+int ReceivedSignal = 0;
+void signal_handler(int sig) { ReceivedSignal = sig; }
+
+BmnEventMonitor::BmnEventMonitor()
+{
+    strPartitionName = "test";
+    strSamplingType = "aaa";
+    strSamplingName = "bbb";
+    iVerbose = 0;
+
+    events = 10000;
+    dispersion = false;
+    repetitions = 1;
+    buffer_size = 100;
+    async = 0;
+    timeout = 10000;
+    wait = 10000;
+}
+
+BmnEventMonitor::BmnEventMonitor(TString partition_name, TString sampling_type, TString sampling_name, Int_t verbose)
+{
+    strPartitionName = partition_name;
+    strSamplingType = sampling_type;
+    strSamplingName = sampling_name;
+    iVerbose = verbose;
+
+    events = 10000;
+    dispersion = false;
+    repetitions = 1;
+    buffer_size = 100;
+    async = 0;
+    timeout = 10000;
+    wait = 10000;
+}
+
+int BmnEventMonitor::Exec()
+{
+    // initialize IPC
+    try
+    {
+        list< pair < string, string > > list_arg;
+        //IPCCore::init(list_arg);
+    }
+    catch(daq::ipc::Exception& ex)
+    {
+        ers::fatal(ex);
+    }
+
+    CmdArgInt		lvl1_type ('L', "lvl1-type", "type", "lvl1_trigger type (default -1)" );
+    CmdArgIntList	lvl1_bits ('B', "lvl1-bits", "bits", "non-zero bits positions in the LVL1 bit pattern", CmdArg::isLIST );
+    CmdArgBool		lvl1_bits_logic ('l', "lvl1-bits-logic", "logic attribute for the LVL1 bit pattern , AND if given OR otherwise");
+    CmdArgInt		lvl1_bits_origin ('o', "lvl1-bits-origin", "origin", "origin of the LVL1 bit pattern, 0 - BEFORE_PRESCALE\n"
+                                      " 1 - AFTER_PRESCALE, 2 - AFTER_VETO (default)" );
+    CmdArgInt		status_word 	('H', "header-word", "word", "status word (default 0 )");
+    CmdArgStr		stream_type 	('T', "stream-type", "stream-type", "stream type name" );
+    CmdArgStrList	stream_names	('N', "stream-names", "stream-names", "list of stream names", CmdArg::isLIST );
+    CmdArgBool		stream_logic	('S', "stream logic", "logic attribute for the stream tags, AND if given OR otherwise");
+
+    lvl1_type = -1;
+    status_word = 0;
+    lvl1_bits_origin = 2;
+    stream_type = "";
+
+    vector<unsigned short> L1_bits;
+    for (size_t i = 0; i < lvl1_bits.count(); i++)
+        L1_bits.push_back(lvl1_bits[i]);
+
+    vector<string> STREAM_names;
+    for (size_t i = 0; i < stream_names.count(); i++)
+        STREAM_names.push_back((const char*)stream_names[i]);
+
+    emon::Logic L1_logic = !(lvl1_bits.flags() && CmdArg::GIVEN) ? emon::logic::IGNORE
+                                                           : (lvl1_bits_logic.flags() && CmdArg::GIVEN) ? emon::logic::AND : emon::logic::OR;
+    emon::Logic STREAM_logic = !(stream_type.flags() && CmdArg::GIVEN) ? emon::logic::IGNORE
+                                                                 : (stream_logic.flags() && CmdArg::GIVEN) ? emon::logic::AND : emon::logic::OR;
+
+    /*emon::SelectionCriteria criteria(emon::L1TriggerType((unsigned char)(int)lvl1_type, !(lvl1_type.flags() && CmdArg::GIVEN)),
+                                        emon::SmartBitValue(L1_bits, L1_logic, (emon::Origin)(int)lvl1_bits_origin),
+                                        emon::SmartStreamValue((const char*)stream_type, STREAM_names, STREAM_logic),
+                                        emon::StatusWord(status_word, !(status_word.flags() && CmdArg::GIVEN)));
+*/emon::SelectionCriteria criteria;
+    vector<string> address_names;
+    address_names.push_back((const char *)strSamplingName.Data());
+
+    emon::SamplingAddress address((const char *)strSamplingType.Data(), address_names);
+
+    IPCPartition partition(strPartitionName);
+
+    signal(SIGINT, signal_handler);
+    signal(SIGTERM, signal_handler);
+
+    unique_ptr<emon::EventIterator> it;
+    for (int i = 0; i < repetitions; i++)
+    {
+        while (!ReceivedSignal)
+        {
+            try
+            {
+                // Connect to the samplers
+                it.reset(new emon::EventIterator(partition, address, criteria, buffer_size, dispersion));
+                break;
+            }
+            catch (emon::Exception& ex)
+            {
+                ers::error(ex);
+                if (wait == 0) return 1;
+            }
+
+            usleep(wait * 1000);
+        }
+        ERS_LOG("Monitoring Task started");
+
+        // Start the timer
+        OWLTimer timer;
+        timer.start( );
+
+        int eventCount = 0;
+        while (eventCount < events)
+        {
+            if (ReceivedSignal)
+            {
+                cout << "Received signal " << ReceivedSignal << ", exiting ... " << endl;
+                break;
+            }
+
+            emon::Event event;
+            // wait some time to simulate event processing in our sample application
+            try
+            {
+                // retrieve the event from the buffer, this either blocks (when async == 0)
+                // or it will throw NoMoreEvents (when async == 1)
+                // you can pass a timeout in milliseconds when in synchronous mode
+                // after the timeout, NoMoreEvents will be thrown
+                if (iVerbose > 1)
+                {
+                    if (async)
+                        clog<<"invoking tryNextEvent()...";
+                    else
+                        clog<<"invoking nextEvent("<<timeout<<")... ";
+                }
+
+                if (async)
+                    event = it->tryNextEvent();
+                else
+                    event = it->nextEvent(timeout);
+
+                if (iVerbose > 1)
+                    cout<<"done"<<endl;
+            }
+            catch (emon::NoMoreEvents& ex)
+            {
+                // output only when in synchronous case, because in asynchronous mode this will happen way too often!
+                if (!async)
+                    ers::warning(ex);
+                else
+                    continue; // We do nothing here, we just keep on trying
+            }
+            catch (emon::SamplerStopped& ex)
+            {
+                // the sampler crashed or exitted...
+                ers::error(ex);
+                break;
+            }
+            catch (emon::Exception& ex)
+            {
+                // we actually have to exit here, or an uncatched NotInitialized
+                // exception will be thrown on deletion of the iterator
+                ers::fatal(ex);
+                return 3;
+            }
+
+            eventCount++;
+
+            if (iVerbose > 0)
+                cout<<"Event count = "<<eventCount<<" Buffer occupancy = ["<<it->eventsAvailable()<<"/"<<buffer_size<<"]"<<endl;
+            if (iVerbose > 1)
+            {
+                const unsigned int* data = event.data();
+
+                cout<<"Event number = "<<dec<<data[0]<<"\tEvent size = "<<dec<<event.size()<<" DWORD\tEvent data: "<<endl;
+                cout<<hex<<setfill('0');
+                for (size_t j = 1; j < event.size(); cout<<endl)
+                {
+                    cout << setw(8) << dec << j << ": "
+                         << setw(2) << hex << (( data[j] >> 24 ) & 0xff )
+                         << setw(2) << hex << (( data[j] >> 16 ) & 0xff )
+                         << setw(2) << hex << (( data[j] >>  8 ) & 0xff )
+                         << setw(2) << hex << (( data[j]       ) & 0xff ) << " ";
+                    j++;
+
+                    for ( ; j%10 && j < event.size(); j++)
+                        cout<<setw(8)<<data[j]<<" ";
+                }
+
+                cout<<dec<<endl;
+
+                usleep(10*1000000);
+            }
+        }//while (eventCount < events)
+
+        if (it.get())
+            ERS_LOG("End of run, monitor dropped "<<it->eventsDropped()<<" events.");
+
+        //stop the timer
+        timer.stop();
+        ERS_LOG("Total number of events received : "<<eventCount);
+        ERS_LOG("Total CPU Time : "<<timer.userTime() + timer.systemTime());
+        ERS_LOG("Total Time : "<<timer.totalTime());
+        ERS_LOG("Events/second : "<<eventCount/timer.totalTime());
+
+        if (ReceivedSignal)
+            break;
+    }//for (int i = 0; i < repetitions; i++)
+
+    return 0;
+}
diff --git a/eventdisplay/tdaq/BmnEventMonitor.h b/eventdisplay/tdaq/BmnEventMonitor.h
new file mode 100644
index 0000000..00db89b
--- /dev/null
+++ b/eventdisplay/tdaq/BmnEventMonitor.h
@@ -0,0 +1,75 @@
+////////////////////////////////////////////
+//    BmnEventMonitor.h
+//    BM@N Event Monitoring Task declaration
+//    Konstantin Gertsenberger
+//    Created: Oct. 11 2016
+////////////////////////////////////////////
+
+#ifndef BMNEVENTMONITOR_H
+#define BMNEVENTMONITOR_H
+
+#ifndef __MAKECINT__
+  #include <emon/EventIterator.h>
+  #include <owl/timer.h>
+  #include <cmdl/cmdargs.h>
+  #include <ipc/core.h>
+#endif  // __MAKECINT__
+
+#include <TString.h>
+
+#include <vector>
+
+class BmnEventMonitor
+{
+  public:
+    /** Default constructor **/
+    BmnEventMonitor();
+
+    /** Standard constructor
+    *@param partition_name  partition to work in
+    *@param sampling_type   sampling address - sampler type
+    *@param sampling_names  sampling address - sampler names
+    *@param verbosity       verbosity-level: 0 - print nothing (default), 1 - print event number and event size? 2 - print event number, event size and event data
+    **/
+    BmnEventMonitor(TString partition_name, TString sampling_type, TString sampling_names, Int_t verbose = 0);
+
+    /** Destructor **/
+    virtual ~BmnEventMonitor() {}
+
+    /** Set verbosity level. For this task and all of the subtasks. **/
+    void SetVerbose(Int_t verbose) {iVerbose = verbose;}
+    void SetPartitionName(TString partition_name) {strPartitionName = partition_name;}
+    void SetSamplingType(TString sampling_type) {strSamplingType = sampling_type;}
+    void SetSamplingName(TString sampling_name) {strSamplingName = sampling_name;}
+
+    /** RunMonitor **/
+    int Exec();
+
+  protected:
+    TString strPartitionName;
+    TString strSamplingType;
+    TString strSamplingName;
+    // Verbosity level
+    Int_t   iVerbose;
+
+    // Operational parameters
+    // use event dispersion
+    Bool_t	dispersion;
+    // delay in ms before another connection attempt (default 10000)
+    Int_t	wait;
+    // number of events to retrieve (default 10000), -1 means work forever
+    Int_t	events;
+
+    // maximum number of events in the buffer (default 1000)), minimum value is 1
+    Int_t	buffer_size;
+    // number of repetitions for the test (default 1), minimum value is 1
+    Int_t	repetitions;
+    // 1 if monitor should retrieve events asynchronous (default 0)
+    Int_t	async;
+    // timeout for the nextEvent call in synchronous mode (default 10000 ms)
+    Int_t	timeout;
+
+    ClassDef(BmnEventMonitor,1);
+};
+
+#endif
diff --git a/eventdisplay/tdaq/EventDLinkDef.h b/eventdisplay/tdaq/EventDLinkDef.h
new file mode 100644
index 0000000..b8c0592
--- /dev/null
+++ b/eventdisplay/tdaq/EventDLinkDef.h
@@ -0,0 +1,26 @@
+#ifdef __CINT__
+
+#pragma link off all globals;
+#pragma link off all classes;
+#pragma link off all functions;
+
+#pragma link C++ class FairEventManager;
+#pragma link C++ class FairMCTracks;
+#pragma link C++ class FairMCStack;
+#pragma link C++ class FairMCTracksEditor;
+#pragma link C++ class FairEventManagerEditor;
+#pragma link C++ class FairBoxSetDraw;
+#pragma link C++ class FairPointSetDraw;
+#pragma link C++ class FairHitDraw;
+#pragma link C++ class FairBoxSet;
+#pragma link C++ class FairBoxSetEditor;
+#pragma link C++ class FairHitPointSetDraw;
+#pragma link C++ class FairMCPointDraw;
+#pragma link C++ class FairTimeStampPointDraw;
+#pragma link C++ class FairWebScreenshots;
+
+// TDAQ
+//#pragma link C++ class BmnEventMonitor+;
+
+#endif
+
diff --git a/fairtools/CMakeLists.txt b/fairtools/CMakeLists.txt
index cace1be..2fa5738 100644
--- a/fairtools/CMakeLists.txt
+++ b/fairtools/CMakeLists.txt
@@ -1,28 +1,41 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libFairTools" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
- ${ROOT_INCLUDE_DIR} 
+Set(INCLUDE_DIRECTORIES
  ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+ ${ROOT_INCLUDE_DIR} 
+)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
 # List of source files
 set(SRCS
    FairLogger.cxx
+   FairMonitor.cxx
+   FairSystemInfo.cxx
 )
 
 Set(HEADERS )
 Set(LINKDEF FairToolsLinkDef.h)
 Set(LIBRARY_NAME FairTools)
-Set(DEPENDENCIES Cint Core)
+Set(DEPENDENCIES Core Graf Gpad)
 
 GENERATE_LIBRARY()
diff --git a/fairtools/FairLogger.cxx b/fairtools/FairLogger.cxx
index 9cb1b2d..cc8e902 100644
--- a/fairtools/FairLogger.cxx
+++ b/fairtools/FairLogger.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /*
  * FairLogger.cxx
  *
@@ -7,16 +14,19 @@
 
 #include "FairLogger.h"
 
-#include "TString.h" // TString
-#include "TSystem.h" // gSystem
+#include "Riosfwd.h"                    // for ostream, ofstream
+#include "TString.h"                    // for TString, operator==, etc
+#include "TSystem.h"                    // for gSystem, TSystem
 
-#include <iostream>  // std::cerr
-#include <iomanip>   // std::setw
-#include <cstdlib>   // abort
+#include <stddef.h>                     // for size_t
+#include <stdio.h>                      // for fclose, freopen, remove, etc
+#include <sys/select.h>                 // for time_t
+#include <time.h>                       // for localtime, strftime, time
+#include <cstdlib>                      // for NULL, abort
+#include <iomanip>                      // for operator<<, setw
+#include <iostream>                     // for cout, cerr
 
-FairLogger* gLogger = FairLogger::GetLogger();
-
-FairLogger* FairLogger::instance = NULL;
+TMCThreadLocal FairLogger* FairLogger::instance = NULL;
 
 FairLogger::FairLogger()
   :
@@ -35,8 +45,9 @@ FairLogger::FairLogger()
   fLevel(INFO),
   fScreenStream(&std::cout),
   fFileStream(NULL),
-  fNullStream(new ostream(0)),
-  fLogFileOpen(kFALSE)
+  fNullStream(new std::ostream(0)),
+  fLogFileOpen(kFALSE),
+  fIsNewLine(kTRUE)
 {
 }
 
@@ -175,10 +186,10 @@ void FairLogger::Log(FairLogLevel level, const char* file, const char* line,
     // glibc and current Windows return -1 for failure, i.e., not
     // telling us how much was needed.
 
-    if (fBufferSizeNeeded <= (int)fBufferSize && fBufferSizeNeeded >= 0) {
+    if (fBufferSizeNeeded <= static_cast<int>(fBufferSize) && fBufferSizeNeeded >= 0) {
       // It fit fine so we're done.
       GetOutputStream(level, file, line, func) <<
-          std::string(fBufferPointer, (size_t) fBufferSizeNeeded)<<
+          std::string(fBufferPointer, static_cast<size_t>(fBufferSizeNeeded))<<
           " " << FairLogger::endl;
 
       break;
@@ -198,9 +209,14 @@ void FairLogger::SetLogFileName(const char* name)
 {
   if (fFileStream) {
     CloseLogFile();
-    delete fFileStream;
     fFileStream = NULL;
-    remove(fLogFileName);
+    // Remove the file only if it still exists
+    std::ifstream ifile(fLogFileName);
+    if ( ifile ) {
+      if( remove(fLogFileName) != 0 ) {
+        LOG(ERROR)<<"Could not delete log file "<< fLogFileName << "." << FairLogger::endl;
+      }
+    }
   }
 
   fLogFileName = name;
@@ -210,7 +226,14 @@ void FairLogger::SetLogFileName(const char* name)
 
 void FairLogger::CloseLogFile()
 {
-  dynamic_cast<ofstream*>(fFileStream)->close();
+  std::ofstream* tmp =NULL;
+  if (fFileStream) {
+    tmp = dynamic_cast<std::ofstream*>(fFileStream);
+    if (tmp) {
+      tmp->close();
+    }
+  }
+  delete tmp;
 }
 
 void FairLogger::OpenLogFile()
@@ -295,6 +318,9 @@ void FairLogger::SetMinLogLevel()
 
 Bool_t FairLogger::IsLogNeeded(FairLogLevel logLevel)
 {
+  if (FATAL == logLevel) {
+    return true;
+  }
   if (logLevel <= fMinLogLevel) {
     return true;
   } else {
@@ -313,48 +339,114 @@ FairLogger& FairLogger::GetOutputStream(FairLogLevel level, const char* file, co
     fLogColored = true;
   }
 
-  if ( (fLogToScreen && level <= fLogScreenLevel) ) {
-    if ( fLogColored ) {
-      *fScreenStream << LogLevelColor[level];
-    }
 
-    *fScreenStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
+  if (fIsNewLine) {
+    if ( (fLogToScreen && level <= fLogScreenLevel) ) {
+
+      if ( fLogColored ) {
+        *fScreenStream << LogLevelColor[level];
+      }
+
+      *fScreenStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
 
-    if ( fLogVerbosityLevel == verbosityHIGH ) {
-      GetTime();
-      *fScreenStream << fTimeBuffer;
+      if ( fLogVerbosityLevel == verbosityHIGH ) {
+        GetTime();
+        *fScreenStream << fTimeBuffer;
+      }
+
+      if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
+        TString bla(file);
+        Ssiz_t pos = bla.Last('/');
+        TString s2(bla(pos+1, bla.Length()));
+        TString s3 = s2 + "::" + func + ":" + line;
+        *fScreenStream << "[" << s3 <<"] ";
+      }
     }
 
-    if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
-      TString bla(file);
-      Ssiz_t pos = bla.Last('/');
-      TString s2(bla(pos+1, bla.Length()));
-      TString s3 = s2 + "::" + func + ":" + line;
-      *fScreenStream << "[" << s3 <<"] ";
+    if ( fLogToFile && level <= fLogFileLevel ) {
+      if(!fLogFileOpen) {
+        OpenLogFile();
+      }
+
+      *fFileStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
+
+      if ( fLogVerbosityLevel == verbosityHIGH ) {
+        GetTime();
+        *fFileStream << fTimeBuffer;
+      }
+
+      if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
+        TString bla(file);
+        Ssiz_t pos = bla.Last('/');
+        TString s2(bla(pos+1, bla.Length()));
+        TString s3 = s2 + "::" + func + ":" + line;
+        *fFileStream << "[" << s3 <<"] ";
+      }
     }
+    fIsNewLine = kFALSE;
   }
+  return *this;
+}
 
-  if ( fLogToFile && level <= fLogFileLevel ) {
-    if(!fLogFileOpen) {
-      OpenLogFile();
-    }
+// coverity[+kill]
+FairLogger& FairLogger::GetFATALOutputStream(const char* file, const char* line, const char* func)
+{
 
-    *fFileStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
+  fLevel = FATAL;
+  FairLogLevel level = FATAL;
 
-    if ( fLogVerbosityLevel == verbosityHIGH ) {
-      GetTime();
-      *fFileStream << fTimeBuffer;
+//  if (level == FATAL) {
+    fLogToScreen = true;
+    fLogVerbosityLevel = verbosityHIGH;
+    fLogColored = true;
+//  }
+
+
+  if (fIsNewLine) {
+    if ( (fLogToScreen && level <= fLogScreenLevel) ) {
+
+      if ( fLogColored ) {
+        *fScreenStream << LogLevelColor[level];
+      }
+
+      *fScreenStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
+
+      if ( fLogVerbosityLevel == verbosityHIGH ) {
+        GetTime();
+        *fScreenStream << fTimeBuffer;
+      }
+
+      if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
+        TString bla(file);
+        Ssiz_t pos = bla.Last('/');
+        TString s2(bla(pos+1, bla.Length()));
+        TString s3 = s2 + "::" + func + ":" + line;
+        *fScreenStream << "[" << s3 <<"] ";
+      }
     }
 
-    if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
-      TString bla(file);
-      Ssiz_t pos = bla.Last('/');
-      TString s2(bla(pos+1, bla.Length()));
-      TString s3 = s2 + "::" + func + ":" + line;
-      *fFileStream << "[" << s3 <<"] ";
+    if ( fLogToFile && level <= fLogFileLevel ) {
+      if(!fLogFileOpen) {
+        OpenLogFile();
+      }
+
+      *fFileStream << "[" << std::setw(7) << std::left << LogLevelString[level] <<"] ";
+
+      if ( fLogVerbosityLevel == verbosityHIGH ) {
+        GetTime();
+        *fFileStream << fTimeBuffer;
+      }
+
+      if ( fLogVerbosityLevel <= verbosityMEDIUM ) {
+        TString bla(file);
+        Ssiz_t pos = bla.Last('/');
+        TString s2(bla(pos+1, bla.Length()));
+        TString s3 = s2 + "::" + func + ":" + line;
+        *fFileStream << "[" << s3 <<"] ";
+      }
     }
+    fIsNewLine = kFALSE;
   }
-
   return *this;
 }
 
@@ -390,9 +482,11 @@ FairLogger& FairLogger::operator<<(std::ostream& (*manip) (std::ostream&))
 std::ostream&  FairLogger::endl(std::ostream& strm)
 {
 
+  gLogger->fIsNewLine = kTRUE;
   if ( (gLogger->fLogToScreen && gLogger->fLevel <= gLogger->fLogScreenLevel) ) {
     if (gLogger->fLogColored) {
-      *(gLogger->fScreenStream) << "\33[00;30m" << std::endl;
+      // reset format to default 
+      *(gLogger->fScreenStream) << "\33[0m" << std::endl;
     } else {
       *(gLogger->fScreenStream) << std::endl;
     }
@@ -422,6 +516,7 @@ std::ostream& FairLogger::flush(std::ostream& strm)
   return strm;
 }
 
+// coverity[+kill]
 void FairLogger::LogFatalMessage(std::ostream& strm)
 {
   // Since Fatal indicates a fatal error it is maybe usefull to have
@@ -472,7 +567,8 @@ void FairLogger::LogFatalMessage(std::ostream& strm)
                    corefile << "\n";
     }
 
-    *(gLogger->fScreenStream) << "\33[00;30m" << std::endl;
+    // reset format to default before exiting
+    *(gLogger->fScreenStream) << "\33[0m" << std::endl; 
 
     flush(strm);
     freopen(corefile, "w", stderr);
diff --git a/fairtools/FairLogger.h b/fairtools/FairLogger.h
index acc0aad..8b21a48 100644
--- a/fairtools/FairLogger.h
+++ b/fairtools/FairLogger.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 
 /*
  * FairLogger.h
@@ -9,21 +16,29 @@
 #ifndef BASE_FAIRLOGGER_H_
 #define BASE_FAIRLOGGER_H_
 
+#include "Rtypes.h"                     // for Bool_t, FairLogger::Class, etc
+#include "TMCtls.h"                     // for MT VMC
+
+#include <stdarg.h>                     // for va_list
+#include <fstream>                      // for ostream, operator<<, etc
+#include <string>                       // for operator<<
+#include <vector>                       // for vector
+
+class FairLogger;
+
 #define IMP_CONVERTTOSTRING(s)  # s
 #define CONVERTTOSTRING(s)      IMP_CONVERTTOSTRING(s)
 #define MESSAGE_ORIGIN          __FILE__, CONVERTTOSTRING(__LINE__), __FUNCTION__
 
+#define LOG_LEVEL(level) \
+  (!(FATAL == level) ? gLogger->GetOutputStream(level, MESSAGE_ORIGIN) : gLogger->GetFATALOutputStream(MESSAGE_ORIGIN))
+
 #define LOG(level)        \
-  !(gLogger->IsLogNeeded(level)) ? gLogger->GetNullStream(level) : gLogger->GetOutputStream(level, MESSAGE_ORIGIN)
+  !(gLogger->IsLogNeeded(level)) ? gLogger->GetNullStream(level) : LOG_LEVEL(level)
 
 #define LOG_IF(level, condition) \
   !(condition) ? gLogger->GetNullStream(level) : LOG(level)
 
-#include "Rtypes.h"
-
-#include <ostream>
-#include <fstream>
-
 // Definiton of the different log levels
 // TODO(F.U): Find bettter names for DEBUG1..4
 enum FairLogLevel {FATAL, ERROR, WARNING, INFO,
@@ -131,6 +146,7 @@ class FairLogger : public std::ostream
                 const char* format, ...);
 
     FairLogger& GetOutputStream(FairLogLevel level, const char* file, const char* line, const char* func);
+    FairLogger& GetFATALOutputStream(const char* file, const char* line, const char* func);
 
     std::ostream& GetNullStream(FairLogLevel level) {
       fLevel=level;
@@ -167,7 +183,12 @@ class FairLogger : public std::ostream
     static std::ostream&        flush(std::ostream&);
 
   private:
-    static FairLogger* instance;
+#if !defined(__CINT__)
+    static TMCThreadLocal FairLogger* instance;
+#else
+    static                FairLogger* instance;
+#endif
+
     FairLogger();
     FairLogger(const FairLogger&);
     FairLogger operator=(const FairLogger&);
@@ -212,9 +233,10 @@ class FairLogger : public std::ostream
     std::ostream* fFileStream;
     std::ostream* fNullStream;
     Bool_t fLogFileOpen;
-    ClassDef(FairLogger, 2)
+    Bool_t fIsNewLine;
+    ClassDef(FairLogger, 3)
 };
 
-extern FairLogger* gLogger;
+#define gLogger (FairLogger::GetLogger())
 
 #endif  // BASE_FAIRLOGGER_H_
diff --git a/fairtools/FairMonitor.cxx b/fairtools/FairMonitor.cxx
new file mode 100644
index 0000000..7c73980
--- /dev/null
+++ b/fairtools/FairMonitor.cxx
@@ -0,0 +1,735 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairMonitor.cxx
+ *
+ *  Created on: Aug 01, 2015
+ *      Author: r.karabowicz
+ */
+
+#include "FairMonitor.h"
+#include "FairLogger.h"
+#include "FairSystemInfo.h"
+
+#include "TArrow.h"
+#include "TAxis.h"
+#include "TBox.h"
+#include "TCanvas.h"
+#include "TDirectory.h"
+#include "TFile.h"
+#include "TH1F.h"
+#include "TLatex.h"
+#include "TLegend.h"
+#include "TList.h"
+#include "TMath.h"
+#include "TNamed.h"
+#include "TPaveText.h"
+#include "TROOT.h"
+#include "TStopwatch.h"
+#include "TString.h"
+#include "TTask.h"
+
+#include <iomanip>
+#include <iostream>
+#include <iterator>
+#include <utility>
+
+FairMonitor* FairMonitor::instance = NULL;
+
+//_____________________________________________________________________________
+FairMonitor::FairMonitor()
+  : TNamed("FairMonitor","Monitor for FairRoot")
+  , fRunMonitor(kFALSE)
+  , fRunTime(0.)
+  , fRunMem(0.)
+  , fTimerMap()
+  , fMemoryMap()
+  , fHistList(new TList())
+  , fCanvas()
+  , fNoTaskRequired(0)
+  , fNoTaskCreated(0)
+  , fCurrentTask(0)
+  , fTaskRequired()
+  , fTaskCreated()
+  , fTaskCreatedTemp()
+  , fObjectMap()
+  , fTaskMap()
+  , fObjectPos()
+  , fTaskPos()
+{
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+FairMonitor::~FairMonitor()
+{
+}
+//_____________________________________________________________________________
+  
+//_____________________________________________________________________________
+FairMonitor* FairMonitor::GetMonitor()
+{
+  if (!instance) {
+    instance = new FairMonitor();
+  }
+  return instance;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::StartTimer(const TTask* tTask, const char* identStr) {
+  if ( !fRunMonitor ) return;
+
+  TString tempString = Form("timer_%p_%s_%s",tTask,tTask->GetName(),identStr);
+
+  typedef std::map<TString, TStopwatch>::iterator ttMapIter;
+
+  ttMapIter itt = fTimerMap.find(tempString);
+  if ( itt == fTimerMap.end() ) {
+    fTimerMap.insert(std::pair<TString, TStopwatch> (tempString,TStopwatch()));
+    itt = fTimerMap.find(tempString);
+  }
+  fTimerMap[tempString].Start();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::StopTimer(const TTask* tTask, const char* identStr) {
+  if ( !fRunMonitor ) return;
+
+  TString tempString = Form("timer_%p_%s_%s",tTask,tTask->GetName(),identStr);
+
+  typedef std::map<TString, TStopwatch>::iterator ttMapIter;
+
+  ttMapIter itt = fTimerMap.find(tempString);
+  if ( itt == fTimerMap.end() ) {
+    LOG(INFO) << "FairMonitor::StopTimer() called without matching StartTimer()" << FairLogger::endl;
+    return;
+  }
+  //  itt->second
+  fTimerMap[tempString].Stop();
+
+  Double_t time = fTimerMap[tempString].RealTime();
+  RecordInfo(tTask,Form("%s_TIM",identStr),time);
+
+  if ( tempString.EndsWith("_EXEC") )
+    fRunTime += time;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::StartMemoryMonitor(const TTask* tTask, const char* identStr) {
+  if ( !fRunMonitor ) return;
+  FairSystemInfo sysInfo;
+  Int_t memoryAtStart = static_cast<Int_t>(sysInfo.GetCurrentMemory());
+
+  TString memMon = Form("mem_%p_%s_%s",tTask,tTask->GetName(),identStr);
+  
+  typedef std::map<TString, Int_t>::iterator tiMapIter;
+
+  tiMapIter iti = fMemoryMap.find(memMon);
+  if ( iti == fMemoryMap.end() ) 
+    fMemoryMap.insert(std::pair<TString, Int_t> (memMon,memoryAtStart));
+  else
+    iti->second = memoryAtStart;
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::StopMemoryMonitor(const TTask* tTask, const char* identStr) {
+  if ( !fRunMonitor ) return;
+  FairSystemInfo sysInfo;
+  Int_t memoryAtEnd = static_cast<Int_t>(sysInfo.GetCurrentMemory());
+
+  TString memMon = Form("mem_%p_%s_%s",tTask,tTask->GetName(),identStr);
+  
+  typedef std::map<TString, Int_t>::iterator tiMapIter;
+
+  tiMapIter iti = fMemoryMap.find(memMon);
+  if ( iti == fMemoryMap.end() ) 
+    LOG(WARNING) << "FairMonitor::StopMemoryMonitor() Could not find corresponding entry for \"" << memMon.Data() << "\"." << FairLogger::endl;
+  else {
+    RecordInfo(tTask,Form("%s_MEM",identStr),memoryAtEnd-iti->second);
+    
+    if ( memMon.EndsWith("_EXEC") )
+      fRunMem += memoryAtEnd-iti->second;
+  } 
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::RecordInfo(const TTask* tTask, const char* identStr, Double_t value) {
+  if ( !fRunMonitor ) return;
+  
+  TString tempString = Form("hist_%p_%s_%s",tTask,tTask->GetName(),identStr);
+
+  Int_t nofHists = fHistList->GetEntries();
+  Int_t ihist = 0;
+  for ( ihist = 0 ; ihist < nofHists ; ihist++ ) {
+    if ( !tempString.CompareTo(fHistList->At(ihist)->GetName()) ) {
+      break;
+    }
+  }
+  if ( ihist == nofHists ) {
+    TString titleString = Form("Histogram %s for %s",identStr,tTask->GetName());
+    fHistList->Add(new TH1F(tempString,titleString,1000,0,1000));
+  }
+  TH1F* tempHist = (static_cast<TH1F*>((fHistList->At(ihist))));
+  Int_t nofEntries = tempHist->GetEntries();
+  if ( nofEntries > tempHist->GetNbinsX() ) 
+    tempHist->SetBins(tempHist->GetNbinsX()*10, 0, tempHist->GetXaxis()->GetXmax()*10);
+
+  tempHist->SetBinContent(nofEntries+1,value);
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::RecordRegister(const char* name, const char* folderName, Bool_t toFile) {
+  if ( !fRunMonitor ) return;
+
+  LOG(DEBUG) << "*** FM::RecordRegister(" << name << ", " << folderName << (toFile?", kTRUE)":", kFALSE") << " for task >>" << fCurrentTask << "<< (" << (fCurrentTask?fCurrentTask->GetName():"") << ")" << FairLogger::endl;
+  if ( fCurrentTask == 0 ) {
+    fNoTaskCreated ++; 
+    LOG(INFO) << "*** FM::RecordRegister(" << name << ", " << folderName << (toFile?", kTRUE)":", kFALSE") << " WITHOUT TASK" << FairLogger::endl;
+    return;
+  }
+  TString tempString = Form("%p_%s",fCurrentTask,fCurrentTask->GetName());
+  if ( toFile ) {
+    fTaskCreated.insert(std::pair<TString, TString>(tempString,TString(name)));
+  }
+  else {
+    fTaskCreatedTemp.insert(std::pair<TString, TString>(tempString,TString(name)));
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::RecordGetting(const char* name) {
+  if ( !fRunMonitor ) return;
+
+  LOG(DEBUG) << "*** FM::RecordGetting(" << name << ") for task >>" << fCurrentTask << "<< (" << (fCurrentTask?fCurrentTask->GetName():"") << ")" << FairLogger::endl;
+
+  if ( fCurrentTask == 0 ) {
+    fNoTaskRequired ++;
+    return;
+  }
+  TString tempString = Form("%p_%s",fCurrentTask,fCurrentTask->GetName());
+  fTaskRequired.insert(std::pair<TString, TString>(tempString,TString(name)));
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::PrintTask(TTask* tempTask, Int_t taskLevel) const {
+  if ( !fRunMonitor ) return;
+
+  Int_t nofHists = fHistList->GetEntries();
+  TString tempString = "";
+
+  Double_t timInt = -1.;
+  Double_t timEnt = 0.;
+  Int_t memInt = -1.;
+
+  char byteChar[4] = {'B','k','M','G'};
+
+  for ( Int_t ihist = 0 ; ihist < nofHists ; ihist++ ) {
+    tempString = Form("%s",fHistList->At(ihist)->GetName());
+    if ( tempString.Contains(Form("%p",tempTask)) ) {
+      if ( tempString.Contains("EXEC_TIM") ) {
+	timInt = (static_cast<TH1F*>(fHistList->At(ihist))->Integral());
+	timEnt = (static_cast<TH1F*>(fHistList->At(ihist))->GetEntries());
+      }
+      if ( tempString.Contains("EXEC_MEM") ) {
+	memInt = (static_cast<TH1F*>(fHistList->At(ihist))->Integral());
+      }
+    }
+  }
+  if ( timInt < 0 ) {
+    LOG(WARNING) << "FairMonitor::PrintTask(), task \"" << tempTask->GetName() << "\" not found!" << FairLogger::endl; 
+  }
+  else {
+    //    LOG(INFO) << "\"" << tempTask->GetName() << "\" --> TIME integral =  " << timInt << " -- MEMORY integral = " << memInt << FairLogger::endl;
+    TString printString = Form("%f", timInt/timEnt);
+    for ( Int_t itemp = printString.Length() ; itemp < 10 ; itemp++ ) 
+      printString.Insert(0,' ');
+    if (printString.Length() > 10 ) printString.Remove(11,100);
+    printString += " s/ev |";
+    Double_t timePerc = 100.*timInt/fRunTime;
+    if ( timePerc < 100. ) printString += ' ';
+    if ( timePerc <  10. ) printString += ' ';
+    tempString = Form("%f",timePerc);
+    for ( Int_t itemp = tempString.Length() ; itemp < 8 ; itemp++ ) 
+      printString += ' ';
+    printString += tempString;
+    printString.Remove(27,100);
+    Int_t byteIdent = 0;
+    while ( memInt > 1024 ) {
+      memInt = memInt/1024;
+      byteIdent++;
+    }
+    tempString = Form("%4d",memInt);
+    printString += " % ] ";
+    if ( memInt < 0 )
+      printString += "- - -";
+    else {
+      printString += tempString;
+      printString += byteChar[byteIdent];
+    }
+    printString += " \"";
+    for ( Int_t ilev = 0 ; ilev < taskLevel ; ilev++ )
+      printString += "  ";
+    printString += tempTask->GetName();
+    if ( printString.Length() > 80 )
+      printString.Remove(80,100);
+    printString += "\"";
+    Int_t timeFrac = static_cast<Int_t>((timePerc/100.*30.));
+    if ( timePerc < 30 )
+      LOG(INFO) << "[\033[42m" << FairLogger::flush;
+    else if ( timePerc < 90 )
+      LOG(INFO) << "[\033[43m" << FairLogger::flush;
+    else
+      LOG(INFO) << "[\033[41m" << FairLogger::flush;
+    for ( Int_t ilen = 0 ; ilen < timeFrac ; ilen++ ) {
+      LOG(INFO) << printString[ilen] << FairLogger::flush;
+    }
+    LOG(INFO) << "\033[0m" << FairLogger::flush;
+    for ( Int_t ilen = timeFrac ; ilen < 32 ; ilen++ ) {
+      LOG(INFO) << printString[ilen] << FairLogger::flush;
+    }
+    switch ( byteIdent ) {
+    case 0:  LOG(INFO) << "\033[42m" << FairLogger::flush; break;
+    case 1:  LOG(INFO) << "\033[43m" << FairLogger::flush; break;
+    default: LOG(INFO) << "\033[41m" << FairLogger::flush; break;
+    }
+    for ( Int_t ilen = 32 ; ilen < 37 ; ilen++ ) {
+      LOG(INFO) << printString[ilen] << FairLogger::flush;
+    }
+    LOG(INFO) << "\033[0m" << FairLogger::flush;
+    for ( Int_t ilen = 37 ; ilen < printString.Length() ; ilen++ ) {
+      LOG(INFO) << printString[ilen] << FairLogger::flush;
+    }
+    LOG(INFO) << FairLogger::endl;
+    //    LOG(INFO) << printString.Data() << FairLogger::endl;
+  }
+
+  TList* subTaskList = tempTask->GetListOfTasks();
+  if ( !subTaskList ) return;
+  for ( Int_t itask = 0 ; itask < subTaskList->GetEntries() ; itask++ ) {
+    TTask* subTask = static_cast<TTask*>(subTaskList->At(itask));
+    if ( subTask ) 
+      PrintTask(subTask,taskLevel+1);
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::Print(Option_t*) const {
+  if ( !fRunMonitor ) {
+    LOG(WARNING) << "FairMonitor was disabled. Nothing to print!" << FairLogger::endl;
+    return;
+  }
+
+  LOG(INFO) << "- Total Run Time: " << fRunTime << " s ---------------------------------------------------------" << FairLogger::endl;
+  TTask* mainFairTask = static_cast<TTask*>((gROOT->GetListOfBrowsables()->FindObject("FairTaskList")));
+  if ( mainFairTask ) 
+    PrintTask(mainFairTask,0);
+  LOG(INFO) << "-------------------------------------------------------------------------------------" << FairLogger::endl;
+  
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::PrintTask(TString specString) const {
+  if ( !fRunMonitor ) {
+    LOG(WARNING) << "FairMonitor was disabled. Nothing to print!" << FairLogger::endl;
+    return;
+  }
+
+  TString unitString = "";
+
+  Int_t nofHists = fHistList->GetEntries();
+  for ( Int_t ihist = 0 ; ihist < nofHists ; ihist++ ) {
+    TString histString = Form("%s",fHistList->At(ihist)->GetName());
+    if ( histString.Contains(specString) ) {
+      histString.Replace(0,histString.First('_')+1,"");
+      histString.Replace(0,histString.First('_')+1,"");
+      Double_t integral = (static_cast<TH1F*>((fHistList->At(ihist)))->Integral());
+      Double_t entries  = (static_cast<TH1F*>((fHistList->At(ihist)))->GetEntries());
+//      Double_t valPent  = integral/entries;
+      if ( histString.EndsWith("_TIM") ) unitString = " s";
+      if ( histString.EndsWith("_MEM") ) unitString = " B";
+      LOG(INFO) << histString.Data() << " >>>>> " << integral << unitString.Data() << " / " << entries << " ent = " << integral/entries << unitString.Data() << " / ent" << FairLogger::endl;
+    }
+  }
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::Draw(Option_t*) {
+  if ( !fRunMonitor ) {
+    LOG(WARNING) << "FairMonitor was disabled. Nothing to print!" << FairLogger::endl;
+    return;
+  }
+
+  typedef std::multimap<TString, TString>::iterator bnMapIter;
+
+  typedef std::map<TString, Int_t>::iterator tiMapIter;
+  tiMapIter iti;
+  
+  TTask* mainFairTask = static_cast<TTask*>((gROOT->GetListOfBrowsables()->FindObject("FairTaskList")));
+  if ( !mainFairTask ) return;
+
+  GetTaskMap(mainFairTask);
+
+  for(bnMapIter itb = fTaskRequired.begin(); itb != fTaskRequired.end() ; itb++) {
+    iti = fTaskMap.find(itb->first);
+    if ( iti == fTaskMap.end() )
+      fTaskMap.insert(std::pair<TString, Int_t> (itb->first,0));
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() )
+      fObjectMap.insert(std::pair<TString, Int_t> (itb->second,0));
+  }
+  for(bnMapIter itb = fTaskCreated.begin(); itb != fTaskCreated.end() ; itb++) {
+    iti = fTaskMap.find(itb->first);
+    if ( iti == fTaskMap.end() )
+      fTaskMap.insert(std::pair<TString, Int_t> (itb->first,0));
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() )
+      fObjectMap.insert(std::pair<TString, Int_t> (itb->second,0));
+  }
+  for(bnMapIter itb = fTaskCreatedTemp.begin(); itb != fTaskCreatedTemp.end() ; itb++) {
+    iti = fTaskMap.find(itb->first);
+    if ( iti == fTaskMap.end() )
+      fTaskMap.insert(std::pair<TString, Int_t> (itb->first,0));
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() )
+      fObjectMap.insert(std::pair<TString, Int_t> (itb->second,0));
+  }
+  
+  AnalyzeObjectMap(mainFairTask);
+
+  Int_t maxHierarchyNumber = 0;
+  for ( iti = fObjectMap.begin() ; iti != fObjectMap.end() ; iti++ ) {
+    if ( maxHierarchyNumber < iti->second ) 
+      maxHierarchyNumber = iti->second; 
+  }
+
+  LOG(DEBUG) << "Max hierarchy number is " << maxHierarchyNumber << FairLogger::endl;
+
+  fCanvas = new TCanvas("MonitorCanvas","Fair Monitor",10,10,960,600);
+  fCanvas->cd();
+
+  fCanvas->SetFillStyle(4000);
+  fCanvas->Range(0,0,960,800);
+  fCanvas->SetFillColor(0);
+  fCanvas->SetBorderSize(0);
+  fCanvas->SetBorderMode(0);
+  fCanvas->SetFrameFillColor(0);
+
+  for ( Int_t ihier = 0 ; ihier < maxHierarchyNumber+1 ; ihier++ ) {
+    Int_t nofHier = 0;
+    for ( iti = fTaskMap.begin() ; iti != fTaskMap.end() ; iti++ ) {
+      if ( iti->second == ihier ) {
+	nofHier ++;
+      }
+    }
+    LOG(DEBUG) << "There are " << nofHier << " tasks on level " << ihier << "." << FairLogger::endl;
+
+    if ( ihier == 0 ) {
+      Double_t iObj = 0.;
+      for ( iti = fTaskMap.begin() ; iti != fTaskMap.end() ; iti++ ) {
+	if ( iti->second == ihier ) {
+	  std::pair<Double_t, Double_t> tempPos(50,600-iObj*40);
+	  fTaskPos.insert(std::pair<TString, std::pair<Double_t, Double_t> > (iti->first,tempPos));
+	  iObj+=1.;
+	}
+      }
+    }
+    else {
+      Int_t iObj = 0;
+      Int_t secLine = 0;
+      Int_t secLineEven = 0;
+      if ( nofHier > 9 ) {
+	secLine = 1;
+	if ( nofHier%2 == 0 ) secLineEven = 1;
+      }
+      Int_t startingPosition = 575 - nofHier/(1+secLine)*45-secLine*(1-secLineEven)*45;
+
+      Double_t topEdge = 800.-800.*(2.*static_cast<Double_t>(ihier)-0.5)/(static_cast<Double_t>(2*maxHierarchyNumber+1))+secLine*15;
+      LOG(DEBUG) << "for level " << ihier << " will put top edge at " << topEdge 
+		<< ". " << (secLineEven?"Two lines":"One line") << (secLineEven?" with offset":"") << FairLogger::endl;
+      for ( iti = fTaskMap.begin() ; iti != fTaskMap.end() ; iti++ ) {
+	if ( iti->second == ihier ) {
+	  std::pair<Double_t, Double_t> tempPos(startingPosition+iObj*90/(1+secLine)-secLineEven*(iObj%2)*45,topEdge-15-secLine*(iObj%2)*35);
+ 	  fTaskPos.insert(std::pair<TString, std::pair<Double_t, Double_t> > (iti->first,tempPos));
+	  iObj+=1;
+	}
+      }
+    }
+
+    nofHier = 0;
+    for ( iti = fObjectMap.begin() ; iti != fObjectMap.end() ; iti++ ) {
+      if ( TMath::Abs(iti->second) == ihier ) {
+	nofHier ++;
+      }
+    }
+    LOG(DEBUG) << "There are " << nofHier << " objects on level " << ihier << "." << FairLogger::endl;
+
+    Int_t iObj = 0;
+    Int_t secLine = 0;
+    Int_t secLineEven = 0;
+    if ( nofHier > 9 ) {
+      secLine = 1;
+      if ( nofHier%2 == 0 ) secLineEven = 1;
+    }
+    Int_t startingPosition = 575 - nofHier/(1+secLine)*45-secLine*(1-secLineEven)*45;
+
+    Double_t topEdge = 800.-800.*(2.*static_cast<Double_t>(ihier)+0.5)/(static_cast<Double_t>(2*maxHierarchyNumber+1))+secLine*15;
+    LOG(DEBUG) << "for level " << ihier << " will put top edge at " << topEdge 
+	      << ". " << (secLineEven?"Two lines":"One line") << (secLineEven?" with offset":"") << FairLogger::endl;
+    for ( iti = fObjectMap.begin() ; iti != fObjectMap.end() ; iti++ ) {
+      if ( TMath::Abs(iti->second) == ihier ) {
+	std::pair<Double_t, Double_t> tempPos(startingPosition+iObj*90/(1+secLine)-secLineEven*(iObj%2)*45,topEdge-15-secLine*(iObj%2)*35);
+	fObjectPos.insert(std::pair<TString, std::pair<Double_t, Double_t> > (iti->first,tempPos));
+	iObj+=1;
+      }
+    }
+    
+  }
+
+  typedef std::map<TString, std::pair<Double_t, Double_t> >::iterator tddMapIter;
+  tddMapIter itt;
+  tddMapIter ito;
+  
+  for(bnMapIter itb = fTaskRequired.begin(); itb != fTaskRequired.end() ; itb++) {
+    itt = fTaskPos.find(itb->first);
+    ito = fObjectPos.find(itb->second);
+    if ( itt != fTaskPos.end() && ito != fObjectPos.end() ) {
+      std::pair<Double_t, Double_t> taskPos = itt->second;
+      std::pair<Double_t, Double_t> objectPos = ito->second;
+      TArrow* tempArrow = new TArrow(objectPos.first,objectPos.second-15,taskPos.first,taskPos.second+15,0.01,"|>");
+      tempArrow->Draw();
+    }
+  }
+  for(bnMapIter itb = fTaskCreated.begin(); itb != fTaskCreated.end() ; itb++) {
+    itt = fTaskPos.find(itb->first);
+    ito = fObjectPos.find(itb->second);
+    if ( itt != fTaskPos.end() && ito != fObjectPos.end() ) {
+      std::pair<Double_t, Double_t> taskPos = itt->second;
+      std::pair<Double_t, Double_t> objectPos = ito->second;
+      TArrow* tempArrow = new TArrow(taskPos.first,taskPos.second-15,objectPos.first,objectPos.second+15,0.01,"|>");
+      tempArrow->Draw();
+    }
+  }
+  for(bnMapIter itb = fTaskCreatedTemp.begin(); itb != fTaskCreatedTemp.end() ; itb++) {
+    itt = fTaskPos.find(itb->first);
+    ito = fObjectPos.find(itb->second);
+    if ( itt != fTaskPos.end() && ito != fObjectPos.end() ) {
+      std::pair<Double_t, Double_t> taskPos = itt->second;
+      std::pair<Double_t, Double_t> objectPos = ito->second;
+      TArrow* tempArrow = new TArrow(taskPos.first,taskPos.second-15,objectPos.first,objectPos.second+15,0.01,"|>");
+      tempArrow->Draw();
+    }
+  }
+
+  for ( itt = fTaskPos.begin() ; itt != fTaskPos.end() ; itt++ ) {
+    std::pair<Double_t, Double_t> taskPos = itt->second;
+    TBox* bkgBox = new TBox(taskPos.first-40,taskPos.second-15,taskPos.first+40,taskPos.second+15);
+    bkgBox->SetFillColor(kGreen-9);
+    bkgBox->Draw();
+
+    TString tempString = Form("hist_%s_%s",itt->first.Data(),"EXEC_TIM");
+    Int_t nofHists = fHistList->GetEntries();
+    for ( Int_t ihist = 0 ; ihist < nofHists ; ihist++ ) {
+      if ( !tempString.CompareTo(fHistList->At(ihist)->GetName()) ) {
+	Double_t timeInt = (static_cast<TH1F*>(fHistList->At(ihist))->Integral());
+	Double_t timeFrac = 80.*timeInt/fRunTime;
+	TBox* barBox = new TBox(taskPos.first-40,taskPos.second-15,taskPos.first-40+timeFrac,taskPos.second+15);
+	barBox->SetFillColor(kRed);
+	barBox->Draw();
+      }
+    }
+
+    tempString = itt->first;
+    tempString.Replace(0,tempString.First('_')+1,"");
+    if ( tempString.Length() > 16 ) tempString.Replace(16,tempString.Length(),"");
+    TLatex* taskText = new TLatex(taskPos.first,taskPos.second,tempString.Data());
+    taskText->SetTextAlign(22);
+    taskText->SetTextSize(0.015);
+    taskText->Draw();
+  }
+
+  for ( ito = fObjectPos.begin() ; ito != fObjectPos.end() ; ito++ ) {
+    std::pair<Double_t, Double_t> objectPos = ito->second;
+    iti = fObjectMap.find(ito->first);
+    TPaveText* paveText = new TPaveText(objectPos.first-40,objectPos.second-15,objectPos.first+40,objectPos.second+15,"nb");
+    paveText->SetFillColor(kMagenta-9);
+    if ( iti != fObjectMap.end() )
+      if ( iti->second < 0 ) 
+	paveText->SetFillColor(kGray);
+    paveText->SetShadowColor(0);
+    paveText->SetTextSize(0.015);
+    TString tempString = ito->first;
+    if ( tempString.Length() > 16 ) tempString.Replace(16,tempString.Length(),"");
+    paveText->AddText(tempString);
+    paveText->Draw();
+  }
+
+
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::DrawHist(TString specString) {
+  if ( !fRunMonitor ) {
+    LOG(WARNING) << "FairMonitor was disabled. Nothing to draw!" << FairLogger::endl;
+    return;
+  }
+
+  Int_t nofHists = fHistList->GetEntries();
+  Int_t nofDraws = 0;
+  TString drawStr = "P";
+
+  TLegend* tempLeg = new TLegend(0.0,0.5,0.5,0.9);
+
+  Double_t histMax = 0.;
+  for ( Int_t ihist = 0 ; ihist < nofHists ; ihist++ ) {
+    TString histString = Form("%s",fHistList->At(ihist)->GetName());
+    if ( histString.Contains(specString) ) {
+      TH1F* tempHist = (static_cast<TH1F*>((fHistList->At(ihist))));
+      if ( histMax < tempHist->GetMaximum() )
+	histMax = tempHist->GetMaximum();
+    }
+  }
+
+  for ( Int_t ihist = 0 ; ihist < nofHists ; ihist++ ) {
+    TString histString = Form("%s",fHistList->At(ihist)->GetName());
+    if ( histString.Contains(specString) ) {
+      TH1F* tempHist = (static_cast<TH1F*>((fHistList->At(ihist))));
+      if ( tempHist->GetXaxis()->GetXmax() > tempHist->GetEntries() )
+	tempHist->SetBins(tempHist->GetEntries(),0,tempHist->GetEntries());
+      tempHist->SetMarkerColor(nofDraws%6+2);
+      tempHist->SetMarkerStyle(nofDraws%4+20);
+      tempHist->SetAxisRange(0.,histMax*1.1,"Y");
+      tempHist->Draw(drawStr);
+      TString tempName = tempHist->GetName();
+      tempName.Remove(0,tempName.First('_')+1);
+      tempName.Remove(0,tempName.First('_')+1);
+      tempLeg->AddEntry(tempHist,tempName,"p");
+      nofDraws++;
+      drawStr = "Psame";
+    }
+  }
+  if ( nofDraws > 1 ) 
+    tempLeg->Draw();
+}
+//_____________________________________________________________________________
+
+//_____________________________________________________________________________
+void FairMonitor::StoreHistograms(TFile* tfile) 
+{
+  if ( !fRunMonitor ) {
+    return;
+  }
+  this->Draw();
+
+  gDirectory = static_cast<TDirectory*>(tfile);
+
+  gDirectory->mkdir("MonitorResults");
+  gDirectory->cd("MonitorResults");
+  TIter next(fHistList);
+  while ( TH1* thist = (static_cast<TH1*>(next())) ) {
+    thist->SetBins(thist->GetEntries(),0,thist->GetEntries());
+    thist->Write();
+  }
+  fCanvas->Write();
+  gDirectory->cd("..");
+
+  fCanvas->Close();
+}
+//_____________________________________________________________________________
+
+//_Private function to fill the map of the tasks_______________________________
+void FairMonitor::GetTaskMap(TTask* tempTask) {
+  TString tempString = Form("%p_%s",tempTask,tempTask->GetName());
+  fTaskMap.insert(std::pair<TString, Int_t> (tempString,0));
+
+  TList* subTaskList = tempTask->GetListOfTasks();
+  if ( !subTaskList ) return;
+  for ( Int_t itask = 0 ; itask < subTaskList->GetEntries() ; itask++ ) {
+    TTask* subTask = static_cast<TTask*>(subTaskList->At(itask));
+    if ( subTask ) 
+      GetTaskMap(subTask);
+  }
+}
+//_____________________________________________________________________________
+
+//_Private function to analyze the object list:________________________________
+// assign to each of the tasks and objects (TClonesArray, pressumably)
+// one number that places them in a hierarchy
+// objects number 0 are the ones in the input array
+// tasks get number from the abs(highest number object they read) increased by one
+// tasks number i create objects number i (if they go to output file) or
+// tasks number i create objects number -i (if they are not persistent)
+void FairMonitor::AnalyzeObjectMap(TTask* tempTask) {
+  TString tempString = Form("%p_%s",tempTask,tempTask->GetName());
+
+  Int_t hierarchyNumber = 0;
+  
+  typedef std::multimap<TString, TString>::iterator bnMapIter;
+  typedef std::map<TString, Int_t>::iterator tiMapIter;
+  tiMapIter iti;
+
+  LOG(DEBUG) << "TASK \"" << tempTask->GetName() << "\" NEEDS:" << FairLogger::endl;
+  for(bnMapIter itb = fTaskRequired.begin(); itb != fTaskRequired.end() ; itb++) {
+    if ( itb->first != tempString ) continue;
+    LOG(DEBUG) << "   \"" << itb->second.Data() << "\"" << FairLogger::endl;
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() ) continue;
+    if ( hierarchyNumber <= TMath::Abs(iti->second) )
+      hierarchyNumber = TMath::Abs(iti->second)+1;
+  }
+
+  //  hierarchyNumber++;
+
+  LOG(DEBUG) << "WILL GET hierarchyNumber = " << hierarchyNumber << FairLogger::endl;
+
+  iti = fTaskMap.find(tempString);
+  if ( iti != fTaskMap.end() ) 
+    iti->second = hierarchyNumber;
+
+  LOG(DEBUG) << "     \"" << tempTask->GetName() << "\" CREATES:" << FairLogger::endl;
+  for(bnMapIter itb = fTaskCreated.begin(); itb != fTaskCreated.end() ; itb++) {
+    if ( itb->first != tempString ) continue;
+    LOG(DEBUG) << " + \"" << itb->second.Data() << "\"" << FairLogger::endl;
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() ) continue;
+    iti->second = hierarchyNumber;
+  }
+
+  for(bnMapIter itb = fTaskCreatedTemp.begin(); itb != fTaskCreatedTemp.end() ; itb++) {
+    if ( itb->first != tempString ) continue;
+    LOG(DEBUG) << " - \"" << itb->second.Data() << "\"" << FairLogger::endl;
+    iti = fObjectMap.find(itb->second);
+    if ( iti == fObjectMap.end() ) continue;
+    iti->second = -hierarchyNumber;
+  }
+
+
+  TList* subTaskList = tempTask->GetListOfTasks();
+  if ( !subTaskList ) return;
+  for ( Int_t itask = 0 ; itask < subTaskList->GetEntries() ; itask++ ) {
+    TTask* subTask = static_cast<TTask*>(subTaskList->At(itask));
+    if ( subTask ) 
+      AnalyzeObjectMap(subTask);
+  }
+
+}
+//_____________________________________________________________________________
+
+ClassImp(FairMonitor)
+
diff --git a/fairtools/FairMonitor.h b/fairtools/FairMonitor.h
new file mode 100644
index 0000000..3d75e61
--- /dev/null
+++ b/fairtools/FairMonitor.h
@@ -0,0 +1,110 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+
+/*
+ * FairMonitor.h
+ *
+ *  Created on: Aug 01, 2015
+ *      Author: r.karabowicz
+ */
+
+#ifndef BASE_FAIRMONITOR_H_
+#define BASE_FAIRMONITOR_H_
+
+#include <list>
+#include <map>
+
+#include "TNamed.h"
+#include "TStopwatch.h"
+
+class TCanvas;
+class TFile;
+class TList;
+class TTask;
+
+class FairMonitor : public TNamed
+{
+  public:
+  static FairMonitor* GetMonitor();
+
+  void EnableMonitor(Bool_t tempBool = kTRUE) { fRunMonitor = tempBool; }
+
+  void StartMonitoring(const TTask* tTask, const char* identStr) {
+    StartTimer        (tTask,identStr);
+    StartMemoryMonitor(tTask,identStr);
+  }
+  void  StopMonitoring(const TTask* tTask, const char* identStr) {
+    StopTimer        (tTask,identStr);
+    StopMemoryMonitor(tTask,identStr);
+  }
+
+  void StartTimer(const TTask* tTask, const char* identStr);
+  void  StopTimer(const TTask* tTask, const char* identStr);
+
+  void StartMemoryMonitor(const TTask* tTask, const char* identStr);
+  void  StopMemoryMonitor(const TTask* tTask, const char* identStr);
+
+  void RecordInfo(const TTask* tTask, const char* identStr, Double_t value);
+
+  void RecordRegister(const char* name, const char* folderName, Bool_t toFile);
+  void RecordGetting(const char* name);
+
+  void SetCurrentTask(TTask* tTask) { fCurrentTask = tTask; }
+
+  virtual void Print(Option_t* option = "") const;
+  virtual void Draw (Option_t* option = "");
+
+  void PrintTask(TString specString) const;
+  void PrintTask(TTask* tempTask, Int_t taskLevel=0) const;
+  void DrawHist(TString specString);
+
+  TList* GetHistList() { return fHistList; }
+
+  void StoreHistograms(TFile* tfile);
+
+  private:
+    static FairMonitor* instance;
+    FairMonitor();
+    ~FairMonitor();
+    FairMonitor(const FairMonitor&);
+    FairMonitor& operator=(const FairMonitor&);
+
+    Bool_t fRunMonitor;
+
+    Double_t fRunTime; 
+    Double_t fRunMem;
+
+    std::map<TString, TStopwatch> fTimerMap;
+    std::map<TString, Int_t> fMemoryMap;
+
+    TList* fHistList;
+    TCanvas* fCanvas;
+
+    Int_t fNoTaskRequired;
+    Int_t fNoTaskCreated;
+
+    TTask* fCurrentTask;
+    std::multimap<TString, TString> fTaskRequired;
+    std::multimap<TString, TString> fTaskCreated;
+    std::multimap<TString, TString> fTaskCreatedTemp;
+    
+    std::map<TString, Int_t> fObjectMap;
+    std::map<TString, Int_t> fTaskMap;
+
+    std::map<TString, std::pair<Double_t, Double_t> > fObjectPos;
+    std::map<TString, std::pair<Double_t, Double_t> > fTaskPos;
+ 
+    void GetTaskMap(TTask* tempTask);
+    void AnalyzeObjectMap(TTask* tempTask);
+
+    ClassDef(FairMonitor, 0)
+};
+
+extern FairMonitor* gMonitor;
+
+#endif  // BASE_FAIRMONITOR_H_
diff --git a/fairtools/FairSystemInfo.cxx b/fairtools/FairSystemInfo.cxx
new file mode 100644
index 0000000..634db71
--- /dev/null
+++ b/fairtools/FairSystemInfo.cxx
@@ -0,0 +1,86 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+/*
+ * FairSystemInfo.cxx
+ *
+ *  Created on: Mar 18, 2015
+ *      Author: f.uhlig
+ */
+
+#include "FairSystemInfo.h"
+
+#include <unistd.h>
+#include <sys/resource.h>
+
+#if defined(__APPLE__) && defined(__MACH__)
+#include <mach/mach.h>
+
+#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
+#include <stdio.h>
+#include <limits>
+
+#else
+#error "Unknown OS."
+#endif
+
+
+Float_t FairSystemInfo::GetMaxMemory()
+{
+  // Returns the maximal used memory in MB
+
+  struct rusage rusage;
+  getrusage( RUSAGE_SELF, &rusage );
+
+#if defined(__APPLE__) && defined(__MACH__)
+  return static_cast<Float_t>(rusage.ru_maxrss)/(1024*1024);
+#else
+  return static_cast<Float_t>(rusage.ru_maxrss)/1024;
+#endif
+  
+}
+
+/**
+ * Returns the current resident set size (physical memory use) measured
+ * in bytes, or zero if the value cannot be determined on this OS.
+ */
+size_t FairSystemInfo::GetCurrentMemory( )
+{
+#if defined(__APPLE__) && defined(__MACH__)
+    /* OSX ------------------------------------------------------ */
+    struct mach_task_basic_info info;
+    mach_msg_type_number_t infoCount = MACH_TASK_BASIC_INFO_COUNT;
+    if ( task_info( mach_task_self( ), MACH_TASK_BASIC_INFO,
+        reinterpret_cast<task_info_t>(&info), &infoCount ) != KERN_SUCCESS )
+//        (task_info_t)&info, &infoCount ) != KERN_SUCCESS )
+        return static_cast<size_t>(0L);      /* Can't access? */
+    return static_cast<size_t>(info.resident_size);
+
+#elif defined(__linux__) || defined(__linux) || defined(linux) || defined(__gnu_linux__)
+    /* Linux ---------------------------------------------------- */
+    long rss = 0L;
+    long pagesize = sysconf(_SC_PAGESIZE);
+    FILE* fp = NULL;
+    if ( (fp = fopen( "/proc/self/statm", "r" )) == NULL )
+        return (size_t)0L;      /* Can't open? */
+    if ( fscanf( fp, "%*s%ld", &rss ) != 1 )
+    {
+        fclose( fp );
+        return (size_t)0L;      /* Can't read? */
+    }
+    fclose( fp );
+    if (rss > 0 && rss < std::numeric_limits<std::size_t>::max()/pagesize) {
+      return (size_t)rss * (size_t)sysconf(_SC_PAGESIZE); 
+    } else {
+       return (size_t)0L;
+    }
+
+#else
+    /* AIX, BSD, Solaris, and Unknown OS ------------------------ */
+    return (size_t)0L;          /* Unsupported. */
+#endif
+}
diff --git a/fairtools/FairSystemInfo.h b/fairtools/FairSystemInfo.h
new file mode 100644
index 0000000..b576af8
--- /dev/null
+++ b/fairtools/FairSystemInfo.h
@@ -0,0 +1,33 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+
+/*
+ * FairSystemInfo.h
+ *
+ *  Created on: Mai 18, 2015
+ *      Author: f.uhlig
+ */
+
+#ifndef BASE_FAIRSYSTEMINFO_H_
+#define BASE_FAIRSYSTEMINFO_H_
+
+#include "Rtypes.h"
+
+class FairSystemInfo
+{
+ public:
+  FairSystemInfo() {}
+  virtual ~FairSystemInfo() {}
+
+  Float_t GetMaxMemory();
+  size_t GetCurrentMemory();  
+
+  ClassDef(FairSystemInfo, 1)
+};
+
+#endif  // BASE_FAIRSYSTEMINFO_H_
diff --git a/fairtools/FairToolsLinkDef.h b/fairtools/FairToolsLinkDef.h
index f2da216..fdf06a9 100644
--- a/fairtools/FairToolsLinkDef.h
+++ b/fairtools/FairToolsLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // $Id: LoggerLinkDef.h,v 1.4 2006/09/15 12:43:35 turany Exp $
 
 #ifdef __CINT__
@@ -9,5 +16,7 @@
 #pragma link C++ global gLogger;
 
 #pragma link C++ class FairLogger+;
+#pragma link C++ class FairMonitor+;
+#pragma link C++ class FairSystemInfo;
 
 #endif
diff --git a/fairtools/README.md b/fairtools/README.md
new file mode 100644
index 0000000..a0d1477
--- /dev/null
+++ b/fairtools/README.md
@@ -0,0 +1,6 @@
+fairtools
+========
+
+Tools used by FairRoot:
+
+- `FairLogger` allows writing to the log.
\ No newline at end of file
diff --git a/ffd/CMakeLists.txt b/ffd/CMakeLists.txt
index b2c295a..a35bf90 100644
--- a/ffd/CMakeLists.txt
+++ b/ffd/CMakeLists.txt
@@ -3,23 +3,26 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/ffd
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(FFD_SRCS
 MpdFfdGeo.cxx 
diff --git a/fsa/CMakeLists.txt b/fsa/CMakeLists.txt
index b62bd1f..a6e5696 100644
--- a/fsa/CMakeLists.txt
+++ b/fsa/CMakeLists.txt
@@ -6,21 +6,20 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/fsa
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(FSA_SRCS
 MpdFsaGeo.cxx 
diff --git a/gconfig/basiclibs.C b/gconfig/basiclibs.C
index 979c68b..b8d9809 100644
--- a/gconfig/basiclibs.C
+++ b/gconfig/basiclibs.C
@@ -13,8 +13,8 @@ void basiclibs()
   gSystem->Load("libPythia6");
   gSystem->Load("libPluto");
   gSystem->Load("libPhysics");
-  gSystem->Load("libNet");
-  gSystem->Load("libTree");
+  gSystem->Load("libNet");  
+  gSystem->Load("libTree"); 
   gSystem->Load("libMinuit");
   gSystem->Load("libMathMore");
 
@@ -22,6 +22,7 @@ void basiclibs()
   gSystem->Load("libProofPlayer");
   gSystem->Load("libGX11TTF");
   gSystem->Load("libGX11");
+  gSystem->Load("libboost_regex");
 
   gSystem->Load("libGdml");
-}
+}  
diff --git a/gconfig/constants.h b/gconfig/constants.h
deleted file mode 100644
index 7c45e62..0000000
--- a/gconfig/constants.h
+++ /dev/null
@@ -1,5 +0,0 @@
-enum CoordinateSystem {sysCenterOfMass, sysLaboratory};
-const CoordinateSystem gCoordinateSystem = sysCenterOfMass;
-
-enum VisualizationColoring {selectedColoring, levelColoring, defaultColoring};
-const VisualizationColoring gVisualizationColoring = selectedColoring;
diff --git a/gconfig/g3libs.C b/gconfig/g3libs.C
index d604c1f..1af71fc 100644
--- a/gconfig/g3libs.C
+++ b/gconfig/g3libs.C
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #include <iostream>
 
 Bool_t isLibrary(const char* libName)
@@ -16,6 +23,8 @@ void g3libs()
      gSystem->Load("libdummies.so");
                    // libdummies.so needed from geant3_+vmc version 0.5
 
+  gSystem->Load("libPythia6.so");
+  gSystem->Load("libEGPythia6.so");
   gSystem->Load("libgeant321.so");
 
   cout << "Loading Geant3 libraries ... finished" << endl;
diff --git a/gconfig/rootlogon.C b/gconfig/rootlogon.C
new file mode 100644
index 0000000..f8f7912
--- /dev/null
+++ b/gconfig/rootlogon.C
@@ -0,0 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
+rootlogon()
+{
+  gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
+  basiclibs();
+  
+  // Load this example libraries
+        gSystem->Load("libFairTools");
+  	gSystem->Load("libGeoBase");
+	gSystem->Load("libParBase");
+	gSystem->Load("libBase");
+	gSystem->Load("libMCStack");
+	gSystem->Load("libField");
+	gSystem->Load("libPassive");
+	gSystem->Load("libGen");
+	gSystem->Load("libPGen");
+	gSystem->Load("libGeane");
+}
diff --git a/geane/CMakeLists.txt b/geane/CMakeLists.txt
index b27906d..08abdb4 100644
--- a/geane/CMakeLists.txt
+++ b/geane/CMakeLists.txt
@@ -1,37 +1,51 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${GEANT3_INCLUDE_DIR}
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/trackbase 
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/trackbase
+${CMAKE_SOURCE_DIR}/base/source 
 ${CMAKE_SOURCE_DIR}/geane
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+  ${GEANT3_INCLUDE_DIR}
+  ${Geant3_INCLUDE_DIRS}
+)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
 
-set(SRCS
-FairGeane.cxx       
-FairGeanePro.cxx
+Set(SRCS
+  FairGeane.cxx       
+  FairGeanePro.cxx
 )
 
 Set(HEADERS )
 Set(LINKDEF GeaneLinkDef.h)
 Set(LIBRARY_NAME Geane)
-Set(DEPENDENCIES Base TrkBase Geom VMC EG Physics Cint Core)
+Set(DEPENDENCIES Base TrkBase VMC)
 
 GENERATE_LIBRARY()
-
-
diff --git a/geane/FairGeane.cxx b/geane/FairGeane.cxx
index 859c258..ec6c6a5 100644
--- a/geane/FairGeane.cxx
+++ b/geane/FairGeane.cxx
@@ -1,17 +1,28 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the GEANE initialization
 //
 // Author: M. Al-Turany
 //
 #include "FairGeane.h"
-#include "FairGeaneApplication.h"
-#include "FairField.h"
-#include "FairRunAna.h"
-#include "TGeoManager.h"
-#include "TString.h"
-#include "TGeoManager.h"
-#include "TVirtualMC.h"
-#include "TROOT.h"
-#include "TSystem.h"
+
+#include "FairField.h"                  // for FairField
+#include "FairGeaneApplication.h"       // for FairGeaneApplication
+#include "FairRunAna.h"                 // for FairRunAna
+
+#include "Riosfwd.h"                    // for ostream
+#include "TGeoManager.h"                // for TGeoManager
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TString.h"                    // for TString, operator!=, etc
+#include "TSystem.h"                    // for TSystem, gSystem
+
+#include <stdlib.h>                     // for getenv
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using std::cout;
 using std::endl;
@@ -66,7 +77,10 @@ InitStatus FairGeane::Init()
 
   TString work = getenv("VMCWORKDIR");
   TString work_config=work+"/gconfig/";
+  work_config.ReplaceAll("//","/");
   TString config_dir= getenv("CONFIG_DIR");
+  config_dir.ReplaceAll("//","/");
+   
   Bool_t AbsPath=kFALSE;
   if (!config_dir.EndsWith("/")) { config_dir+="/"; }
 
@@ -113,7 +127,7 @@ InitStatus FairGeane::Init()
   //gROOT->ProcessLine("SetCuts()");
 
   FairField* field=FairRunAna::Instance()->GetField();
-  field->Print();
+  field->Print("");
   fApp->SetField(field);
 
   fApp->InitMC(ConfigMacro.Data(), "");
@@ -135,7 +149,7 @@ FairGeane::~FairGeane()
 {
 
 }
-void FairGeane::SetField(FairField* field)
+void FairGeane::SetField(FairField* /*field*/)
 {
 
   cout<< "\033[5m\033[31m -W- FairGeane::SetField  This method is not used anymore, use FairRunAna::SetField instead \033[0m " << endl;
diff --git a/geane/FairGeane.h b/geane/FairGeane.h
index b2216dc..8425f50 100644
--- a/geane/FairGeane.h
+++ b/geane/FairGeane.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the GEANE initialization
 //
 // Author: M. Al-Turany
@@ -5,8 +12,10 @@
 #ifndef FAIRGeane_H
 #define FAIRGeane_H
 
-#include "FairTask.h"
-#include "TString.h"
+#include "FairTask.h"                   // for FairTask, InitStatus
+
+#include "Rtypes.h"                     // for FairGeane::Class, ClassDef, etc
+#include "TString.h"                    // for TString
 
 class FairGeaneApplication;
 class FairField;
diff --git a/geane/FairGeanePro.cxx b/geane/FairGeanePro.cxx
index 080c07a..0860bbf 100644
--- a/geane/FairGeanePro.cxx
+++ b/geane/FairGeanePro.cxx
@@ -1,26 +1,35 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the interface to propagate track parameters with GEANE
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
 //
-
 #include "FairGeanePro.h"
-#include "FairTrackParP.h"
-#include "FairTrackParH.h"
-#include "FairRunAna.h"
-#include "FairField.h"
-#include "FairGeaneUtil.h"
-
-#include "TGeant3TGeo.h"
-#include "TVector3.h"
-#include "TArrayD.h"
-#include "TDatabasePDG.h"
-#include "TGeoTorus.h"
-#include "TMatrixFSym.h"
-#include "TVirtualMC.h"
-#include "TGeant3.h"
-#include "FairGeaneApplication.h"
-#include <iostream>
-#include <cmath>
+
+#include "FairGeaneApplication.h"       // for FairGeaneApplication
+#include "FairGeaneUtil.h"              // for FairGeaneUtil
+#include "FairTrackPar.h"               // for FairTrackPar
+#include "FairTrackParH.h"              // for FairTrackParH
+#include "FairTrackParP.h"              // for FairTrackParP
+
+#include "Riosfwd.h"                    // for ostream
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TGeant3.h"                    // for TGeant3, Ertrio_t
+#include "TGeoTorus.h"                  // for TGeoTorus
+#include "TMath.h"                      // for pow, ACos, Cos, sqrt
+#include "TMathBase.h"                  // for Abs
+#include "TVector3.h"                   // for TVector3, operator-, etc
+#include "TVirtualMC.h"                 // for gMC
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <cmath>                        // IWYU pragma: keep for fabs
+// IWYU pragma: no_include <architecture/i386/math.h>
 
 using std::cout;
 using std::endl;
@@ -28,11 +37,11 @@ using std::endl;
 // -----   Default constructor   -------------------------------------------
 FairGeanePro::FairGeanePro()
   : TNamed("Geane", "Propagate Tracks"),
-    gMC3((TGeant3*) gMC),
+    gMC3(static_cast<TGeant3 *> (TVirtualMC::GetMC())),
     fPropOption(""),
     nepred(1),
     fdbPDG(TDatabasePDG::Instance()),
-    afErtrio(gMC3->fErtrio),
+    afErtrio(NULL),
     GeantCode(0),
     ProMode(0),
     VName(""),
@@ -48,12 +57,16 @@ FairGeanePro::FairGeanePro()
     fvwi(TVector3(0., 0., 0.)),
     ftrklength(0.),
     flag(0),
-    fApp(FairGeaneApplication::Instance())
+    fApp(FairGeaneApplication::Instance()),
+    fPrintErrors(kTRUE)
 {
   if(gMC3==NULL) {
     std::cerr<<"FairGeanePro::TGeant3 has not been initialized! ABORTING!"<<std::endl;
     throw;
   }
+  afErtrio = gMC3->fErtrio;
+
+
   //  nepred=1;
   xlf[0] = 0.;
   //  fdbPDG= TDatabasePDG::Instance();
@@ -148,7 +161,7 @@ Bool_t FairGeanePro::Propagate(FairTrackParH* TParam, FairTrackParH* TEnd, Int_t
       Int_t option;
       if(VEnter) { option =1; }
       else { option =2; }
-      gMC3->Eufilv(1, ein, (Char_t*)VName.Data(), &VCopyNo, &option);
+      gMC3->Eufilv(1, ein, const_cast<Char_t*>(VName.Data()), &VCopyNo, &option);
     } else if(fPropOption.Contains("L")) {
       if(fPCA == 0) {
         gMC3->Eufill(nepred, ein,xlf);
@@ -197,7 +210,7 @@ Bool_t FairGeanePro::Propagate(FairTrackParH* TParam, FairTrackParH* TEnd, Int_t
   return kTRUE;
 
 }
-Bool_t FairGeanePro::Propagate(FairTrackParP* TStart, FairTrackParH* TEnd, Int_t PDG)
+Bool_t FairGeanePro::Propagate(FairTrackParP* /*TStart*/, FairTrackParH* /*TEnd*/, Int_t /*PDG*/)
 {
   // Propagate a parabola track (SD system) and return a helix (SC system) (not used nor implemented)
   cout << "FairGeanePro::Propagate(FairTrackParP *TParam, FairTrackParH &TEnd, Int_t PDG) : (not used nor implemented)" << endl;
@@ -315,7 +328,7 @@ Bool_t FairGeanePro::Propagate(FairTrackParP* TStart, FairTrackParP* TEnd, Int_t
 }
 
 
-Bool_t FairGeanePro::Propagate(FairTrackParH* TStart, FairTrackParP* TEnd, Int_t PDG)
+Bool_t FairGeanePro::Propagate(FairTrackParH* /*TStart*/, FairTrackParP* /*TEnd*/, Int_t /*PDG*/)
 {
   // Propagate a helix track (SC system) and return a parabola (SD system) (not used nor implemented)
   cout << "FairGeanePro::Propagate(FairTrackParH *TParam, FairTrackParP &TEnd, Int_t PDG) not implemented" << endl;
@@ -437,8 +450,13 @@ Bool_t FairGeanePro::PropagateToVolume(TString VolName, Int_t CopyNo , Int_t opt
 Bool_t FairGeanePro::PropagateToLength(Float_t length)
 {
   // define final length (option "L")
-  xlf[0]=length;
-  fPropOption="LE";
+ if(length < 0) {
+     xlf[0]=-length;
+     fPropOption="BLE";
+  }else {
+     xlf[0]=length;
+     fPropOption="LE";
+  }
   ProMode=1; //need errors in representation 1 (SC)(see Geane doc)
   return kTRUE;
 }
@@ -582,9 +600,9 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
   // .. Di : distance between track and wire in the PCA
   // .. trklength : track length to add to the GEANE one
 
-  Float_t pf[3] = {point.X(), point.Y(), point.Z()};
-  Float_t w1[3] = {wire1.X(), wire1.Y(), wire1.Z()};
-  Float_t w2[3] = {wire2.X(), wire2.Y(), wire2.Z()};
+  Float_t pf[3] = {static_cast<Float_t>(point.X()), static_cast<Float_t>(point.Y()), static_cast<Float_t>(point.Z())};
+  Float_t w1[3] = {static_cast<Float_t>(wire1.X()), static_cast<Float_t>(wire1.Y()), static_cast<Float_t>(wire1.Z())};
+  Float_t w2[3] = {static_cast<Float_t>(wire2.X()), static_cast<Float_t>(wire2.Y()), static_cast<Float_t>(wire2.Z())};
 
   GeantCode=fdbPDG->ConvertPdgToGeant3(PDGCode);
 
@@ -627,7 +645,7 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
   // maximum distance calculated 2 * geometric distance
   // start point - end point (the point to which we want
   // to find the PCA)
-  Float_t stdlength[1] = {maxdistance};
+  Float_t stdlength[1] = {static_cast<Float_t>(maxdistance)};
 
   gMC3->Eufill(1, ein, stdlength);
 
@@ -652,14 +670,23 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
         || (po2[0] == po3[0] && po2[1] == po3[1] && po2[2] == po3[2])) {
       Int_t quitFlag=0;
       Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(pf),vpf,Di,Le,quitFlag);
-      if(quitFlag!=0) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+      if(quitFlag!=0) {
+        if(fPrintErrors) { std::cerr << "FairGeanePro:FindPCA: Track2ToPoint quitFlag " << quitFlag << " ABORT" << std::endl; }
+        return 1;
+      } //abort
     } else {
       Track3ToPoint(TVector3(po1),TVector3(po2),TVector3(po3),TVector3(pf),vpf,flg,Di,Le,Rad);
       if(flg==1) {
         Int_t quitFlag=0;
         Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(pf),vpf,Di,Le,quitFlag);
-        if(quitFlag!=0) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
-      } else if(flg==2) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+        if(quitFlag!=0) {
+          if(fPrintErrors) { std::cerr << "FairGeanePro:FindPCA: Track2ToPoint quitFlag " << quitFlag << " ABORT" << std::endl; }
+          return 1;
+        } //abort
+      } else if(flg==2) {
+        if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track3ToPoint flg " << flg << " ABORT"<< std::endl; }
+        return 1;
+      } //abort
     }
     // if the propagation to closest approach to a POINT  is performed
     // vwi is the point itself (with respect to which the PCA is calculated)
@@ -675,9 +702,12 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
         Int_t quitFlag=0;
         dist1<dist2?Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w1),vpf,Di,Le,quitFlag):
         Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w2),vpf,Di,Le,quitFlag);
-        if(quitFlag!=0) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+        if(quitFlag!=0) {
+          if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToPoint quitFlag " << quitFlag << " ABORT"<< std::endl; }
+          return 1;
+        } //abort
       } else if(flg==2) {
-        std::cerr<<"ABORT"<<std::endl;
+        if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToLine flg " << flg << " ABORT"<< std::endl; }
         return 1;
       }
     } else {
@@ -692,9 +722,12 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
           Int_t quitFlag=0;
           dist1<dist2?Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w1),vpf,Di,Le,quitFlag):
           Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w2),vpf,Di,Le,quitFlag);
-          if(quitFlag!=0) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+          if(quitFlag!=0) {
+            if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToPoint quitFlag " << quitFlag << " ABORT"<< std::endl; }
+            return 1;
+          } //abort
         } else if(flg==2) {
-          std::cerr<<"ABORT"<<std::endl;
+          if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToLine flg " << flg << " ABORT"<< std::endl; }
           return 1;
         }
       } else if(flg==2) {
@@ -703,19 +736,25 @@ int FairGeanePro::FindPCA(Int_t pca, Int_t PDGCode, TVector3 point, TVector3 wir
 
         dist1<dist2?Track3ToPoint(TVector3(po1),TVector3(po2),TVector3(po3),TVector3(w1),vpf,flg,Di,Le,Rad):
         Track3ToPoint(TVector3(po1),TVector3(po2),TVector3(po3),TVector3(w2),vpf,flg,Di,Le,Rad);
-        if(flg==2) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+        if(flg==2) {
+          if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track3ToLine flg " << flg << " ABORT"<< std::endl; }
+          return 1;
+        } //abort
       } else if(flg==3) {
         dist1 = (vwi-TVector3(w1)).Mag();
         dist2 = (vwi-TVector3(w2)).Mag();
         Int_t quitFlag=0;
         dist1<dist2?Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w1),vpf,Di,Le,quitFlag):
         Track2ToPoint(TVector3(po1),TVector3(po3),TVector3(w2),vpf,Di,Le,quitFlag);
-        if(quitFlag!=0) {std::cerr<<"ABORT"<<std::endl; return 1;} //abort
+        if(quitFlag!=0) {
+          if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToPoint quitFlag " << quitFlag << " ABORT"<< std::endl; }
+          return 1;
+        } //abort
       } else if(flg==4) {
         Track2ToLine(TVector3(po1),TVector3(po3),TVector3(w1),
                      TVector3(w2),vpf,vwi,flg,Di,Le);
         if(flg==2) {
-          std::cerr<<"ABORT"<<std::endl;
+          if(fPrintErrors) { std::cerr<<"FairGeanePro:FindPCA: Track2ToLine flg " << flg << " ABORT"<< std::endl; }
           return 1;
         }
       }
@@ -1026,7 +1065,8 @@ void FairGeanePro::Track3ToLine(TVector3 X1, TVector3 X2, TVector3 X3,
 
   // select the right solution
   dmin = 1.e+08;
-  imin=-1;
+  imin=0;  // This was set to -1 which could make problem if the indx is negative!! (MT)
+
   for(Int_t j=0; j<it; j++) {
     Pointw[0] = B[0] + sol4[j]*M[0];
     Pointw[1] = B[1] + sol4[j]*M[1];
diff --git a/geane/FairGeanePro.h b/geane/FairGeanePro.h
index d9b5f0c..15fa67d 100644
--- a/geane/FairGeanePro.h
+++ b/geane/FairGeanePro.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the interface to propagate track parameters with GEANE
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
@@ -5,18 +12,18 @@
 #ifndef FAIRGEANEPRO_H
 #define FAIRGEANEPRO_H 1
 
-#include "TNamed.h"
-#include "TVector3.h"
-#include "TGeant3.h"
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Int_t, Bool_t, Double_t, etc
+#include "TGeant3.h"                    // for Ertrio_t, etc
+#include "TString.h"                    // for TString
+#include "TVector3.h"                   // for TVector3
 
-//class TGeant3;
-class TDatabasePDG;
-class TArrayD;
 class FairTrackPar;
 class FairTrackParP;
 class FairTrackParH;
-class FairField;
 class FairGeaneApplication;
+class TDatabasePDG;
 
 class FairGeanePro : public TNamed
 {
@@ -70,6 +77,7 @@ class FairGeanePro : public TNamed
     // transport matrix
     void GetTransportMatrix(Double_t trm[5][5]);
 
+    void SetPrintErrors(bool printError = kTRUE) { fPrintErrors = printError; }
 
   private:
 
@@ -109,6 +117,9 @@ class FairGeanePro : public TNamed
     FairGeaneApplication* fApp;
     Double_t trpmat[5][5];
 
+    // if kFALSE --> do not print the ABORT messages
+    Bool_t fPrintErrors;
+
     FairGeanePro(const FairGeanePro&);
     FairGeanePro& operator=(const FairGeanePro&);
 
diff --git a/geane/GeaneLinkDef.h b/geane/GeaneLinkDef.h
index 34bb7e7..bae0d88 100644
--- a/geane/GeaneLinkDef.h
+++ b/geane/GeaneLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifdef __CINT__
 
 #pragma link off all globals;
diff --git a/geane/README.md b/geane/README.md
new file mode 100644
index 0000000..4a71c7f
--- /dev/null
+++ b/geane/README.md
@@ -0,0 +1,4 @@
+geane
+========
+
+The [GEANE](http://iopscience.iop.org/1742-6596/119/3/032018) allows particle trajectory transport (the track parameters and errors) through the given geometry and magnetic fields. The GEANE was originally part of the [GEANT3](http://en.wikipedia.org/wiki/GEANT-3) Monte Carlo tranport package. Standalone GEANE was developed to help track finding and fitting in the analysis stages. 
diff --git a/generators/CMakeLists.txt b/generators/CMakeLists.txt
index 699e7cd..55ede56 100644
--- a/generators/CMakeLists.txt
+++ b/generators/CMakeLists.txt
@@ -1,49 +1,64 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-# Check for gcc version, since for gcc 4 one has to add friend-injection
-# as option to compile FairPlutoGenerator
 EXEC_PROGRAM( gcc ARGS "-dumpversion" OUTPUT_VARIABLE GCC_VERSION )
 STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]" "\\1" req_gcc_major_vers "${GCC_VERSION}")
 STRING(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]" "\\1" req_gcc_minor_vers "${GCC_VERSION}")
 IF(${req_gcc_major_vers} MATCHES "4" AND NOT ${req_gcc_minor_vers} MATCHES "0")
-  SET_SOURCE_FILES_PROPERTIES(FairPlutoGenerator.cxx PROPERTIES COMPILE_FLAGS
-  "-ffriend-injection")
 ENDIF(${req_gcc_major_vers} MATCHES "4" AND NOT ${req_gcc_minor_vers} MATCHES "0")
 
-
-
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR}
 ${PLUTO_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/field 
-${CMAKE_SOURCE_DIR}/base 
+${CMAKE_SOURCE_DIR}/geobase
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
+${CMAKE_SOURCE_DIR}/base/sim
 ${CMAKE_SOURCE_DIR}/generators 
-${CMAKE_SOURCE_DIR}/gconfig
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/config
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 ${PLUTO_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(SRCS
-FairAsciiGenerator.cxx    
-FairBoxGenerator.cxx      
-FairIonGenerator.cxx      
-FairParticleGenerator.cxx 
-FairShieldGenerator.cxx   
-FairPlutoGenerator.cxx    
-FairPlutoReactionGenerator.cxx    
-FairUrqmdGenerator.cxx    
+FairAsciiGenerator.cxx
+FairBoxGenerator.cxx
+FairIonGenerator.cxx
+FairParticleGenerator.cxx
+FairShieldGenerator.cxx
+FairPlutoReactionGenerator.cxx
+FairUrqmdGenerator.cxx
 FairEvtGenGenerator.cxx
+
+MpdMCEventHeader.cxx
+MpdLAQGSMGenerator.cxx
+MpdHypYPtGenerator.cxx
+MpdRainGenerator.cxx
+MpdPlutoGenerator.cxx
+MpdPHSDGenerator.cxx
+MpdUrqmdGenerator.cxx
+MpdGetNumEvents.cxx
+MpdHistoGenerator.cxx
+Mpd3fdGenerator.cxx
+MpdVHLLEGenerator.cxx
 )
 
 Set(HEADERS )
diff --git a/generators/FairAsciiGenerator.cxx b/generators/FairAsciiGenerator.cxx
index b9c2f19..8d0ad89 100644
--- a/generators/FairAsciiGenerator.cxx
+++ b/generators/FairAsciiGenerator.cxx
@@ -1,17 +1,21 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairAsciiGenerator source file                  -----
 // -----          Created 09/06/04  by V. Friese / D.Bertini           -----
 // -------------------------------------------------------------------------
 #include "FairAsciiGenerator.h"
 
-#include "FairPrimaryGenerator.h"
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairLogger.h"
 
-#include "TDatabasePDG.h"
-
-#include <iostream>
-
-using std::cout;
-using std::endl;
+#include <stddef.h>                     // for NULL
+#include <climits>                      // for INT_MAX
 
 // -----   Default constructor   ------------------------------------------
 FairAsciiGenerator::FairAsciiGenerator()
@@ -31,10 +35,11 @@ FairAsciiGenerator::FairAsciiGenerator(const char* fileName)
    fFileName(fileName)
 {
   //  fFileName  = fileName;
-  cout << "-I FairAsciiGenerator: Opening input file " << fileName << endl;
-  fInputFile = new ifstream(fFileName);
+  LOG(INFO) << "FairAsciiGenerator: Opening input file " 
+	    << fileName << FairLogger::endl;
+  fInputFile = new std::ifstream(fFileName);
   if ( ! fInputFile->is_open() ) {
-    Fatal("FairAsciiGenerator","Cannot open input file.");
+    LOG(FATAL) << "Cannot open input file." << FairLogger::endl;
   }
 
   // fPDG=TDatabasePDG::Instance();
@@ -58,7 +63,8 @@ Bool_t FairAsciiGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
   // Check for input file
   if ( ! fInputFile->is_open() ) {
-    cout << "-E FairAsciiGenerator: Input file not open!" << endl;
+    LOG(ERROR) << "FairAsciiGenerator: Input file not open!" 
+	       << FairLogger::endl;
     return kFALSE;
   }
 
@@ -72,18 +78,21 @@ Bool_t FairAsciiGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   Double_t px = 0., py = 0., pz = 0.;
 
   // Read event header line from input file
-  *fInputFile >> ntracks >> eventID >>  vx >>  vy >>  vz;
+  *fInputFile >> ntracks;
+  if (fInputFile->fail() || ntracks < 0 || ntracks > (INT_MAX-1)) LOG(FATAL) << "Error reading the number of events from event header." << FairLogger::endl;
+  *fInputFile >> eventID >>  vx >>  vy >>  vz;
 
   // If end of input file is reached : close it and abort run
   if ( fInputFile->eof() ) {
-    cout << "-I FairAsciiGenerator: End of input file reached " << endl;
+    LOG(INFO) << "FairAsciiGenerator: End of input file reached " 
+	      << FairLogger::endl;
     CloseInput();
     return kFALSE;
   }
 
-  cout << "-I FairAsciiGenerator: Event " << eventID << ",  vertex = ("
-       << vx << "," << vy << "," << vz << ") cm,  multiplicity "
-       << ntracks << endl;
+  LOG(INFO) << "FairAsciiGenerator: Event " << eventID << ",  vertex = ("
+	    << vx << "," << vy << "," << vz << ") cm,  multiplicity "
+	    << ntracks << FairLogger::endl;
 
   // Loop over tracks in the current event
   for (Int_t itrack=0; itrack<ntracks; itrack++) {
@@ -111,8 +120,8 @@ void FairAsciiGenerator::CloseInput()
 {
   if ( fInputFile ) {
     if ( fInputFile->is_open() ) {
-      cout << "-I FairAsciiGenerator: Closing input file "
-           << fFileName << endl;
+      LOG(INFO) << "FairAsciiGenerator: Closing input file "
+		<< fFileName << FairLogger::endl;
       fInputFile->close();
     }
     delete fInputFile;
diff --git a/generators/FairAsciiGenerator.h b/generators/FairAsciiGenerator.h
index 71965e9..c48ce71 100644
--- a/generators/FairAsciiGenerator.h
+++ b/generators/FairAsciiGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairAsciiGenerator header file                  -----
 // -----          Created 09/06/04  by V. Friese / D.Bertini           -----
@@ -22,16 +29,15 @@
 #ifndef FAIR_ASCIIGENERATOR_H
 #define FAIR_ASCIIGENERATOR_H
 
+#include "FairGenerator.h"              // for FairGenerator
 
-#include "FairGenerator.h"
+#include "Riosfwd.h"                    // for ifstream
+#include "Rtypes.h"                     // for FairAsciiGenerator::Class, etc
 
-#include <fstream>
+#include <fstream>                      // for ifstream
 
-class TDatabasePDG;
 class FairPrimaryGenerator;
 
-
-
 class FairAsciiGenerator : public FairGenerator
 {
 
@@ -61,7 +67,7 @@ class FairAsciiGenerator : public FairGenerator
 
   private:
 
-    ifstream* fInputFile;               //! Input file stream
+    std::ifstream* fInputFile;               //! Input file stream
     const Char_t* fFileName;            //! Input file Name
 
 
diff --git a/generators/FairBoxGenerator.cxx b/generators/FairBoxGenerator.cxx
index cc7618c..b579744 100644
--- a/generators/FairBoxGenerator.cxx
+++ b/generators/FairBoxGenerator.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----            FairBoxGenerator source file                        -----
 // -----          Created 09/09/04  by Yu.Kharlov
@@ -55,6 +62,73 @@ FairBoxGenerator::FairBoxGenerator(Int_t pdgid, Int_t mult) :
   // Constructor. Set default kinematics limits
   SetPhiRange  ();
 }
+
+// ------------------------------------------------------------------------
+FairBoxGenerator::FairBoxGenerator(const FairBoxGenerator& rhs) :
+  FairGenerator(rhs),
+  fPDGType(rhs.fPDGType),fMult(rhs.fMult),fPDGMass(rhs.fPDGMass),
+  fPtMin(rhs.fPtMin),fPtMax(rhs.fPtMax),
+  fPhiMin(rhs.fPhiMin),fPhiMax(rhs.fPhiMax),fEtaMin(rhs.fEtaMin),
+  fEtaMax(rhs.fEtaMax),fYMin(rhs.fYMin),fYMax(rhs.fYMax),
+  fPMin(rhs.fPMin),fPMax(rhs.fPMax),fThetaMin(rhs.fThetaMin),
+  fThetaMax(rhs.fThetaMax),fX(rhs.fX),fY(rhs.fY),fZ(rhs.fZ),
+  fX1(rhs.fX1),fY1(rhs.fY1),fX2(rhs.fX2),fY2(rhs.fY2),
+  fEtaRangeIsSet(rhs.fEtaRangeIsSet), fYRangeIsSet(rhs.fYRangeIsSet),
+  fThetaRangeIsSet(rhs.fThetaRangeIsSet),fCosThetaIsSet(rhs.fCosThetaIsSet),
+  fPtRangeIsSet(rhs.fPtRangeIsSet), fPRangeIsSet(rhs.fPRangeIsSet),
+  fPointVtxIsSet(rhs.fPointVtxIsSet),fBoxVtxIsSet(rhs.fBoxVtxIsSet),
+  fDebug(rhs.fDebug)
+{
+  // Copy constructor
+}
+
+// ------------------------------------------------------------------------
+FairBoxGenerator& FairBoxGenerator::operator=(const FairBoxGenerator& rhs)
+{
+  // Assignment operator
+
+  // check assignment to self
+  if (this == &rhs) return *this;
+
+  // base class assignment
+  TNamed::operator=(rhs);
+
+  // assignment operator
+  fPDGType = rhs.fPDGType;
+  fMult = rhs.fMult;
+  fPDGMass = rhs.fPDGMass;
+  fPtMin = rhs.fPtMin;
+  fPtMax = rhs.fPtMax;
+  fPhiMin = rhs.fPhiMin;
+  fPhiMax = rhs.fPhiMax;
+  fEtaMin = rhs.fEtaMin;
+  fEtaMax = rhs.fEtaMax;
+  fYMin = rhs.fYMin;
+  fYMax = rhs.fYMax;
+  fPMin = rhs.fPMin;
+  fPMax = rhs.fPMax;
+  fThetaMin = rhs.fThetaMin;
+  fThetaMax = rhs.fThetaMax;
+  fX = rhs.fX;
+  fY = rhs.fY;
+  fZ = rhs.fZ;
+  fX1 = rhs.fX1;
+  fY1 = rhs.fY1;
+  fX2 = rhs.fX2;
+  fY2 = rhs.fY2;
+  fEtaRangeIsSet = rhs.fEtaRangeIsSet;
+  fYRangeIsSet = rhs.fYRangeIsSet;
+  fThetaRangeIsSet = rhs.fThetaRangeIsSet;
+  fCosThetaIsSet = rhs.fCosThetaIsSet;
+  fPtRangeIsSet = rhs.fPtRangeIsSet;
+  fPRangeIsSet = rhs.fPRangeIsSet;
+  fPointVtxIsSet = rhs.fPointVtxIsSet;
+  fBoxVtxIsSet = rhs.fBoxVtxIsSet;
+  fDebug = rhs.fDebug;
+
+  return *this;
+}
+
 // ------------------------------------------------------------------------
 Bool_t  FairBoxGenerator::Init()
 {
@@ -83,13 +157,15 @@ Bool_t  FairBoxGenerator::Init()
   TDatabasePDG* pdgBase = TDatabasePDG::Instance();
   TParticlePDG* particle = pdgBase->GetParticle(fPDGType);
 
-  if (! particle) { Fatal("FairBoxGenerator","PDG code %d not defined.",fPDGType); }
-
+  if (! particle) {
+    Fatal("FairBoxGenerator","PDG code %d not defined.",fPDGType);
+  } else {
+    fPDGMass = particle->Mass();
+    // printf("particle->Mass() = %f \n", fPDGMass);
+    return kTRUE;
+  }
 
-  fPDGMass = particle->Mass();
-// printf("particle->Mass() = %f \n", fPDGMass);
   return kTRUE;
-
 }
 
 // ------------------------------------------------------------------------
@@ -152,6 +228,16 @@ Bool_t FairBoxGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   return kTRUE;
 
 }
+
+// ------------------------------------------------------------------------
+FairGenerator* FairBoxGenerator::CloneGenerator() const
+{
+  // Clone for worker (used in MT mode only)
+
+  return new FairBoxGenerator(*this);
+}
+
+
 // ------------------------------------------------------------------------
 
 
diff --git a/generators/FairBoxGenerator.h b/generators/FairBoxGenerator.h
index ba4b7be..f93e0f3 100644
--- a/generators/FairBoxGenerator.h
+++ b/generators/FairBoxGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairBoxGenerator header file                    -----
 // -----          Created 09/09/04  by Yu.Kharlov                      -----
@@ -27,9 +34,9 @@
 #ifndef FAIR_BOXGENERATOR_H
 #define FAIR_BOXGENERATOR_H
 
-#include "FairGenerator.h"
+#include "FairGenerator.h"              // for FairGenerator
 
-#include <iostream>
+#include "Rtypes.h"                     // for Double32_t, Bool_t, kTRUE, etc
 
 class FairPrimaryGenerator;
 
@@ -101,6 +108,14 @@ class FairBoxGenerator : public FairGenerator
      **/
     virtual Bool_t ReadEvent(FairPrimaryGenerator* primGen);
 
+    /** Clone this object (used in MT mode only) */
+    virtual FairGenerator* CloneGenerator() const;
+
+  protected:
+    /** Copy constructor. **/
+    FairBoxGenerator(const FairBoxGenerator&);
+    FairBoxGenerator& operator=(const FairBoxGenerator&);
+
   private:
     Int_t      fPDGType;             // Particle type (PDG encoding)
     Int_t      fMult;                // Multiplicity
diff --git a/generators/FairEvtGenGenerator.cxx b/generators/FairEvtGenGenerator.cxx
index 6468667..e2e8fc1 100644
--- a/generators/FairEvtGenGenerator.cxx
+++ b/generators/FairEvtGenGenerator.cxx
@@ -1,27 +1,27 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----             FairEvtGenGenerator source file                      -----
 // -----          Created 09/10/06  by S. Spataro                      -----
 // -------------------------------------------------------------------------
 #include "FairEvtGenGenerator.h"
 
-#include "FairPrimaryGenerator.h"
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairLogger.h"
 
-#include <iostream>
-#include <cstdio>
+#include "Riosfwd.h"                    // for ostream
+#include "TF1.h"                        // for TF1
+#include "TRandom.h"                    // for TRandom, gRandom
 
-// New includes here:
+#include <algorithm>                    // for max
 
-#include "TMath.h"
-#include "TRandom.h"
-
-using std::cout;
-using std::endl;
 using std::max;
 
-
-
-
-
 // -----   Default constructor   ------------------------------------------
 FairEvtGenGenerator::FairEvtGenGenerator()
   : FairGenerator(),
@@ -43,7 +43,8 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName)
    fRsigma (0.),
    fDensityFunction(0)
 {
-  cout << "-I FairEvtGenGenerator: Opening input file " << fileName << endl;
+  LOG(INFO) << "FairEvtGenGenerator: Opening input file " << fileName 
+	    << FairLogger::endl;
   if ((fInputFile = fopen(fFileName,"r"))==NULL)
     //  fInputFile = new ifstream(fFileName);
     //  if ( ! fInputFile->is_open() )
@@ -65,9 +66,10 @@ FairEvtGenGenerator::FairEvtGenGenerator(const char* fileName, Double_t Rsigma,
    fRsigma (Rsigma),
    fDensityFunction(DensityFunction)
 {
-  cout << "-I FairEvtGenGenerator: Opening input file " << fileName << endl;
+  LOG(INFO) << "FairEvtGenGenerator: Opening input file " << fileName 
+	    << FairLogger::endl;
   if ((fInputFile = fopen(fFileName,"r"))==NULL) {
-    Fatal("FairEvtGenGenerator","Cannot open input file.");
+    LOG(FATAL) << "Cannot open input file." << FairLogger::endl;
   }
 
 }
@@ -92,7 +94,8 @@ Bool_t FairEvtGenGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   // Check for input file
   if (!fInputFile) {
     // if ( ! fInputFile->is_open() ) {
-    cout << "-E FairEvtGenGenerator: Input file not open!" << endl;
+    LOG(INFO) << "FairEvtGenGenerator: Input file not open!" 
+	      << FairLogger::endl;
     return kFALSE;
   }
 
@@ -113,17 +116,18 @@ Bool_t FairEvtGenGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
   if (ncols && ntracks>0) {
 
-    // cout << "Event number: " << eventID << "\tNtracks: " << ntracks << endl;
+    // LOG(INFO) << "Event number: " << eventID << "\tNtracks: " 
+    //           << ntracks << FairLogger::endl;
     for (Int_t ii=0; ii<15; ii++) {
-      ncols = fscanf(fInputFile,"%s",buffer);
-      //   cout << buffer << "\t" ;
+      ncols += fscanf(fInputFile,"%s",buffer);
+      //   LOG(INFO) << buffer << "\t" ;
     }
-    //cout << endl;
+    //LOG(INFO) << FairLogger::endl;
 
     for (Int_t ll=0; ll<ntracks; ll++) {
-      ncols = fscanf(fInputFile,"%d %d %d %d %d %d %d %g %f %f %f %f %f %f %f", &nLine, &pdgID, &nDecay, &nM1, &nM2, &nDF, &nDL, &fPx, &fPy, &fPz, &fE, &fT, &fVx, &fVy, &fVz);
-//  cout << nLine << "\t" << pdgID << "\t" << nDecay << "\t" << nM1 << "\t" << nM2 << "\t" << nDF << "\t" << nDL <<
-      //  "\t" << fPx << "\t" << fPy << "\t" << fPz << "\t" << fE << "\t" << fT << "\t" << fVx << "\t" << fVy << "\t" << fVz << endl;
+      ncols += fscanf(fInputFile,"%d %d %d %d %d %d %d %g %f %f %f %f %f %f %f", &nLine, &pdgID, &nDecay, &nM1, &nM2, &nDF, &nDL, &fPx, &fPy, &fPz, &fE, &fT, &fVx, &fVy, &fVz);
+//  LOG(INFO) << nLine << "\t" << pdgID << "\t" << nDecay << "\t" << nM1 << "\t" << nM2 << "\t" << nDF << "\t" << nDL <<
+      //  "\t" << fPx << "\t" << fPy << "\t" << fPz << "\t" << fE << "\t" << fT << "\t" << fVx << "\t" << fVy << "\t" << fVz << FairLogger::endl;
       max_nr = max(max_nr, nDF);
       max_nr = max(max_nr, nDL);
       if ((nDF==-1) && (nDL==-1)) {
@@ -150,7 +154,8 @@ Bool_t FairEvtGenGenerator::ReadEvent(FairPrimaryGenerator* primGen)
       }
     }
   } else {
-    cout << "-I FairEvtGenGenerator: End of input file reached " << endl;
+    LOG(INFO) << "FairEvtGenGenerator: End of input file reached " 
+	      << FairLogger::endl;
     CloseInput();
     return kFALSE;
   }
@@ -158,15 +163,16 @@ Bool_t FairEvtGenGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
   // If end of input file is reached : close it and abort run
   if ( feof(fInputFile) ) {
-    cout << "-I FairEvtGenGenerator: End of input file reached " << endl;
+    LOG(INFO) << "FairEvtGenGenerator: End of input file reached " 
+	      << FairLogger::endl;
     CloseInput();
     return kFALSE;
   }
 
   /*
-    cout << "-I FairEvtGenGenerator: Event " << eventID << ",  vertex = ("
+    LOG(INFO) << "FairEvtGenGenerator: Event " << eventID << ",  vertex = ("
     << vx << "," << vy << "," << vz << ") cm,  multiplicity "
-    << ntracks << endl;
+    << ntracks << FairLogger::endl;
   */
 
   return kTRUE;
@@ -181,8 +187,8 @@ void FairEvtGenGenerator::CloseInput()
   if ( fInputFile ) {
     //if ( fInputFile->is_open() ) {
     {
-      cout << "-I FairEvtGenGenerator: Closing input file "
-           << fFileName << endl;
+      LOG(INFO) << "FairEvtGenGenerator: Closing input file "
+		<< fFileName << FairLogger::endl;
       //  fInputFile->close();
 
       fclose(fInputFile);
diff --git a/generators/FairEvtGenGenerator.h b/generators/FairEvtGenGenerator.h
index a4c9b43..526fe68 100644
--- a/generators/FairEvtGenGenerator.h
+++ b/generators/FairEvtGenGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairEvtGenGenerator header file                 -----
 // -----          Created 09/10/06  by S. Spataro                      -----
@@ -76,15 +83,14 @@
 #define FAIR_EVTGENGENERATOR_H
 
 
-#include "FairGenerator.h"
-#include "TF1.h"
+#include "FairGenerator.h"              // for FairGenerator
 
-#include <fstream>
-
-class TDatabasePDG;
-class FairPrimaryGenerator;
+#include "Rtypes.h"                     // for FairEvtGenGenerator::Class, etc
 
+#include <stdio.h>                      // for FILE
 
+class FairPrimaryGenerator;
+class TF1;
 
 class FairEvtGenGenerator : public FairGenerator
 {
diff --git a/generators/FairIonGenerator.cxx b/generators/FairIonGenerator.cxx
index acf0591..c768094 100644
--- a/generators/FairIonGenerator.cxx
+++ b/generators/FairIonGenerator.cxx
@@ -1,24 +1,29 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                   FairIonGenerator source file                 -----
 // -----          Created 09/07/04  by V. Friese / D.Bertini           -----
 // -------------------------------------------------------------------------
 #include "FairIonGenerator.h"
 
-#include "FairPrimaryGenerator.h"
+#include "FairIon.h"                    // for FairIon
+#include "FairParticle.h"               // for FairParticle
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairRunSim.h"                 // for FairRunSim
+#include "FairLogger.h"                 // for logging
 
-#include "FairIon.h"
-#include "FairRunSim.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TObjArray.h"                  // for TObjArray
+#include "TParticle.h"                  // for TParticle
+#include "TParticlePDG.h"               // for TParticlePDG
 
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
-#include "TObjArray.h"
-
-#include "FairRunSim.h"
-#include "FairIon.h"
-#include <iostream>
-#include "TParticle.h"
-using std::cout;
-using std::endl;
+#include <stdio.h>                      // for NULL, sprintf
 
 // -----   Initialsisation of static variables   --------------------------
 Int_t FairIonGenerator::fgNIon = 0;
@@ -34,8 +39,9 @@ FairIonGenerator::FairIonGenerator()
    fVx(0), fVy(0), fVz(0),
    fIon(NULL),  fQ(0)
 {
-//  cout << "-W- FairIonGenerator: "
-//      << " Please do not use the default constructor! " << endl;
+//  LOG(WARNING) << "FairIonGenerator: "
+//               << " Please do not use the default constructor! " 
+//               << FairLogger::endl;
 }
 // ------------------------------------------------------------------------
 
@@ -54,7 +60,7 @@ FairIonGenerator::FairIonGenerator(const Char_t* ionName, Int_t mult,
   TObjArray* UserIons=fRun->GetUserDefIons();
   TObjArray* UserParticles=fRun->GetUserDefParticles();
   FairParticle* part=0;
-  fIon =(FairIon*) UserIons->FindObject(ionName);
+  fIon =static_cast<FairIon*>(UserIons->FindObject(ionName));
   if(fIon) {
     fgNIon++;
     fMult = mult;
@@ -66,7 +72,7 @@ FairIonGenerator::FairIonGenerator(const Char_t* ionName, Int_t mult,
     fVz   = vz;
 
   } else {
-    part= (FairParticle*)UserParticles->FindObject(ionName);
+    part= static_cast<FairParticle*>(UserParticles->FindObject(ionName));
     if(part) {
       fgNIon++;
       TParticle* particle=part->GetParticle();
@@ -80,8 +86,8 @@ FairIonGenerator::FairIonGenerator(const Char_t* ionName, Int_t mult,
     }
   }
   if(fIon==0 && part==0 ) {
-    cout << "-E- FairIonGenerator: Ion or Particle is not defined !" << endl;
-    Fatal("FairIonGenerator", "No FairRun instantised!");
+    LOG(FATAL) << "Ion or Particle is not defined !" 
+	       << FairLogger::endl;
   }
 
 }
@@ -115,10 +121,11 @@ FairIonGenerator::FairIonGenerator(Int_t z, Int_t a, Int_t q, Int_t mult,
   fIon= new FairIon(buffer, z, a, q);
   FairRunSim* run = FairRunSim::Instance();
   if ( ! run ) {
-    cout << "-E- FairIonGenerator: No FairRun instantised!" << endl;
-    Fatal("FairIonGenerator", "No FairRun instantised!");
+    LOG(ERROR) << "No FairRun instantised!" 
+	       << FairLogger::endl;
+  } else {
+    run->AddNewIon(fIon);
   }
-  run->AddNewIon(fIon);
 }
 //_________________________________________________________________________
 
@@ -156,25 +163,27 @@ Bool_t FairIonGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 {
 
 // if ( ! fIon ) {
-//   cout << "-W- FairIonGenerator: No ion defined! " << endl;
+//   LOG(WARNING) << "FairIonGenerator: No ion defined! " 
+//                << FairLogger::endl;
 //   return kFALSE;
 // }
 
   TParticlePDG* thisPart =
     TDatabasePDG::Instance()->GetParticle(fIon->GetName());
   if ( ! thisPart ) {
-    cout << "-W- FairIonGenerator: Ion " << fIon->GetName()
-         << " not found in database!" << endl;
+    LOG(WARNING) << "FairIonGenerator: Ion " << fIon->GetName()
+		 << " not found in database!" << FairLogger::endl;
     return kFALSE;
   }
 
   int pdgType = thisPart->PdgCode();
 
-  cout << "-I- FairIonGenerator: Generating " << fMult << " ions of type "
-       << fIon->GetName() << " (PDG code " << pdgType << ")" << endl;
-  cout << "    Momentum (" << fPx << ", " << fPy << ", " << fPz
-       << ") Gev from vertex (" << fVx << ", " << fVy
-       << ", " << fVz << ") cm" << endl;
+  LOG(INFO) << "FairIonGenerator: Generating " << fMult << " ions of type "
+	    << fIon->GetName() << " (PDG code " << pdgType << ")" 
+	    << FairLogger::endl;
+  LOG(INFO) << "    Momentum (" << fPx << ", " << fPy << ", " << fPz
+	    << ") Gev from vertex (" << fVx << ", " << fVy
+	    << ", " << fVz << ") cm" << FairLogger::endl;
 
   for(Int_t i=0; i<fMult; i++) {
     primGen->AddTrack(pdgType, fPx, fPy, fPz, fVx, fVy, fVz);
diff --git a/generators/FairIonGenerator.h b/generators/FairIonGenerator.h
index bad2ded..8d50c10 100644
--- a/generators/FairIonGenerator.h
+++ b/generators/FairIonGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                   FairIonGenerator header file                 -----
 // -----          Created 09/07/04  by V. Friese / D.Bertini           -----
@@ -10,12 +17,11 @@
 #ifndef FAIRIONGENERATOR_H
 #define FAIRIONGENERATOR_H
 
+#include "FairGenerator.h"              // for FairGenerator
 
-#include "FairGenerator.h"
-#include "FairIon.h"
-
-#include <iostream>
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
 
+class FairIon;
 class FairPrimaryGenerator;
 
 class FairIonGenerator : public FairGenerator
diff --git a/generators/FairParticleGenerator.cxx b/generators/FairParticleGenerator.cxx
index 725ba86..522405a 100644
--- a/generators/FairParticleGenerator.cxx
+++ b/generators/FairParticleGenerator.cxx
@@ -1,12 +1,17 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairParticleGenerator source file               -----
 // -----          Created 09/07/04  by V. Friese / D.Bertini           -----
 // -------------------------------------------------------------------------
 #include "FairParticleGenerator.h"
 
-#include "FairPrimaryGenerator.h"
-
-#include <iostream>
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
 
 // -----   Default constructor   ------------------------------------------
 FairParticleGenerator::FairParticleGenerator()
diff --git a/generators/FairParticleGenerator.h b/generators/FairParticleGenerator.h
index 520b7bc..3af1152 100644
--- a/generators/FairParticleGenerator.h
+++ b/generators/FairParticleGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairParticleGenerator header file               -----
 // -----          Created 09/07/04  by V. Friese / D.Bertini           -----
@@ -16,13 +23,12 @@
 #ifndef FAIR_PARTICLEGENERATOR_H
 #define FAIR_PARTICLEGENERATOR_H
 
+#include "FairGenerator.h"              // for FairGenerator
 
-#include "FairGenerator.h"
+#include "Rtypes.h"                     // for Double32_t, Int_t, etc
 
 class FairPrimaryGenerator;
 
-
-
 class FairParticleGenerator : public FairGenerator
 {
 
diff --git a/generators/FairShieldGenerator.cxx b/generators/FairShieldGenerator.cxx
index 04fa290..d72a4c1 100644
--- a/generators/FairShieldGenerator.cxx
+++ b/generators/FairShieldGenerator.cxx
@@ -1,20 +1,28 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairShieldGenerator source file                 -----
 // -----                Created 15/09/06  by V. Friese                 -----
 // -------------------------------------------------------------------------
 #include "FairShieldGenerator.h"
 
-#include "FairPrimaryGenerator.h"
-#include "FairIon.h"
-#include "FairRunSim.h"
+#include "FairIon.h"                    // for FairIon
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairRunSim.h"                 // for FairRunSim
+#include "FairLogger.h"                 // for logging
 
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TParticlePDG.h"               // for TParticlePDG
 
-#include <iostream>
+#include <stdio.h>                      // for NULL, sprintf
+#include <utility>                      // for pair
+#include <climits>                      // for INT_MAX
 
-using std::cout;
-using std::endl;
 using std::map;
 
 // -----   Default constructor   ------------------------------------------
@@ -39,21 +47,21 @@ FairShieldGenerator::FairShieldGenerator(const char* fileName)
    fIonMap()
 {
 
-  //  fPDG=TDatabasePDG::Instance();
-  //  fFileName  = fileName;
-  cout << "-I- FairShieldGenerator: Opening input file " << fileName << endl;
-  fInputFile = new ifstream(fFileName);
+  LOG(INFO) << "FairShieldGenerator: Opening input file " 
+	    << fileName << FairLogger::endl;
+  fInputFile = new std::ifstream(fFileName);
   if ( ! fInputFile->is_open() ) {
-    Fatal("FairShieldGenerator","Cannot open input file.");
+    LOG(FATAL) << "Cannot open input file." << FairLogger::endl;
   }
-  cout << "-I- FairShieldGenerator: Looking for ions..." << endl;
+  LOG(INFO) << "FairShieldGenerator: Looking for ions..." 
+	    << FairLogger::endl;
   Int_t nIons = RegisterIons();
-  cout << "-I- FairShieldGenerator: " << nIons << " ions registered."
-       << endl;
+  LOG(INFO) << "FairShieldGenerator: " << nIons << " ions registered."
+	    << FairLogger::endl;
   CloseInput();
-  cout << "-I- FairShieldGenerator: Reopening input file " << fileName
-       << endl;
-  fInputFile = new ifstream(fFileName);
+  LOG(INFO) << "FairShieldGenerator: Reopening input file " 
+	    << fileName << FairLogger::endl;
+  fInputFile = new std::ifstream(fFileName);
 }
 // ------------------------------------------------------------------------
 
@@ -74,7 +82,8 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
   // Check for input file
   if ( ! fInputFile->is_open() ) {
-    cout << "-E- FairShieldGenerator: Input file not open!" << endl;
+    LOG(ERROR) << "FairShieldGenerator: Input file not open!" 
+	       << FairLogger::endl;
     return kFALSE;
   }
 
@@ -95,18 +104,23 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   Int_t    pdgType = 0;
 
   // Read event header line from input file
-  *fInputFile >> eventId >> nTracks >> pBeam >> b;
+  *fInputFile >> eventId;
+  *fInputFile >> nTracks;
+  if (nTracks < 0 || nTracks > (INT_MAX-1)) LOG(FATAL) << "Error reading the number of events from event header." << FairLogger::endl;
+  *fInputFile >> pBeam >> b;
+
 
   // If end of input file is reached : close it and abort run
   if ( fInputFile->eof() ) {
-    cout << "-I- FairShieldGenerator: End of input file reached " << endl;
+    LOG(INFO) << "FairShieldGenerator: End of input file reached " 
+	      << FairLogger::endl;
     CloseInput();
     return kFALSE;
   }
 
-  cout << "-I- FairShieldGenerator: Event " << eventId << ",  pBeam = "
-       << pBeam << "GeV, b = " << b << " fm, multiplicity " << nTracks
-       << endl;
+  LOG(INFO) << "FairShieldGenerator: Event " << eventId << ",  pBeam = "
+	    << pBeam << "GeV, b = " << b << " fm, multiplicity " << nTracks
+	    << FairLogger::endl;
 
   // Loop over tracks in the current event
   for (Int_t itrack=0; itrack<nTracks; itrack++) {
@@ -120,8 +134,9 @@ Bool_t FairShieldGenerator::ReadEvent(FairPrimaryGenerator* primGen)
       sprintf(ionName, "Ion_%d_%d", iMass, iCharge);
       TParticlePDG* part = fPDG->GetParticle(ionName);
       if ( ! part ) {
-        cout << "-W- FairShieldGenerator::ReadEvent: Cannot find "
-             << ionName << " in database!" << endl;
+        LOG(WARNING) << "FairShieldGenerator::ReadEvent: Cannot find "
+		     << ionName << " in database!" 
+		     << FairLogger::endl;
         continue;
       }
       pdgType = part->PdgCode();
@@ -144,8 +159,8 @@ void FairShieldGenerator::CloseInput()
 {
   if ( fInputFile ) {
     if ( fInputFile->is_open() ) {
-      cout << "-I- FairShieldGenerator: Closing input file "
-           << fFileName << endl;
+      LOG(INFO) << "FairShieldGenerator: Closing input file "
+		<< fFileName << FairLogger::endl;
       fInputFile->close();
     }
     delete fInputFile;
@@ -167,7 +182,10 @@ Int_t FairShieldGenerator::RegisterIons()
 
   while ( ! fInputFile->eof()) {
 
-    *fInputFile >> eventId >> nTracks >> pBeam >> b;
+    *fInputFile >> eventId;
+    *fInputFile >> nTracks;
+    if (nTracks < 0 || nTracks > (INT_MAX-1)) LOG(FATAL) << "Error reading the number of events from event header." << FairLogger::endl;
+    *fInputFile >> pBeam >> b;
     if ( fInputFile->eof() ) { continue; }
     for (Int_t iTrack=0; iTrack<nTracks; iTrack++) {
       *fInputFile >> iPid >> iMass >> iCharge >> px >> py >> pz;
diff --git a/generators/FairShieldGenerator.h b/generators/FairShieldGenerator.h
index 301d96c..687c777 100644
--- a/generators/FairShieldGenerator.h
+++ b/generators/FairShieldGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairShieldGenerator header file                 -----
 // -----                Created 15/09/06 by V. Friese                  -----
@@ -22,11 +29,14 @@
 #ifndef FAIRSHIELDGENERATOR_H
 #define FAIRSHIELDGENERATOR_H 1
 
+#include "FairGenerator.h"              // for FairGenerator
 
-#include "FairGenerator.h"
+#include "Riosfwd.h"                    // for ifstream
+#include "Rtypes.h"                     // for FairShieldGenerator::Class, etc
+#include "TString.h"                    // for TString
 
-#include <fstream>
-#include <map>
+#include <fstream>                      // for ifstream
+#include <map>                          // for map
 
 class TDatabasePDG;
 class FairPrimaryGenerator;
@@ -61,7 +71,7 @@ class FairShieldGenerator : public FairGenerator
 
   private:
 
-    ifstream*      fInputFile;          //! Input file stream
+    std::ifstream*      fInputFile;          //! Input file stream
     const Char_t*  fFileName;           //! Input file Name
     TDatabasePDG*  fPDG;                //!  PDG database
 
diff --git a/generators/FairUrqmdGenerator.cxx b/generators/FairUrqmdGenerator.cxx
index 1234970..49b6e43 100644
--- a/generators/FairUrqmdGenerator.cxx
+++ b/generators/FairUrqmdGenerator.cxx
@@ -1,33 +1,31 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairUrqmdGenerator source file                  -----
 // -----                Created 24/06/04  by V. Friese                 -----
 // -------------------------------------------------------------------------
 #include "FairUrqmdGenerator.h"
 
-#include "FairPrimaryGenerator.h"
-#include "FairMCEventHeader.h"
-#include "constants.h"
+#include "FairMCEventHeader.h"          // for FairMCEventHeader
+#include "FairPrimaryGenerator.h"       // for FairPrimaryGenerator
+#include "FairLogger.h"                 // for logging
 
-#include "TMCProcess.h"
-#include "TObjArray.h"
-#include "TPDGCode.h"
-#include "TParticle.h"
-#include "TRandom.h"
-#include "TString.h"
-#include "TVirtualMCStack.h"
-#include "TLorentzVector.h"
-#include "TDatabasePDG.h"
-#include "TParticlePDG.h"
-
-
-#include <iostream>
-#include <cstring>
-
-using std::cout;
-using std::endl;
-
-//const Double_t kProtonMass = 0.938271998;
+#include "Riosfwd.h"                    // for ostream, ifstream
+#include "TDatabasePDG.h"               // for TDatabasePDG
+#include "TLorentzVector.h"             // for TLorentzVector
+#include "TMath.h"                      // for Sqrt, sqrt
+#include "TParticlePDG.h"               // for TParticlePDG
+#include "TString.h"                    // for TString, operator+
+#include "TVector3.h"                   // for TVector3
 
+#include <stdlib.h>                     // for getenv
+#include <climits>                      // for INT_MAX
+#include <fstream>                      // IWYU pragma: keep for ifstream
 
 // -----   Default constructor   ------------------------------------------
 FairUrqmdGenerator::FairUrqmdGenerator()
@@ -49,25 +47,49 @@ FairUrqmdGenerator::FairUrqmdGenerator(const char* fileName)
    fFileName(fileName)
 {
   //  fFileName = fileName;
-  cout << "-I FairUrqmdGenerator: Opening input file " << fileName << endl;
+  LOG(INFO) << "FairUrqmdGenerator: Opening input file " 
+	    << fileName << FairLogger::endl;
   fInputFile = fopen(fFileName, "r");
-  if ( ! fInputFile ) { Fatal("FairUrqmdgenerator","Cannot open input file."); }
+  if ( ! fInputFile ) { 
+    LOG(FATAL) << "Cannot open input file."
+	       << FairLogger::endl; 
+  }
   ReadConversionTable();
 }
 // ------------------------------------------------------------------------
+FairUrqmdGenerator::FairUrqmdGenerator(const char* fileName,  const char* conversion_table)
+:FairGenerator(),
+fInputFile(NULL),
+fParticleTable(),
+fFileName(fileName)
+{
+    //  fFileName = fileName;
+    LOG(INFO) << "FairUrqmdGenerator: Opening input file "
+    << fileName << FairLogger::endl;
+    fInputFile = fopen(fFileName, "r");
+    if ( ! fInputFile ) {
+        LOG(FATAL) << "Cannot open input file."
+	       << FairLogger::endl;
+    }
+    ReadConversionTable(conversion_table);
+}
+// ------------------------------------------------------------------------
+
 
 
 
 // -----   Destructor   ---------------------------------------------------
 FairUrqmdGenerator::~FairUrqmdGenerator()
 {
-  //  cout<<"Enter Destructor of FairUrqmdGenerator"<<endl;
+  //  LOG(DEBUG) << "Enter Destructor of FairUrqmdGenerator"
+  //             << FairLogger::endl;
   if ( fInputFile ) {
     fclose(fInputFile);
     fInputFile = NULL;
   }
   fParticleTable.clear();
-  //  cout<<"Leave Destructor of FairUrqmdGenerator"<<endl;
+  //  LOG(DEBUG) << "Leave Destructor of FairUrqmdGenerator"
+  //             << FairLogger::endl;
 }
 // ------------------------------------------------------------------------
 
@@ -79,14 +101,15 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
   // ---> Check for input file
   if ( ! fInputFile ) {
-    cout << "-E FairUrqmdGenerator: Input file not open! " << endl;
+    LOG(ERROR) << "FairUrqmdGenerator: Input file not open! " 
+	       << FairLogger::endl;
     return kFALSE;
   }
 
   // ---> Check for primary generator
   if ( ! primGen ) {
-    cout << "-E- FairUrqmdGenerator::ReadEvent: "
-         << "No PrimaryGenerator!" << endl;
+    LOG(ERROR) << "FairUrqmdGenerator::ReadEvent: "
+	       << "No PrimaryGenerator!" << FairLogger::endl;
     return kFALSE;
   }
 
@@ -101,36 +124,49 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   char read[200];
   fgets(read, 200, fInputFile);
   if ( feof(fInputFile) ) {
-    cout << "-I FairUrqmdGenerator : End of input file reached." << endl;
+    LOG(INFO) << "FairUrqmdGenerator : End of input file reached." 
+	      << FairLogger::endl;
     fclose(fInputFile);
     fInputFile = NULL;
     return kFALSE;
   }
   if ( read[0] != 'U' ) {
-    cout << "-E FairUrqmdGenerator: Wrong event header" << endl;
+    LOG(ERROR) << "FairUrqmdGenerator: Wrong event header" 
+	       << FairLogger::endl;
     return kFALSE;
   }
 
+  Int_t retval = 0;
+
   // ---> Read rest of event header
   fgets(read, 26, fInputFile);
-  fscanf(fInputFile, "%d", &aProj);
-  fscanf(fInputFile, "%d", &zProj);
+  retval = fscanf(fInputFile, "%d", &aProj);
+  CheckReturnValue(retval);
+  retval = fscanf(fInputFile, "%d", &zProj);
+  CheckReturnValue(retval);
   fgets(read, 25, fInputFile);
-  fscanf(fInputFile, "%d", &aTarg);
-  fscanf(fInputFile, "%d", &zTarg);
+  retval = fscanf(fInputFile, "%d", &aTarg);
+  CheckReturnValue(retval);
+  retval = fscanf(fInputFile, "%d", &zTarg);
+  CheckReturnValue(retval);
   fgets(read, 200, fInputFile);
   fgets(read, 200, fInputFile);
   fgets(read, 36, fInputFile);
-  fscanf(fInputFile, "%f", &b);
+  retval = fscanf(fInputFile, "%f", &b);
+  CheckReturnValue(retval);
   fgets(read, 200, fInputFile);
   fgets(read, 39, fInputFile);
-  fscanf(fInputFile, "%e", &ekin);
+  retval = fscanf(fInputFile, "%e", &ekin);
+  CheckReturnValue(retval);
   fgets(read, 200, fInputFile);
   fgets(read, 7, fInputFile);
-  fscanf(fInputFile, "%d", &evnr);
+  retval = fscanf(fInputFile, "%d", &evnr);
+  CheckReturnValue(retval);
   fgets(read, 200, fInputFile);
   for (int iline=0; iline<8; iline++)  { fgets(read, 200,fInputFile); }
-  fscanf(fInputFile, "%d", &ntracks);
+  retval = fscanf(fInputFile, "%d", &ntracks);
+  if (ntracks < 0 || ntracks > (INT_MAX-1)) LOG(FATAL) << "Error reading the number of events from event header." << FairLogger::endl;
+  CheckReturnValue(retval);
   fgets(read, 200, fInputFile);
   fgets(read, 200, fInputFile);
 
@@ -144,8 +180,9 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
   Double_t betaCM  = pBeam / (eBeam + kProtonMass);
   Double_t gammaCM = TMath::Sqrt( 1. / ( 1. - betaCM*betaCM) );
 
-  cout << "-I FairUrqmdGenerator: Event " << evnr << ",  b = " << b
-       << " fm,  multiplicity " << ntracks  << ", ekin: " << ekin << endl;
+  LOG(INFO) << "FairUrqmdGenerator: Event " << evnr << ",  b = " << b
+	    << " fm,  multiplicity " << ntracks  << ", ekin: " 
+	    << ekin << FairLogger::endl;
 
   // Set event id and impact parameter in MCEvent if not yet done
   FairMCEventHeader* event = primGen->GetEvent();
@@ -161,13 +198,20 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
     // Read momentum and PID from file
     fgets(read, 81, fInputFile);
-    fscanf(fInputFile, "%e", &ppx);
-    fscanf(fInputFile, "%e", &ppy);
-    fscanf(fInputFile, "%e", &ppz);
-    fscanf(fInputFile, "%e", &m);
-    fscanf(fInputFile, "%d", &ityp);
-    fscanf(fInputFile, "%d", &i3);
-    fscanf(fInputFile, "%d", &ichg);
+    retval = fscanf(fInputFile, "%e", &ppx);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%e", &ppy);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%e", &ppz);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%e", &m);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%d", &ityp);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%d", &i3);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%d", &ichg);
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
 
     // Convert UrQMD type and charge to unique pid identifier
@@ -176,8 +220,9 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
 
     // Convert Unique PID into PDG particle code
     if (fParticleTable.find(pid) == fParticleTable.end()) {
-      cout << "-W FairUrqmdGenerator: PID " << ityp << " charge "
-           << ichg << " not found in table (" << pid << ")" << endl;
+      LOG(WARNING) << "FairUrqmdGenerator: PID " << ityp << " charge "
+		   << ichg << " not found in table (" << pid << ")" 
+		   << FairLogger::endl;
       continue;
     }
     Int_t pdgID = fParticleTable[pid];
@@ -188,8 +233,7 @@ Bool_t FairUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen)
     Double_t py   = Double_t(ppy);
     Double_t pz   = Double_t(ppz);
     Double_t e    = sqrt( mass*mass + px*px + py*py + pz*pz );
-    if (gCoordinateSystem == sysLaboratory)
-        pz = gammaCM * ( pz + betaCM * e );
+    pz = gammaCM * ( pz + betaCM * e );
     Double_t ee = sqrt( mass*mass + px*px + py*py + pz*pz );
 
     TVector3 aa(px,py,pz);
@@ -217,7 +261,8 @@ Bool_t FairUrqmdGenerator::SkipEvents(Int_t count)
   for(Int_t ii=0; ii<count; ii++) {
     // ---> Check for input file
     if ( ! fInputFile ) {
-      cout << "-E FairUrqmdGenerator: Input file not open! " << endl;
+      LOG(ERROR) << "FairUrqmdGenerator: Input file not open! " 
+		 << FairLogger::endl;
       return kFALSE;
     }
 
@@ -229,40 +274,54 @@ Bool_t FairUrqmdGenerator::SkipEvents(Int_t count)
     char read[200];
     fgets(read, 200, fInputFile);
     if ( feof(fInputFile) ) {
-      cout << "-I FairUrqmdGenerator : End of input file reached." << endl;
+      LOG(INFO) << "FairUrqmdGenerator : End of input file reached." 
+		<< FairLogger::endl;
       fclose(fInputFile);
       fInputFile = NULL;
       return kFALSE;
     }
     if ( read[0] != 'U' ) {
-      cout << "-E FairUrqmdGenerator: Wrong event header" << endl;
+      LOG(ERROR) << "FairUrqmdGenerator: Wrong event header" 
+		 << FairLogger::endl;
       return kFALSE;
     }
 
+    Int_t retval = 0;
+
     // ---> Read rest of event header
     fgets(read, 26, fInputFile);
-    fscanf(fInputFile, "%d", &aProj);
-    fscanf(fInputFile, "%d", &zProj);
+    retval = fscanf(fInputFile, "%d", &aProj);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%d", &zProj);
+    CheckReturnValue(retval);
     fgets(read, 25, fInputFile);
-    fscanf(fInputFile, "%d", &aTarg);
-    fscanf(fInputFile, "%d", &zTarg);
+    retval = fscanf(fInputFile, "%d", &aTarg);
+    CheckReturnValue(retval);
+    retval = fscanf(fInputFile, "%d", &zTarg);
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
     fgets(read, 200, fInputFile);
     fgets(read, 36, fInputFile);
-    fscanf(fInputFile, "%f", &b);
+    retval = fscanf(fInputFile, "%f", &b);
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
     fgets(read, 39, fInputFile);
-    fscanf(fInputFile, "%e", &ekin);
+    retval = fscanf(fInputFile, "%e", &ekin);
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
     fgets(read, 7, fInputFile);
-    fscanf(fInputFile, "%d", &evnr);
+    retval = fscanf(fInputFile, "%d", &evnr);
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
     for (int iline=0; iline<8; iline++)  { fgets(read, 200,fInputFile); }
-    fscanf(fInputFile, "%d", &ntracks);
+    retval = fscanf(fInputFile, "%d", &ntracks);
+    if (ntracks < 0 || ntracks > (INT_MAX-1)) LOG(FATAL) << "Error reading the number of events from event header." << FairLogger::endl;
+    CheckReturnValue(retval);
     fgets(read, 200, fInputFile);
     fgets(read, 200, fInputFile);
 
-    cout << "-I FairUrqmdGenerator: Event " << evnr << " skipped!" << endl;
+    LOG(INFO) << "FairUrqmdGenerator: Event " << evnr << " skipped!" 
+	      << FairLogger::endl;
 
     // ---> Loop over tracks in the current event
     for(int itrack=0; itrack<ntracks; itrack++) {
@@ -277,14 +336,27 @@ Bool_t FairUrqmdGenerator::SkipEvents(Int_t count)
 // ------------------------------------------------------------------------
 
 // -----   Private method ReadConverisonTable   ---------------------------
-void FairUrqmdGenerator::ReadConversionTable()
+void FairUrqmdGenerator::ReadConversionTable(TString conversion_table)
 {
-
+    
   TString work      = getenv("VMCWORKDIR");
-  TString fileName  = work + "/input/urqmd_pdg.dat";
-  ifstream* pdgconv = new ifstream(fileName.Data());
+  TString fileName;
+
+  if (conversion_table.IsNull()){
+    fileName  = work + "/input/urqmd_pdg.dat";
+  }else{
+    fileName= conversion_table.Data();
+  }
+      
+  std::ifstream* pdgconv = new std::ifstream(fileName.Data());
+  
+  if (!pdgconv->good()) {
+    LOG(FATAL) << "Could not open Urqmd->PDG input file " 
+	       << fileName << FairLogger::endl;
+  }
 
   Int_t index = 0;
+   
   Int_t pdgId = 0;
 
   while ( ! pdgconv->eof() ) {
@@ -296,12 +368,18 @@ void FairUrqmdGenerator::ReadConversionTable()
   pdgconv->close();
   delete pdgconv;
 
-  cout << "-I FairUrqmdGenerator: Particle table for conversion from "
-       << "UrQMD loaded" <<  endl;
+  LOG(INFO) << "FairUrqmdGenerator: Particle table for conversion from "
+	    << "UrQMD loaded" <<  FairLogger::endl;
 
 }
 // ------------------------------------------------------------------------
 
-
+void FairUrqmdGenerator::CheckReturnValue(Int_t retval)
+{
+  if (1 != retval) { 
+    LOG(ERROR) << "Error when reading variable from input file"
+	       << FairLogger::endl;
+  } 
+} 
 
 ClassImp(FairUrqmdGenerator);
diff --git a/generators/FairUrqmdGenerator.h b/generators/FairUrqmdGenerator.h
index 196a767..621e7e5 100644
--- a/generators/FairUrqmdGenerator.h
+++ b/generators/FairUrqmdGenerator.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 // -----                FairUrqmdGenerator header file                  -----
 // -----          Created 11/06/04  by V. Friese / D.Bertini           -----
@@ -19,16 +26,15 @@
 #ifndef FAIRURQMDGENERATOR_H
 #define FAIRURQMDGENERATOR_H
 
+#include "FairGenerator.h"              // for FairGenerator
 
-#include "FairGenerator.h"
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
 
-#include <fstream>
-#include <map>
+#include <stdio.h>                      // for FILE
+#include <map>                          // for map
 
-class TVirtualMCStack;
 class FairPrimaryGenerator;
 
-
 class FairUrqmdGenerator : public FairGenerator
 {
 
@@ -42,7 +48,13 @@ class FairUrqmdGenerator : public FairGenerator
      * @param fileName The input file name
      **/
     FairUrqmdGenerator(const char* fileName);
+   
+    /** Standard constructor.
+     * @param fileName The input file name
+     * @param conversion_table name of conversion table file (from Urqmd->PDG) should use the full path to the file
+     **/
 
+    FairUrqmdGenerator(const char* fileName,  const char* conversion_table);
 
     /** Destructor. **/
     ~FairUrqmdGenerator();
@@ -55,7 +67,7 @@ class FairUrqmdGenerator : public FairGenerator
      **/
     Bool_t ReadEvent(FairPrimaryGenerator* primGen);
 
-    //Skip some events in file
+    /** Skip defined number of events in file **/
     Bool_t SkipEvents(Int_t count);
 
   private:
@@ -69,7 +81,10 @@ class FairUrqmdGenerator : public FairGenerator
     /** Private method ReadConversionTable. Reads the conversion table
         from UrQMD particle code to PDG particle code and fills the
         conversion map. Is called from the constructor. **/
-    void ReadConversionTable();
+    void ReadConversionTable(TString conversion_table="");
+
+    /** Check return value from fscanf call **/
+    void CheckReturnValue(Int_t retval);
 
     FairUrqmdGenerator(const FairUrqmdGenerator&);
     FairUrqmdGenerator& operator=(const FairUrqmdGenerator&);
diff --git a/generators/GenLinkDef.h b/generators/GenLinkDef.h
index d053d01..98aba8c 100644
--- a/generators/GenLinkDef.h
+++ b/generators/GenLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // $Id: GenLinkDef.h,v 1.2 2006/09/15 16:53:34 friese Exp $
 
 #ifdef __CINT__
@@ -6,14 +13,28 @@
 #pragma link off all classes;
 #pragma link off all functions;
 
-#pragma link C++ class  FairAsciiGenerator+;
-#pragma link C++ class  FairIonGenerator+;
-#pragma link C++ class  FairParticleGenerator+;
-#pragma link C++ class  FairPlutoGenerator+;
-#pragma link C++ class  FairPlutoReactionGenerator+;
-#pragma link C++ class  FairShieldGenerator+;
-#pragma link C++ class  FairUrqmdGenerator+;
-#pragma link C++ class  FairBoxGenerator+;
-#pragma link C++ class  FairEvtGenGenerator+;
+#pragma link C++ class FairAsciiGenerator+;
+#pragma link C++ class FairIonGenerator+;
+#pragma link C++ class FairParticleGenerator+;
+#pragma link C++ class FairPlutoReactionGenerator+;
+#pragma link C++ class FairShieldGenerator+;
+#pragma link C++ class FairUrqmdGenerator+;
+#pragma link C++ class FairBoxGenerator+;
+#pragma link C++ class FairEvtGenGenerator+;
+
+#pragma link C++ class MpdMCEventHeader+;
+#pragma link C++ class MpdLAQGSMGenerator+;
+#pragma link C++ class MpdHypYPtGenerator+;
+#pragma link C++ class MpdPlutoGenerator+;
+#pragma link C++ class MpdRainGenerator+;
+#pragma link C++ class MpdPHSDGenerator+;
+#pragma link C++ class Mpd3fdGenerator+;
+#pragma link C++ class MpdUrqmdGenerator+;
+#pragma link C++ class MpdVHLLEGenerator+;
+#pragma link C++ class MpdLibZ+;
+#pragma link C++ class MpdGetNumEvents+;
+#pragma link C++ class MpdHistoGenerator+;
+
+#pragma link C++ class map<TString, FairIon*>;
 
 #endif
diff --git a/mpdgenerators/Mpd3fdGenerator.cxx b/generators/Mpd3fdGenerator.cxx
similarity index 100%
rename from mpdgenerators/Mpd3fdGenerator.cxx
rename to generators/Mpd3fdGenerator.cxx
diff --git a/mpdgenerators/Mpd3fdGenerator.h b/generators/Mpd3fdGenerator.h
similarity index 100%
rename from mpdgenerators/Mpd3fdGenerator.h
rename to generators/Mpd3fdGenerator.h
diff --git a/mpdgenerators/MpdGetNumEvents.cxx b/generators/MpdGetNumEvents.cxx
similarity index 90%
rename from mpdgenerators/MpdGetNumEvents.cxx
rename to generators/MpdGetNumEvents.cxx
index d314151..734a786 100644
--- a/mpdgenerators/MpdGetNumEvents.cxx
+++ b/generators/MpdGetNumEvents.cxx
@@ -1,4 +1,5 @@
 #include "MpdGetNumEvents.h"
+#include "FairRootManager.h"
 
 #include "TChain.h"
 #include "TString.h"
@@ -117,14 +118,13 @@ off_t MpdLibZ::tell(){return gztell(file);}
 ClassImp(MpdLibZ);
 
 
-bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_format_ID)
+bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t& fQGSM_format_ID)
 {
     libz->gets(ss, 250);
 
     // If end of input file is reached : close it and abort run
     if (libz->eof())
     {
-        cout<<"End of input file reached "<<endl;
         libz->close();
         return false;
     }
@@ -140,20 +140,18 @@ bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_f
         {
             if (tss.Contains("QGSM format ID"))
             {
-                sscanf(ss,"QGSM format ID=%d", fQGSM_format_ID);
-                cout<<"QGSM format ID "<<*fQGSM_format_ID<<endl;
+                sscanf(ss,"QGSM format ID=%d", &fQGSM_format_ID);
 
                 // correction of incorrect format_ID in some data files
-                if (*fQGSM_format_ID == 2)
+                if (fQGSM_format_ID == 2)
                 {
                     off_t file_pos = libz->tell();
                     for (int k = 0; k < 5; k++)
                         libz->gets(ss,250);
 
                     if (strlen(ss) > 90)
-                        *fQGSM_format_ID = 3;
+                        fQGSM_format_ID = 3;
 
-                    cout<<"QGSM format ID now"<<*fQGSM_format_ID<<endl;
                     libz->seek(file_pos, 0);
                 }
             }
@@ -162,7 +160,7 @@ bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_f
             tss = ss;
             lines++;
 
-            if ((*fQGSM_format_ID >= 2) && (lines >= 4)) return  true;
+            if ((fQGSM_format_ID >= 2) && (lines >= 4)) return  true;
 
             if (lines > 25)
             {
@@ -173,7 +171,7 @@ bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_f
     }
     else
     {
-        if (*fQGSM_format_ID >= 2) return true;
+        if (fQGSM_format_ID >= 2) return true;
 
         if (!tss.Contains("particles, b,bx,by"))
         {
@@ -192,11 +190,11 @@ bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_f
     // 3
     if (!tss.Contains("event"))
     {
-        if (*fQGSM_format_ID >= 2) return true;
+        if (fQGSM_format_ID >= 2) return true;
         else
         {
             cout<<"Wrong event header! 2 "<<endl;
-            printf("Format id:%d \n %s \n", *fQGSM_format_ID, ss);
+            printf("Format id:%d \n %s \n", fQGSM_format_ID, ss);
             libz->close();
             return false;
         }//else
@@ -204,7 +202,7 @@ bool MpdGetNumEvents::GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_f
 
     char tmp[250];
 
-    switch (*fQGSM_format_ID)
+    switch (fQGSM_format_ID)
     {
         case 0:
         case 1:
@@ -269,13 +267,15 @@ Int_t MpdGetNumEvents::GetNumPHSDEvents(char* filename)
     libz->close();
     delete libz;
 
+    cout<<"The total number of events in the PHSD file will be processed - "<<num<<endl;
+
     return num;
 }
 
 Int_t MpdGetNumEvents::GetNumQGSMEvents(char* fileName)
 {
-    Int_t* fQGSM_format_ID;
-    MpdLibZ *libz = new MpdLibZ(fileName);
+    Int_t fQGSM_format_ID = 0;
+    MpdLibZ* libz = new MpdLibZ(fileName);
     libz->open("rb");
 
     char ss[252];
@@ -297,6 +297,7 @@ Int_t MpdGetNumEvents::GetNumQGSMEvents(char* fileName)
     libz->close();
     delete libz;
 
+    cout<<"The total number of events in the QGSM file will be processed - "<<num<<endl;
     return num;
 }
 
@@ -313,7 +314,7 @@ Int_t MpdGetNumEvents::GetNumURQMDEvents(char* fileName)
         libz->gets(read, 200);
         Int_t urqmdVersion = 0;
         sscanf(read, "UQMD   version:       %d   1000  %d  output_file  14", &urqmdVersion, &urqmdVersion);
-       
+
         if (read[0] != 'U')
         {
             cout<<"Wrong event header"<<endl;
@@ -337,18 +338,20 @@ Int_t MpdGetNumEvents::GetNumURQMDEvents(char* fileName)
     libz->close();
     delete libz;
 
+    cout<<"The total number of events in the UrQMD file will be processed - "<<num<<endl;
     return num;
 }
 
 Int_t MpdGetNumEvents::GetNumROOTEvents(char* filename)
 {
-    TChain* fileTree = new TChain("cbmsim");
+    TChain* fileTree = new TChain(FairRootManager::GetTreeName());
     fileTree->Add(filename);
 
     Int_t num = fileTree->GetEntries();
 
     delete fileTree;
 
+    cout<<"The total number of events in the ROOT file will be processed - "<<num<<endl;
     return num;
 }
 
diff --git a/mpdgenerators/MpdGetNumEvents.h b/generators/MpdGetNumEvents.h
similarity index 85%
rename from mpdgenerators/MpdGetNumEvents.h
rename to generators/MpdGetNumEvents.h
index 7d39464..018a43b 100644
--- a/mpdgenerators/MpdGetNumEvents.h
+++ b/generators/MpdGetNumEvents.h
@@ -1,6 +1,8 @@
 #include "TROOT.h"
 
+#ifndef __CINT__
 #include <zlib.h>
+#endif
 
 class MpdLibZ
 {
@@ -11,16 +13,22 @@ class MpdLibZ
     int open(const char* mode);
     int eof();
     int close();
+    #ifndef __CINT__
     int write(voidpc buf, unsigned len);
     int read(voidp buf, unsigned len);
+    #endif
     char* gets(char* buf, int len);
     int puts(char* s);
+    #ifndef __CINT__
     off_t tell ();
     off_t seek (off_t pos, int whence);
+    #endif
 
   private:
     char* fileName;
+    #ifndef __CINT__
     gzFile file;
+    #endif
 
     ClassDef(MpdLibZ, 1);
 };
@@ -31,7 +39,7 @@ class MpdGetNumEvents
     MpdGetNumEvents(){}
     ~MpdGetNumEvents(){}
 
-    static bool GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t* fQGSM_format_ID);
+    static bool GetQGSMEventHeader(char* ss, MpdLibZ* libz, Int_t& fQGSM_format_ID);
 
   public:
     static Int_t GetNumROOTEvents(char* filename);
diff --git a/mpdgenerators/MpdHistoGenerator.cxx b/generators/MpdHistoGenerator.cxx
similarity index 100%
rename from mpdgenerators/MpdHistoGenerator.cxx
rename to generators/MpdHistoGenerator.cxx
diff --git a/mpdgenerators/MpdHistoGenerator.h b/generators/MpdHistoGenerator.h
similarity index 100%
rename from mpdgenerators/MpdHistoGenerator.h
rename to generators/MpdHistoGenerator.h
diff --git a/mpdgenerators/MpdHypYPtGenerator.cxx b/generators/MpdHypYPtGenerator.cxx
similarity index 100%
rename from mpdgenerators/MpdHypYPtGenerator.cxx
rename to generators/MpdHypYPtGenerator.cxx
diff --git a/mpdgenerators/MpdHypYPtGenerator.h b/generators/MpdHypYPtGenerator.h
similarity index 100%
rename from mpdgenerators/MpdHypYPtGenerator.h
rename to generators/MpdHypYPtGenerator.h
diff --git a/mpdgenerators/MpdLAQGSMGenerator.cxx b/generators/MpdLAQGSMGenerator.cxx
similarity index 98%
rename from mpdgenerators/MpdLAQGSMGenerator.cxx
rename to generators/MpdLAQGSMGenerator.cxx
index 58a0576..3926ac1 100644
--- a/mpdgenerators/MpdLAQGSMGenerator.cxx
+++ b/generators/MpdLAQGSMGenerator.cxx
@@ -41,7 +41,7 @@ MpdLAQGSMGenerator::MpdLAQGSMGenerator() {}
 
 
 // -----   Standard constructor   -----------------------------------------
-MpdLAQGSMGenerator::MpdLAQGSMGenerator(const char* fileName, const Bool_t use_collider_system, Int_t QGSM_format_ID) : 
+MpdLAQGSMGenerator::MpdLAQGSMGenerator(const char* fileName, const Bool_t use_collider_system, Int_t QGSM_format_ID,Int_t Max_Event_Number ) : 
    FairGenerator(),
    fIonMap()
 {
@@ -77,7 +77,8 @@ MpdLAQGSMGenerator::MpdLAQGSMGenerator(const char* fileName, const Bool_t use_co
   cout << "-I- MpdLAQGSMGenerator: Looking for ions..." << endl;
   //AZ Int_t nIons = RegisterIons();
   //  Int_t nIons = RegisterIons1();
-  Int_t nIons = RegisterIons();    // MG
+  //  Int_t nIons = RegisterIons();    // MG
+  Int_t nIons = RegisterIons(Max_Event_Number);    // EL
   cout << "-I- MpdLAQGSMGenerator: " << nIons << " ions registered." 
        << endl;
 
@@ -542,7 +543,7 @@ Bool_t MpdLAQGSMGenerator::general_feof (void *p)
 }
 
 // -----   Private method RegisterIons   ----------------------------------
-Int_t MpdLAQGSMGenerator::RegisterIons() {
+Int_t MpdLAQGSMGenerator::RegisterIons(Int_t Max_Event_Number) {
 
   Int_t nIons = 0;
   //  Int_t eventId, nTracks, iPid, iMass, iCharge;
@@ -586,7 +587,7 @@ Int_t MpdLAQGSMGenerator::RegisterIons() {
   Int_t PDG;
   TString ionName;
 
-  while ( ! general_feof(fInputFile)) {
+  while ( (!general_feof(fInputFile)) && ((!Max_Event_Number)||(eventId<Max_Event_Number)) ) {
 
     sscanf(ss," %d %d", &eventId, &nTracks); 
 
diff --git a/mpdgenerators/MpdLAQGSMGenerator.h b/generators/MpdLAQGSMGenerator.h
similarity index 94%
rename from mpdgenerators/MpdLAQGSMGenerator.h
rename to generators/MpdLAQGSMGenerator.h
index 272df21..784b3cd 100644
--- a/mpdgenerators/MpdLAQGSMGenerator.h
+++ b/generators/MpdLAQGSMGenerator.h
@@ -18,7 +18,10 @@
 #include <fstream>
 #include <map>
 #include <vector>
+
+#ifndef __CINT__
 #include <zlib.h>
+#endif
 
 class TDatabasePDG;
 class FairPrimaryGenerator;
@@ -45,7 +48,7 @@ struct la_tab_t {
   /** Standard constructor. 
    ** @param fileName The input file name
    **/
-  MpdLAQGSMGenerator(const char* fileName, const Bool_t use_collider_system=kTRUE, Int_t QGSM_format_ID=0);
+  MpdLAQGSMGenerator(const char* fileName, const Bool_t use_collider_system=kTRUE, Int_t QGSM_format_ID=0,Int_t Max_Event_Number=0);
 
   /** Destructor. **/
   virtual ~MpdLAQGSMGenerator();
@@ -70,7 +73,9 @@ struct la_tab_t {
  private:
 
   FILE* fInputFile;                    //!  Input file
+  #ifndef __CINT__
   gzFile fGZInputFile;                 //!  GZ Input file
+  #endif
   const Char_t*  fFileName;           //! Input file Name
   TDatabasePDG*  fPDG;                //!  PDG database
   Int_t fQGSM_format_ID;              //   Reflect format changes
@@ -85,7 +90,7 @@ struct la_tab_t {
 
   /** Private method RegisterIons. Goes through the input file and registers
    ** any ion needed. **/
-  Int_t RegisterIons();
+  Int_t RegisterIons(Int_t Max_Event_Number=0);
   Int_t RegisterIons1(); //AZ
 
   Int_t CreatePdgCode(Int_t Z, Int_t A, Int_t Strange,Int_t user=0);
diff --git a/mpdgenerators/MpdLAQGSM_light_particles.dat b/generators/MpdLAQGSM_light_particles.dat
similarity index 100%
rename from mpdgenerators/MpdLAQGSM_light_particles.dat
rename to generators/MpdLAQGSM_light_particles.dat
diff --git a/mpdgenerators/MpdMCEventHeader.cxx b/generators/MpdMCEventHeader.cxx
similarity index 100%
rename from mpdgenerators/MpdMCEventHeader.cxx
rename to generators/MpdMCEventHeader.cxx
diff --git a/mpdgenerators/MpdMCEventHeader.h b/generators/MpdMCEventHeader.h
similarity index 100%
rename from mpdgenerators/MpdMCEventHeader.h
rename to generators/MpdMCEventHeader.h
diff --git a/mpdgenerators/MpdPHSDGenerator.cxx b/generators/MpdPHSDGenerator.cxx
similarity index 100%
rename from mpdgenerators/MpdPHSDGenerator.cxx
rename to generators/MpdPHSDGenerator.cxx
diff --git a/mpdgenerators/MpdPHSDGenerator.h b/generators/MpdPHSDGenerator.h
similarity index 96%
rename from mpdgenerators/MpdPHSDGenerator.h
rename to generators/MpdPHSDGenerator.h
index 098e6f1..063a817 100644
--- a/mpdgenerators/MpdPHSDGenerator.h
+++ b/generators/MpdPHSDGenerator.h
@@ -8,7 +8,9 @@
 #ifndef Mpd_PHSDGENERATOR_H
 #define Mpd_PHSDGENERATOR_H
 
+#ifndef __CINT__
 #include <zlib.h>
+#endif
 
 #include <TRandom2.h>
 
@@ -34,7 +36,9 @@ class MpdPHSDGenerator : public FairGenerator
  private:
   Int_t fntr; //! number of tracks in given event
   Float_t fb; //! impact parameter in given event
+  #ifndef __CINT__
   gzFile    fgzFile; //! file
+  #endif
   char fbuffer[256]; //! reading buffer
 
   TRandom2 *frandom; //!
diff --git a/mpdgenerators/MpdPlutoGenerator.cxx b/generators/MpdPlutoGenerator.cxx
similarity index 85%
rename from mpdgenerators/MpdPlutoGenerator.cxx
rename to generators/MpdPlutoGenerator.cxx
index e6e1a6e..e6b7d99 100644
--- a/mpdgenerators/MpdPlutoGenerator.cxx
+++ b/generators/MpdPlutoGenerator.cxx
@@ -21,29 +21,35 @@ const Double_t kProtonMass = 0.938271998;
 const Double_t kElectronMass = 0.00051098892;
 
 // -----   Default constructor   ------------------------------------------
-MpdPlutoGenerator::MpdPlutoGenerator() {
-  iEvent     = 0;
-  fInputFile = NULL;
-  fInputTree = NULL;
+MpdPlutoGenerator::MpdPlutoGenerator()
+  :FairGenerator(),
+   iEvent(0),
+   fEkin(0),
+   fFileName(NULL),
+   fInputFile(NULL),
+   fInputTree(NULL),
+   fParticles(NULL)
+{
 }
 // ------------------------------------------------------------------------
 
 
-
 // -----   Standard constructor   -----------------------------------------
-MpdPlutoGenerator::MpdPlutoGenerator(const Char_t* fileName, Double_t ekin = 25.0) {
-  iEvent     = 0;
+MpdPlutoGenerator::MpdPlutoGenerator(const Char_t* fileName, Double_t ekin = 25.0)
+  :FairGenerator(),
+   iEvent(0),
+   fFileName(fileName),
+   fInputFile(new TFile(fileName)),
+   fInputTree(NULL),
+   fParticles(new TClonesArray("PParticle",100))
+{
   fEkin      = ekin;
-  fFileName  = fileName;
-  fInputFile = new TFile(fFileName);
   fInputTree = (TTree*) fInputFile->Get("data");
-  fParticles = new TClonesArray("PParticle",100);
   fInputTree->SetBranchAddress("Particles", &fParticles);
 }
 // ------------------------------------------------------------------------
 
 
-
 // -----   Destructor   ---------------------------------------------------
 MpdPlutoGenerator::~MpdPlutoGenerator() {
   CloseInput();
@@ -51,19 +57,18 @@ MpdPlutoGenerator::~MpdPlutoGenerator() {
 // ------------------------------------------------------------------------
 
 
-
 // -----   Public method ReadEvent   --------------------------------------
 Bool_t MpdPlutoGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
 
   // Check for input file
   if ( ! fInputFile ) {
-    std::cout << "-E MpdPlutoGenerator: Input file nor open!" << std::endl;
+    cout << "-E MpdPlutoGenerator: Input file nor open!" << endl;
     return kFALSE;
   }
 
   // Check for number of events in input file
   if ( iEvent > fInputTree->GetEntries() ) {
-    std::cout << "-E MpdPlutoGenerator: No more events in input file!" << std::endl;
+    cout << "-E MpdPlutoGenerator: No more events in input file!" << endl;
     CloseInput();
     return kFALSE;
   }
@@ -85,8 +90,8 @@ Bool_t MpdPlutoGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
 
     // Check if particle type is known to database
     if ( ! pdgType ) {
-      std::cout << "-W MpdPlutoGenerator: Unknown type " << part->ID()
-	   << ", skipping particle." << std::endl;
+      cout << "-W MpdPlutoGenerator: Unknown type " << part->ID()
+       << ", skipping particle." << endl;
       continue;
     }
 
@@ -144,8 +149,8 @@ Bool_t MpdPlutoGenerator::SkipEvents(Int_t count) {
 // -----   Private method CloseInput   ------------------------------------
 void MpdPlutoGenerator::CloseInput() {
   if ( fInputFile ) {
-    std::cout << "-I MpdPlutoGenerator: Closing input file " << fFileName
-	 << std::endl;
+    cout << "-I MpdPlutoGenerator: Closing input file " << fFileName
+     << endl;
     fInputFile->Close();
     delete fInputFile;
   }
diff --git a/mpdgenerators/MpdPlutoGenerator.h b/generators/MpdPlutoGenerator.h
similarity index 100%
rename from mpdgenerators/MpdPlutoGenerator.h
rename to generators/MpdPlutoGenerator.h
diff --git a/mpdgenerators/MpdRainGenerator.cxx b/generators/MpdRainGenerator.cxx
similarity index 100%
rename from mpdgenerators/MpdRainGenerator.cxx
rename to generators/MpdRainGenerator.cxx
diff --git a/mpdgenerators/MpdRainGenerator.h b/generators/MpdRainGenerator.h
similarity index 100%
rename from mpdgenerators/MpdRainGenerator.h
rename to generators/MpdRainGenerator.h
diff --git a/mpdgenerators/MpdUrqmdGenerator.cxx b/generators/MpdUrqmdGenerator.cxx
similarity index 79%
rename from mpdgenerators/MpdUrqmdGenerator.cxx
rename to generators/MpdUrqmdGenerator.cxx
index e31ae9a..110f913 100644
--- a/mpdgenerators/MpdUrqmdGenerator.cxx
+++ b/generators/MpdUrqmdGenerator.cxx
@@ -19,6 +19,7 @@
 #include "TDatabasePDG.h"
 #include "TParticlePDG.h"
 
+
 #include <iostream>
 #include <cstring>
 
@@ -70,7 +71,11 @@ fFileName(fileName) {
 MpdUrqmdGenerator::~MpdUrqmdGenerator() {
     //  cout<<"Enter Destructor of MpdUrqmdGenerator"<<endl;
     if (fInputFile) {
+#ifdef GZIP_SUPPORT
         gzclose(fInputFile);
+#else
+        fclose(fInputFile);
+#endif
         fInputFile = NULL;
     }
     fParticleTable.clear();
@@ -106,13 +111,23 @@ Bool_t MpdUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
 
     // ---> Read and check first event header line from input file
     char read[200];
+#ifdef GZIP_SUPPORT
     gzgets(fInputFile, read, 200); // line 1
+#else
+    fgets(read, 200, fInputFile);
+#endif
     Int_t urqmdVersion = 0;
     sscanf(read, "UQMD   version:       %d   1000  %d  output_file  14", &urqmdVersion, &urqmdVersion);
     cout << "URQMD VERSION USED = " << urqmdVersion << endl;
+#ifdef GZIP_SUPPORT
     if (gzeof(fInputFile)) {
         cout << "-I MpdUrqmdGenerator : End of input file reached." << endl;
         gzclose(fInputFile);
+#else
+    if ( feof(fInputFile) ) {
+        cout << "-I MpdUrqmdGenerator : End of input file reached." << endl;
+        fclose(fInputFile);
+#endif
         fInputFile = NULL;
         return kFALSE;
     }
@@ -122,6 +137,7 @@ Bool_t MpdUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
     }
 
     // ---> Read rest of event header
+#ifdef GZIP_SUPPORT
     gzgets(fInputFile, read, 200); // line 2
     sscanf(read, "projectile:  (mass, char) %d %d target:  (mass, char) %d %d",
             &aProj, &zProj, &aTarg, &zTarg); // line 2
@@ -142,6 +158,29 @@ Bool_t MpdUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
     gzgets(fInputFile, read, 200); // line 18
     sscanf(read, "%d", &ntracks); // line 18
     gzgets(fInputFile, read, 200); // line 19
+#else
+    fgets(read, 26, fInputFile);
+    fscanf(fInputFile, "%d", &aProj);
+    fscanf(fInputFile, "%d", &zProj);
+    fgets(read, 25, fInputFile);
+    fscanf(fInputFile, "%d", &aTarg);
+    fscanf(fInputFile, "%d", &zTarg);
+    fgets(read, 200, fInputFile);
+    fgets(read, 200, fInputFile);
+    fgets(read, 36, fInputFile);
+    fscanf(fInputFile, "%f", &b);
+    fgets(read, 200, fInputFile);
+    fgets(read, 39, fInputFile);
+    fscanf(fInputFile, "%e", &ekin);
+    fgets(read, 200, fInputFile);
+    fgets(read, 7, fInputFile);
+    fscanf(fInputFile, "%d", &evnr);
+    fgets(read, 200, fInputFile);
+    for (int iline=0; iline<8; iline++)  { fgets(read, 200,fInputFile); }
+    fscanf(fInputFile, "%d", &ntracks);
+    fgets(read, 200, fInputFile);
+    fgets(read, 200, fInputFile);
+#endif
 
     // ---> Calculate beta and gamma for Lorentztransformation
     TDatabasePDG* pdgDB = TDatabasePDG::Instance();
@@ -155,15 +194,15 @@ Bool_t MpdUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
 
     cout << "-I MpdUrqmdGenerator: Event " << evnr << ",  b = " << b
             << " fm,  multiplicity " << ntracks << ", ekin: " << ekin << endl;
-    
-    
+
+
     Double_t phi = 0.;
     // ---> Generate rotation angle
     if (fEventPlaneSet) {
         gRandom->SetSeed(0);
         phi = gRandom->Uniform(fPhiMin, fPhiMax);
     }
-    
+
     // Set event id and impact parameter in MCEvent if not yet done
     FairMCEventHeader* event = primGen->GetEvent();
     if (event && (!event->IsSet())) {
@@ -174,14 +213,25 @@ Bool_t MpdUrqmdGenerator::ReadEvent(FairPrimaryGenerator* primGen) {
     }
 
 
-
     // ---> Loop over tracks in the current event
     for (int itrack = 0; itrack < ntracks; itrack++) {
 
         // Read momentum and PID from file
+#ifdef GZIP_SUPPORT
         gzgets(fInputFile, read, 81);
         gzgets(fInputFile, read, 200);
         sscanf(read, "%e %e %e %e %d %d %d", &ppx, &ppy, &ppz, &m, &ityp, &i3, &ichg);
+#else
+        fgets(read, 81, fInputFile);
+        fscanf(fInputFile, "%e", &ppx);
+        fscanf(fInputFile, "%e", &ppy);
+        fscanf(fInputFile, "%e", &ppz);
+        fscanf(fInputFile, "%e", &m);
+        fscanf(fInputFile, "%d", &ityp);
+        fscanf(fInputFile, "%d", &i3);
+        fscanf(fInputFile, "%d", &ichg);
+        fgets(read, 200, fInputFile);
+#endif
 
         // Convert UrQMD type and charge to unique pid identifier
         if (ityp >= 0) {
@@ -252,14 +302,24 @@ Bool_t MpdUrqmdGenerator::SkipEvents(Int_t count) {
 
         // ---> Read and check first event header line from input file
         char read[200];
+#ifdef GZIP_SUPPORT
         gzgets(fInputFile, read, 200); // line 1
+#else
+        fgets(read, 200, fInputFile);
+#endif
         Int_t urqmdVersion = 0;
         sscanf(read, "UQMD   version:       %d   1000  %d  output_file  14", &urqmdVersion, &urqmdVersion);
         cout << "URQMD VERSION USED = " << urqmdVersion << endl;
 
+#ifdef GZIP_SUPPORT
         if (gzeof(fInputFile)) {
             cout << "-I MpdUrqmdGenerator : End of input file reached." << endl;
             gzclose(fInputFile);
+#else
+        if ( feof(fInputFile) ) {
+            cout << "-I MpdUrqmdGenerator : End of input file reached." << endl;
+            fclose(fInputFile);
+#endif
             fInputFile = NULL;
             return kFALSE;
         }
@@ -269,6 +329,7 @@ Bool_t MpdUrqmdGenerator::SkipEvents(Int_t count) {
         }
 
         // ---> Read rest of event header
+#ifdef GZIP_SUPPORT
         gzgets(fInputFile, read, 200); // line 2
         sscanf(read, "projectile:  (mass, char) %d %d target:  (mass, char) %d %d",
                 &aProj, &zProj, &aTarg, &zTarg); // line 2
@@ -289,6 +350,29 @@ Bool_t MpdUrqmdGenerator::SkipEvents(Int_t count) {
         gzgets(fInputFile, read, 200); // line 15
         sscanf(read, "%d", &ntracks); // line 15
         gzgets(fInputFile, read, 200); // line 16
+#else
+        fgets(read, 26, fInputFile);
+        fscanf(fInputFile, "%d", &aProj);
+        fscanf(fInputFile, "%d", &zProj);
+        fgets(read, 25, fInputFile);
+        fscanf(fInputFile, "%d", &aTarg);
+        fscanf(fInputFile, "%d", &zTarg);
+        fgets(read, 200, fInputFile);
+        fgets(read, 200, fInputFile);
+        fgets(read, 36, fInputFile);
+        fscanf(fInputFile, "%f", &b);
+        fgets(read, 200, fInputFile);
+        fgets(read, 39, fInputFile);
+        fscanf(fInputFile, "%e", &ekin);
+        fgets(read, 200, fInputFile);
+        fgets(read, 7, fInputFile);
+        fscanf(fInputFile, "%d", &evnr);
+        fgets(read, 200, fInputFile);
+        for (int iline=0; iline<8; iline++)  { fgets(read, 200,fInputFile); }
+        fscanf(fInputFile, "%d", &ntracks);
+        fgets(read, 200, fInputFile);
+        fgets(read, 200, fInputFile);
+#endif
 
         cout << "-I MpdUrqmdGenerator: Event " << evnr << " skipped!" << endl;
 
@@ -296,7 +380,12 @@ Bool_t MpdUrqmdGenerator::SkipEvents(Int_t count) {
         for (int itrack = 0; itrack < ntracks; itrack++) {
 
             // Read momentum and PID from file
+#ifdef GZIP_SUPPORT
             gzgets(fInputFile, read, 200);
+#else
+            fgets(read, 81, fInputFile);
+            fgets(read, 200, fInputFile);
+#endif
         }
     }
     return kTRUE;
@@ -336,4 +425,5 @@ void MpdUrqmdGenerator::SetEventPlane(Double_t phiMin, Double_t phiMax) {
 }
 
 
+
 ClassImp(MpdUrqmdGenerator);
diff --git a/mpdgenerators/MpdUrqmdGenerator.h b/generators/MpdUrqmdGenerator.h
similarity index 79%
rename from mpdgenerators/MpdUrqmdGenerator.h
rename to generators/MpdUrqmdGenerator.h
index 76a929e..75bc05f 100644
--- a/mpdgenerators/MpdUrqmdGenerator.h
+++ b/generators/MpdUrqmdGenerator.h
@@ -12,8 +12,8 @@
  calculation has to be performed in the CM system of the collision; Lorentz
  transformation into the lab is performed by this class.
  Derived from FairGenerator.
- **/
-
+**/
+#define GZIP_SUPPORT // version with gz support
 
 #ifndef MPDURQMDGENERATOR_H
 #define MPDURQMDGENERATOR_H
@@ -23,13 +23,18 @@
 #include <fstream>
 #include <map>
 
+#ifdef GZIP_SUPPORT
+#ifndef __CINT__
 #include <zlib.h>
+#endif
+#endif
 
 class TVirtualMCStack;
 class FairPrimaryGenerator;
 
-class MpdUrqmdGenerator : public FairGenerator {
-public:
+class MpdUrqmdGenerator : public FairGenerator
+{
+  public:
 
     /** Default constructor without arguments should not be used. **/
     MpdUrqmdGenerator();
@@ -57,16 +62,22 @@ public:
 
     void SetEventPlane(Double_t phiMin, Double_t phiMax);
 
-private:
+  private:
 
-    gzFile fInputFile; //!  Input file
+#ifdef GZIP_SUPPORT
+    #ifndef __CINT__
+    gzFile fInputFile;                    //!  Input file
+    #endif
+#else
+    FILE* fInputFile;                     //!  Input file
+#endif
 
-    std::map<Int_t, Int_t> fParticleTable; //!  Map from UrQMD PID to PDGPID
+    std::map<Int_t,Int_t> fParticleTable;      //!  Map from UrQMD PID to PDGPID
 
     Double32_t fPhiMin, fPhiMax; // Limits of event plane angle
     Bool_t fEventPlaneSet; // Flag whether event plane angle is used
 
-    const Char_t* fFileName; //!  Input file name
+    const Char_t* fFileName;              //!  Input file name
 
     /** Private method ReadConversionTable. Reads the conversion table
         from UrQMD particle code to PDG particle code and fills the
@@ -76,7 +87,7 @@ private:
     MpdUrqmdGenerator(const MpdUrqmdGenerator&);
     MpdUrqmdGenerator& operator=(const MpdUrqmdGenerator&);
 
-    ClassDef(MpdUrqmdGenerator, 1);
+    ClassDef(MpdUrqmdGenerator,1);
 
 };
 
diff --git a/mpdgenerators/MpdVHLLEGenerator.cxx b/generators/MpdVHLLEGenerator.cxx
similarity index 100%
rename from mpdgenerators/MpdVHLLEGenerator.cxx
rename to generators/MpdVHLLEGenerator.cxx
diff --git a/mpdgenerators/MpdVHLLEGenerator.h b/generators/MpdVHLLEGenerator.h
similarity index 100%
rename from mpdgenerators/MpdVHLLEGenerator.h
rename to generators/MpdVHLLEGenerator.h
diff --git a/geobase/CMakeLists.txt b/geobase/CMakeLists.txt
index d41581c..3acf29e 100644
--- a/geobase/CMakeLists.txt
+++ b/geobase/CMakeLists.txt
@@ -1,20 +1,31 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/fairtools
+  ${CMAKE_SOURCE_DIR}/geobase
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR} 
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR} 
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
 
 set(SRCS
@@ -57,7 +68,7 @@ FairGeoBasicShape.cxx
 Set(HEADERS )
 Set(LINKDEF GeoBaseLinkDef.h)
 Set(LIBRARY_NAME GeoBase)
-Set(DEPENDENCIES Geom Graf3d Cint Core)
+Set(DEPENDENCIES Geom Graf3d Core FairTools)
 
 GENERATE_LIBRARY()
 
diff --git a/geobase/FairGeoAsciiIo.cxx b/geobase/FairGeoAsciiIo.cxx
index 00b6b92..205ece6 100644
--- a/geobase/FairGeoAsciiIo.cxx
+++ b/geobase/FairGeoAsciiIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -7,13 +14,16 @@
 // Class for geometry I/O from ASCII file
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoAsciiIo.h"
 
-#include "FairGeoSet.h"
-#include "FairGeoMedia.h"
-#include "FairGeoIo.h"
-#include "FairGeoInterface.h"
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoIo.h"                  // for FairGeoIo
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoSet.h"                 // for FairGeoSet
+
+#include <stdio.h>                      // for sscanf
+#include <string.h>                     // for strcmp, strlen, strtok, etc
+#include <iostream>                     // for cout
 
 using std::cout;
 using std::endl;
@@ -45,7 +55,7 @@ Bool_t FairGeoAsciiIo::open(const char* fname,const Text_t* status)
 {
   // Opens the file fname
   close();
-  if (!file) { file=new fstream(); }
+  if (!file) { file=new std::fstream(); }
   else { (file->clear()); }
   if (!filedir.IsNull()) { filename=filedir+"/"+fname; }
   else { filename=fname; }
@@ -218,7 +228,7 @@ Bool_t FairGeoAsciiIo::readDetectorSetup(FairGeoInterface* interface)
         if (set&&mod) {
           char* ss=strtok(buf,d);
           if (ss&&strlen(ss)>3) {
-            secNo=(Int_t)(ss[3]-'0')-1;
+            secNo=static_cast<Int_t>(ss[3]-'0')-1;
             for(Int_t i=0; i<maxModules&&mod; i++) {
               ss=strtok(NULL,d);
               if (ss) { sscanf(ss,"%i",&mod[i]); }
diff --git a/geobase/FairGeoAsciiIo.h b/geobase/FairGeoAsciiIo.h
index edd3e47..3a5b443 100644
--- a/geobase/FairGeoAsciiIo.h
+++ b/geobase/FairGeoAsciiIo.h
@@ -1,12 +1,20 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOASCIIIO_H
 #define FAIRGEOASCIIIO_H
 
-#include "FairGeoIo.h"
+#include "FairGeoIo.h"                  // for FairGeoIo
 
-#include "TString.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Bool_t, etc
+#include "TString.h"                    // for TString
 
-#include <fstream>
-//#include <iomanip>
+#include <fstream>                      // for fstream
 
 class FairGeoSet;
 class FairGeoMedia;
@@ -21,7 +29,7 @@ class FairGeoAsciiIo: public FairGeoIo
     TString  filename;
     TString  filedir;
     Bool_t   writable;
-    fstream* file;
+    std::fstream* file;
   public:
     FairGeoAsciiIo();
     virtual ~FairGeoAsciiIo();
diff --git a/geobase/FairGeoAssembly.cxx b/geobase/FairGeoAssembly.cxx
index c5d593d..ad9a7c6 100644
--- a/geobase/FairGeoAssembly.cxx
+++ b/geobase/FairGeoAssembly.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : M. Al-Turany  21/04/2009
 
 /////////////////////////////////////////////////////////////
@@ -6,13 +13,18 @@
 //
 // class for the shape Assembly
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoAssembly.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for fstream, etc
 
 ClassImp(FairGeoAssembly)
 
@@ -44,7 +56,7 @@ FairGeoAssembly::~FairGeoAssembly()
   }
 }
 
-Int_t FairGeoAssembly::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoAssembly::readPoints(std::fstream*,FairGeoVolume*)
 {
 
   //Assemblies has no parameters so just return 1;
@@ -52,14 +64,14 @@ Int_t FairGeoAssembly::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-TArrayD* FairGeoAssembly::calcVoluParam(FairGeoVolume* volu)
+TArrayD* FairGeoAssembly::calcVoluParam(FairGeoVolume*)
 {
   // nothing to calculate
 
   return param;
 }
 
-Bool_t FairGeoAssembly::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoAssembly::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 4 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
@@ -84,7 +96,7 @@ void FairGeoAssembly::printPoints(FairGeoVolume* volu)
 
 
 
-void FairGeoAssembly::calcVoluPosition(FairGeoVolume* volu,
+void FairGeoAssembly::calcVoluPosition(FairGeoVolume*,
                                        const FairGeoTransform& dTC,const FairGeoTransform& mTR)
 {
   // calls the function posInMother(...) to calculate the position of the
diff --git a/geobase/FairGeoAssembly.h b/geobase/FairGeoAssembly.h
index fa4ecdc..c69d8f2 100644
--- a/geobase/FairGeoAssembly.h
+++ b/geobase/FairGeoAssembly.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOASSEMBLY_H
 #define FAIRGEOASSEMBLY_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoAssembly::Class, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoAssembly : public FairGeoBasicShape
 {
@@ -14,8 +27,8 @@ class FairGeoAssembly : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream* pFile,FairGeoVolume* volu);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream* pFile,FairGeoVolume* volu);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
 
     ClassDef(FairGeoAssembly,0) // class for geometry shape ASSEMBLY
diff --git a/geobase/FairGeoBasicShape.cxx b/geobase/FairGeoBasicShape.cxx
index 9804c47..065c5ca 100644
--- a/geobase/FairGeoBasicShape.cxx
+++ b/geobase/FairGeoBasicShape.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 29/06/99 by Ilse Koenig
@@ -9,15 +16,17 @@
 // Base class of the all shapes
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoBasicShape.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
 
-#include "TArrayD.h"
+#include "TArrayD.h"                    // for TArrayD
 
-#include <iostream>
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <iostream>                     // for cout
 
 using std::cout;
 
@@ -53,7 +62,7 @@ FairGeoBasicShape::~FairGeoBasicShape()
 }
 
 
-Int_t FairGeoBasicShape::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoBasicShape::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads nPoints with 3 components from Ascii file
   // if the array of points is not existing in the volume it is created and
@@ -73,7 +82,7 @@ Int_t FairGeoBasicShape::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoBasicShape::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoBasicShape::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes nPoints with 3 components to Ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoBasicShape.h b/geobase/FairGeoBasicShape.h
index f5e0ae1..991e7c4 100644
--- a/geobase/FairGeoBasicShape.h
+++ b/geobase/FairGeoBasicShape.h
@@ -1,14 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOBASICSHAPE_H
 #define FAIRGEOBASICSHAPE_H
 
-//#include "FairGeoTransform.h"
+#include "TNamed.h"                     // for TNamed
 
-#include "TNamed.h"
-//#include "TString.h"
-//#include "TArrayD.h"
-//#include "TShape.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Int_t, etc
 
-#include <fstream>
+#include <fstream>                      // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
@@ -33,8 +38,8 @@ class FairGeoBasicShape : public TNamed
     TArrayD* getParam() {return param;}
     FairGeoTransform* getCenterPosition() {return center;}
     FairGeoTransform* getVoluPosition() {return position;}
-    virtual Int_t readPoints(fstream*,FairGeoVolume*);
-    virtual Bool_t writePoints(fstream*,FairGeoVolume*);
+    virtual Int_t readPoints(std::fstream*,FairGeoVolume*);
+    virtual Bool_t writePoints(std::fstream*,FairGeoVolume*);
     virtual void printPoints(FairGeoVolume* volu);
     virtual TArrayD* calcVoluParam(FairGeoVolume*) {return 0;}
     virtual void calcVoluPosition(FairGeoVolume*,const FairGeoTransform&);
diff --git a/geobase/FairGeoBrik.cxx b/geobase/FairGeoBrik.cxx
index e15eb19..4cdab4a 100644
--- a/geobase/FairGeoBrik.cxx
+++ b/geobase/FairGeoBrik.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 14/05/99 by Ilse Koenig
@@ -13,13 +20,14 @@
 // in the technical coordinate system
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoBrik.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
 
-#include "TArrayD.h"
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
 ClassImp(FairGeoBrik)
 
diff --git a/geobase/FairGeoBrik.h b/geobase/FairGeoBrik.h
index f8f67d1..41bda12 100644
--- a/geobase/FairGeoBrik.h
+++ b/geobase/FairGeoBrik.h
@@ -1,10 +1,21 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOBRIK_H
 #define FAIRGEOBRIK_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Rtypes.h"                     // for FairGeoBrik::Class, etc
+
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoBrik : public FairGeoBasicShape
 {
diff --git a/geobase/FairGeoBuilder.cxx b/geobase/FairGeoBuilder.cxx
index 031425e..b314c4a 100644
--- a/geobase/FairGeoBuilder.cxx
+++ b/geobase/FairGeoBuilder.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 11/11/03 by Ilse Koenig
 
diff --git a/geobase/FairGeoBuilder.h b/geobase/FairGeoBuilder.h
index 6fd6b10..b9ca6d8 100644
--- a/geobase/FairGeoBuilder.h
+++ b/geobase/FairGeoBuilder.h
@@ -1,9 +1,17 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOBUILDER_H
 #define FAIRGEOBUILDER_H
 
-#include "TNamed.h"
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Int_t, etc
 
-//class FairGeoSet;
 class FairGeoNode;
 class FairGeoMedium;
 
@@ -24,6 +32,8 @@ class FairGeoBuilder : public TNamed
     virtual Bool_t createNode(FairGeoNode*, Int_t hadFormat =0)=0;
     virtual Int_t createMedium(FairGeoMedium*)=0;
     virtual void finalize() {}
+    inline const Int_t& GetNMedia() const { return nMed; }
+    inline void SetNMedia(const Int_t& nmed) { nMed = nmed; }
     ClassDef(FairGeoBuilder,0)
 };
 
diff --git a/geobase/FairGeoCompositeVolume.cxx b/geobase/FairGeoCompositeVolume.cxx
index 7e84503..0e2d3be 100644
--- a/geobase/FairGeoCompositeVolume.cxx
+++ b/geobase/FairGeoCompositeVolume.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 20/04/99
 
@@ -6,9 +13,12 @@
 //
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoCompositeVolume.h"
 
+#include "TObjArray.h"                  // for TObjArray
+
+#include <stddef.h>                     // for NULL
+
 ClassImp(FairGeoCompositeVolume)
 
 FairGeoCompositeVolume::FairGeoCompositeVolume(Int_t nComp)
@@ -36,12 +46,16 @@ Int_t FairGeoCompositeVolume::getNumComponents()
 
 FairGeoVolume* FairGeoCompositeVolume::getComponent(const Int_t n)
 {
-  return (FairGeoVolume*)components->At(n);
+  return static_cast<FairGeoVolume*>(components->At(n));
 }
 
 void FairGeoCompositeVolume::createComponents(const Int_t n)
 {
-  if (components) { components->Delete(); }
+  if (components) { 
+    components->Delete(); 
+  } else {
+    components=new TObjArray();
+  }
   components->Expand(n);
 }
 
@@ -55,7 +69,7 @@ void FairGeoCompositeVolume::clear()
 {
   FairGeoVolume::clear();
   Int_t n=getNumComponents();
-  for(Int_t i=0; i<n; i++) { ((FairGeoVolume*)components->At(i))->clear(); }
+  for(Int_t i=0; i<n; i++) { (static_cast<FairGeoVolume*>(components->At(i)))->clear(); }
 }
 
 void FairGeoCompositeVolume::print()
@@ -63,7 +77,7 @@ void FairGeoCompositeVolume::print()
   FairGeoVolume::print();
   FairGeoVolume* v;
   for(Int_t i=0; i<components->GetSize(); i++) {
-    v=(FairGeoVolume*)components->At(i);
+    v=static_cast<FairGeoVolume*>(components->At(i));
     if (v) { v->print(); }
   }
 }
diff --git a/geobase/FairGeoCompositeVolume.h b/geobase/FairGeoCompositeVolume.h
index 3ad75a0..bf125c2 100644
--- a/geobase/FairGeoCompositeVolume.h
+++ b/geobase/FairGeoCompositeVolume.h
@@ -1,7 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOCOMPOSITEVOLUME_H
 #define FAIRGEOCOMPOSITEVOLUME_H
 
-#include "FairGeoVolume.h"
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "Rtypes.h"                     // for Int_t, etc
 
 class TObjArray;
 /**
diff --git a/geobase/FairGeoCone.cxx b/geobase/FairGeoCone.cxx
index 671f28f..c25c10b 100644
--- a/geobase/FairGeoCone.cxx
+++ b/geobase/FairGeoCone.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 28/06/99 by Ilse Koenig
@@ -24,13 +31,19 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoCone.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for fstream, etc
 
 ClassImp(FairGeoCone)
 
@@ -63,7 +76,7 @@ FairGeoCone::~FairGeoCone()
 }
 
 
-Int_t FairGeoCone::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoCone::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 4 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -87,7 +100,7 @@ Int_t FairGeoCone::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoCone::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoCone::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 4 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoCone.h b/geobase/FairGeoCone.h
index 7e9fc5e..c6e2d29 100644
--- a/geobase/FairGeoCone.h
+++ b/geobase/FairGeoCone.h
@@ -1,11 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOCONE_H
 #define FAIRGEOCONE_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoCone::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
+
 
 class FairGeoTransform;
 class FairGeoVolume;
-
+class TArrayD;
 /**
  * class for geometry shape CONE
  * @author ilse koenig
@@ -18,8 +31,8 @@ class FairGeoCone : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoCone,0) //
 };
diff --git a/geobase/FairGeoCons.cxx b/geobase/FairGeoCons.cxx
index c426165..1612bb7 100644
--- a/geobase/FairGeoCons.cxx
+++ b/geobase/FairGeoCons.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 28/06/99 by Ilse Koenig
@@ -27,13 +34,19 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoCons.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for fstream, etc
 
 ClassImp(FairGeoCons)
 
@@ -66,7 +79,7 @@ FairGeoCons::~FairGeoCons()
 }
 
 
-Int_t FairGeoCons::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoCons::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 5 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -91,7 +104,7 @@ Int_t FairGeoCons::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoCons::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoCons::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 5 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoCons.h b/geobase/FairGeoCons.h
index 6eaea73..5560bdb 100644
--- a/geobase/FairGeoCons.h
+++ b/geobase/FairGeoCons.h
@@ -1,11 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOCONS_H
 #define FAIRGEOCONS_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoCons::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
-
+class TArrayD;
 /**
  * class for geometry shape CONS
  * @author ilse koenig
@@ -18,8 +30,8 @@ class FairGeoCons : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoCons,0) //
 };
diff --git a/geobase/FairGeoEltu.cxx b/geobase/FairGeoEltu.cxx
index 6f88c5b..733b79c 100644
--- a/geobase/FairGeoEltu.cxx
+++ b/geobase/FairGeoEltu.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 28/06/99 by Ilse Koenig
@@ -21,13 +28,19 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoEltu.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for fstream, etc
 
 ClassImp(FairGeoEltu)
 
@@ -60,7 +73,7 @@ FairGeoEltu::~FairGeoEltu()
 }
 
 
-Int_t FairGeoEltu::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoEltu::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 3 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -85,7 +98,7 @@ Int_t FairGeoEltu::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoEltu::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoEltu::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 3 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoEltu.h b/geobase/FairGeoEltu.h
index c556cac..62e524e 100644
--- a/geobase/FairGeoEltu.h
+++ b/geobase/FairGeoEltu.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOELTU_H
 #define FAIRGEOELTU_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoEltu::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 /**
  * class for geometry shape ELTU
@@ -18,8 +31,8 @@ class FairGeoEltu : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoEltu,0) //
 };
diff --git a/geobase/FairGeoInterface.cxx b/geobase/FairGeoInterface.cxx
index d92ff54..ddbb70f 100644
--- a/geobase/FairGeoInterface.cxx
+++ b/geobase/FairGeoInterface.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/03 by Ilse Koenig
 
@@ -14,23 +21,25 @@
 //  4-nSets is now set by a method SetNoOfSets(Int_t) (see header file)
 
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoInterface.h"
 
-#include "FairGeoIo.h"
-#include "FairGeoAsciiIo.h"
-#include "FairGeoMedia.h"
-#include "FairGeoShapes.h"
-#include "FairGeoSet.h"
-#include "FairGeoBuilder.h"
-//#include "FairGeoNode.h"
+#include "FairGeoAsciiIo.h"             // for FairGeoAsciiIo
+#include "FairGeoBuilder.h"             // for FairGeoBuilder
+#include "FairGeoIo.h"                  // for FairGeoIo
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoSet.h"                 // for FairGeoSet
+#include "FairGeoShapes.h"              // for FairGeoShapes
 
-#include "TClass.h"
-#include "TObjArray.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TClass.h"                     // for TClass
+#include "TList.h"                      // for TList
+#include "TObjArray.h"                  // for TObjArray
 
-#include <iostream>
-//#include <iomanip>
-//#include <ctime>
+#include <stdio.h>                      // for sprintf, NULL
+#include <string.h>                     // for strcmp
+#include <sys/select.h>                 // for time_t
+#include <time.h>                       // for tm, localtime, time
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using std::cout;
 using std::endl;
@@ -121,49 +130,49 @@ void FairGeoInterface::addInputFile(const char* file)
       media->setInputFile(file);
     } else {
       if (setName.Contains("cave")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoCave);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoCave));
         if (!pSet) {
           pSet=new FairGeoCave;
           sets->AddAt(pSet,kFairGeoCave);
         }
       } else if (setName.Contains("pipe")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoPipe);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoPipe));
         if (!pSet) {
           pSet=new FairGeoPipe;
           sets->AddAt(pSet,kFairGeoPipe);
         }
       } else if (setName.Contains("target")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoTarget);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTarget));
         if (!pSet) {
           pSet=new FairGeoTarget;
           sets->AddAt(pSet,kFairGeoTarget);
         }
       } else if (setName.Contains("magnet")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoMagnet);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoMagnet));
         if (!pSet) {
           pSet=new FairGeoMagnet;
           sets->AddAt(pSet,kFairGeoMagnet);
         }
       } else if (setName.Contains("rich")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoRich);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoRich));
         if (!pSet) {
           pSet=new FairGeoRich;
           sets->AddAt(pSet,kFairGeoRich);
         }
       } else if (setName.Contains("sts")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoSts);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoSts));
         if (!pSet) {
           pSet=new FairGeoSts;
           sets->AddAt(pSet,kFairGeoSts);
         }
       } else if (setName.Contains("trd")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoTrd);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTrd));
         if (!pSet) {
           pSet=new FairGeoTrd;
           sets->AddAt(pSet,kFairGeoTrd);
         }
       } else if (setName.Contains("tof")) {
-        pSet=(FairGeoSet*)sets->At(kFairGeoTof);
+        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTof));
         if (!pSet) {
           pSet=new FairGeoTof;
           sets->AddAt(pSet,kFairGeoTof);
@@ -188,21 +197,21 @@ FairGeoSet* FairGeoInterface::findSet(const char* name)
   setName.ToLower();
   Int_t l=setName.Last('/')+1;
   setName=setName(l,setName.Length()-l);
-  /*  if (setName.Contains("cave"))        pSet=(FairGeoSet*)sets->At(kFairGeoCave);
-    else if (setName.Contains("pipe"))   pSet=(FairGeoSet*)sets->At(kFairGeoPipe);
-    else if (setName.Contains("target")) pSet=(FairGeoSet*)sets->At(kFairGeoTarget);
-    else if (setName.Contains("magnet"))  pSet=(FairGeoSet*)sets->At(kFairGeoMagnet);
-    else if (setName.Contains("rich"))   pSet=(FairGeoSet*)sets->At(kFairGeoRich);
-    else if (setName.Contains("sts"))    pSet=(FairGeoSet*)sets->At(kFairGeoSts);
-    else if (setName.Contains("trd"))    pSet=(FairGeoSet*)sets->At(kFairGeoTrd);
-    else if (setName.Contains("tof"))    pSet=(FairGeoSet*)sets->At(kFairGeoTof);
-    else if (setName.Contains("ecal")) pSet=(FairGeoSet*)sets->At(kFairGeoEcal);
+  /*  if (setName.Contains("cave"))        pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoCave));
+    else if (setName.Contains("pipe"))   pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoPipe));
+    else if (setName.Contains("target")) pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTarget));
+    else if (setName.Contains("magnet"))  pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoMagnet));
+    else if (setName.Contains("rich"))   pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoRich));
+    else if (setName.Contains("sts"))    pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoSts));
+    else if (setName.Contains("trd"))    pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTrd));
+    else if (setName.Contains("tof"))    pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoTof));
+    else if (setName.Contains("ecal")) pSet=static_cast<FairGeoSet*>(sets->At(kFairGeoEcal));
     return pSet;
     */
   for(Int_t i=0; i<nSets; i++) {
     PSetName=sets->At(i)->GetName();
     if (PSetName.Contains(setName.Data())) {
-      pSet=(FairGeoSet*)sets->At(i);
+      pSet=static_cast<FairGeoSet*>(sets->At(i));
       cout << "FairGeoInterface::findSet" <<pSet->GetName() <<endl;
       break;
     }
@@ -292,7 +301,7 @@ Bool_t FairGeoInterface::readAll()
   if(rc) { rc=readMedia(); }
   FairGeoSet* pSet=0;
   for(Int_t i=0; i<nSets&&rc; i++) {
-    pSet=(FairGeoSet*)sets->At(i);
+    pSet=static_cast<FairGeoSet*>(sets->At(i));
     if (pSet) {
       cout<<"Read "<<pSet->GetName()<<endl;
       rc=readSet(pSet);
@@ -308,7 +317,7 @@ Bool_t FairGeoInterface::writeAll()
   FairGeoSet* pSet=0;
   rc=writeMedia();
   for(Int_t i=0; i<nSets&&rc; i++) {
-    pSet=(FairGeoSet*)sets->At(i);
+    pSet=static_cast<FairGeoSet*>(sets->At(i));
     if (pSet) { rc=writeSet(pSet); }
   }
   return rc;
@@ -323,7 +332,7 @@ Bool_t FairGeoInterface::createAll(Bool_t withCleanup)
   if (geoBuilder) {
     FairGeoSet* pSet=0;
     for(Int_t i=0; i<nSets&&rc; i++) {
-      pSet=(FairGeoSet*)sets->At(i);
+      pSet=static_cast<FairGeoSet*>(sets->At(i));
       if (pSet) {
         cout<<"Create "<<pSet->GetName()<<endl;
         rc=pSet->create(geoBuilder);
@@ -354,7 +363,7 @@ Bool_t FairGeoInterface::createGeometry(Bool_t withCleanup)
     if (rc) { rc=readMedia(); }
     FairGeoSet* pSet=0;
     for(Int_t i=0; i<nSets&&rc; i++) {
-      pSet=(FairGeoSet*)sets->At(i);
+      pSet=static_cast<FairGeoSet*>(sets->At(i));
       if (pSet) {
         cout<<"Read and create "<<pSet->GetName()<<endl;
         rc=readSet(pSet);
@@ -422,7 +431,7 @@ Bool_t FairGeoInterface::connectOutput (const char* name)
       fName=fName+buf+".geo";
       output->open(fName,"out");
       cout<<"Output file for "<<name<<":  "
-          <<((FairGeoAsciiIo*)output)->getFilename()<<endl;
+          <<(static_cast<FairGeoAsciiIo*>(output))->getFilename()<<endl;
     }
     if (output->isOpen()&&output->isWritable()) { return kTRUE; }
   } else { Error("connectOutput","No output open"); }
@@ -444,7 +453,7 @@ void FairGeoInterface::print()
   cout<<"List of detector parts:\n";
   FairGeoSet* pSet=0;
   for(Int_t i=0; i<nSets; i++) {
-    pSet=(FairGeoSet*)sets->At(i);
+    pSet=static_cast<FairGeoSet*>(sets->At(i));
     if (pSet) { cout<<"  "<<pSet->GetName()<<":\t"<<pSet->getGeomFile()<<'\n'; }
   }
   cout<<"********************************************************************\n";
@@ -467,7 +476,7 @@ Bool_t FairGeoInterface::readSetupFile()
   // Reads the detector setups, needed for create only subsets
   Bool_t rc=kTRUE;
   if (setupFile.Length()>0) {
-    FairGeoAsciiIo* input=(FairGeoAsciiIo*)(connectInput(setupFile));
+    FairGeoAsciiIo* input=static_cast<FairGeoAsciiIo*>(connectInput(setupFile));
     if (input) { rc=input->readDetectorSetup(this); }
   }
   return rc;
diff --git a/geobase/FairGeoInterface.h b/geobase/FairGeoInterface.h
index 749f30e..83190d4 100644
--- a/geobase/FairGeoInterface.h
+++ b/geobase/FairGeoInterface.h
@@ -1,10 +1,17 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOINTERFACE_H
 #define FAIRGEOINTERFACE_H
 
-#include "TObject.h"
-#include "TString.h"
-//#include "TObjArray.h"
-//#include "TList.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Bool_t, kFALSE, Int_t, etc
+#include "TString.h"                    // for TString
 
 class FairGeoIo;
 class FairGeoSet;
diff --git a/geobase/FairGeoIo.cxx b/geobase/FairGeoIo.cxx
index 40ab1d2..c5acdc4 100644
--- a/geobase/FairGeoIo.cxx
+++ b/geobase/FairGeoIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
diff --git a/geobase/FairGeoIo.h b/geobase/FairGeoIo.h
index 455722b..64656ee 100644
--- a/geobase/FairGeoIo.h
+++ b/geobase/FairGeoIo.h
@@ -1,7 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOIO_H
 #define FAIRGEOIO_H
 
-#include "TObject.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Bool_t, FairGeoIo::Class, etc
 
 class FairGeoMedia;
 class FairGeoSet;
diff --git a/geobase/FairGeoLoader.cxx b/geobase/FairGeoLoader.cxx
index 40c66d1..6ae0ff4 100644
--- a/geobase/FairGeoLoader.cxx
+++ b/geobase/FairGeoLoader.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /***************************************************************************
                           FairGeoLoader.cxx  -  description
                              -------------------
@@ -5,17 +12,17 @@
     copyright            : (C) 2004 by ilse koenig , M. Al-turany
     email                : m.al-turany@gsi.de
  ***************************************************************************/
-
 #include "FairGeoLoader.h"
 
-#include "FairGeoInterface.h"
-#include "FairGeoRootBuilder.h"
-//#include "FairGeoG3Builder.h"
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoRootBuilder.h"         // for FairGeoRootBuilder
 
-#include "TGeoManager.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TGeoManager.h"                // for TGeoManager
 
-#include <iostream>
-#include <cstdlib>
+#include <string.h>                     // for strncmp
+#include <cstdlib>                      // for NULL, exit
+#include <iostream>                     // for cout, endl, operator<<, etc
 
 using std::cout;
 using std::endl;
@@ -49,7 +56,7 @@ FairGeoLoader::FairGeoLoader(const char* Name, const char* title)
   if ( strncmp(Name,"TGeo",4) == 0 ) {
     TGeoManager* geom = new TGeoManager("FAIRGeom", "FAIR geometry");
     fGeoBuilder=new FairGeoRootBuilder("TGeo builder","geometry builder");
-    ((FairGeoRootBuilder*)fGeoBuilder)->setGeoManager(geom);
+    (static_cast<FairGeoRootBuilder*>(fGeoBuilder))->setGeoManager(geom);
   } else if ( strncmp(Name,"G3Native",8) == 0) {
     cout << "-I- FairGeoLoader() : Native G3 Geometry is used: This option is not supported any more!" << endl;
     exit(0);
diff --git a/geobase/FairGeoLoader.h b/geobase/FairGeoLoader.h
index 228bd87..bdd6fd7 100644
--- a/geobase/FairGeoLoader.h
+++ b/geobase/FairGeoLoader.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /***************************************************************************
                           FairGeoLoader.h  -  description
                              -------------------
@@ -10,8 +17,9 @@
 #ifndef FairGeoLOADER_H
 #define FairGeoLOADER_H
 
-#include "TNamed.h"
+#include "TNamed.h"                     // for TNamed
 
+#include "Rtypes.h"                     // for FairGeoLoader::Class, etc
 
 class FairGeoInterface;
 class FairGeoBuilder;
diff --git a/geobase/FairGeoMatrix.cxx b/geobase/FairGeoMatrix.cxx
index 821c119..e563c41 100644
--- a/geobase/FairGeoMatrix.cxx
+++ b/geobase/FairGeoMatrix.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- Author : M. Sanchez
 //*-- Modified : 07.03.2001
 
diff --git a/geobase/FairGeoMatrix.h b/geobase/FairGeoMatrix.h
index bba3e2e..8b441e0 100644
--- a/geobase/FairGeoMatrix.h
+++ b/geobase/FairGeoMatrix.h
@@ -1,9 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOMATRIX_H
 #define FAIRGEOMATRIX_H
 
-#include "FairGeoVector.h"
+#include "TObject.h"                    // for TObject
 
-#include "TObject.h"
+#include "FairGeoVector.h"              // for FairGeoVector
+
+#include "Rtypes.h"                     // for Double_t, etc
 
 /**
  * @author Ilse koenig
diff --git a/geobase/FairGeoMedia.cxx b/geobase/FairGeoMedia.cxx
index b43bfd6..7390fda 100644
--- a/geobase/FairGeoMedia.cxx
+++ b/geobase/FairGeoMedia.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Last modified : 10/11/03 by Ilse Koenig
 
@@ -10,6 +17,7 @@
 
 #include "FairGeoMedia.h"
 #include "FairGeoMedium.h"
+#include "FairLogger.h"
 
 #include "TList.h"
 
@@ -43,7 +51,7 @@ FairGeoMedia::~FairGeoMedia()
 FairGeoMedium* FairGeoMedia::getMedium(const char* mediumName)
 {
   // Returns the medium with name mediumName
-  return (FairGeoMedium*)media->FindObject(mediumName);
+  return static_cast<FairGeoMedium*>(media->FindObject(mediumName));
 }
 
 void FairGeoMedia::addMedium(FairGeoMedium* m)
@@ -59,7 +67,7 @@ void FairGeoMedia::list()
   cout<<"List of media:\n";
   TListIter iter(media);
   FairGeoMedium* medium;
-  while((medium=(FairGeoMedium*)iter.Next())) {
+  while((medium=static_cast<FairGeoMedium*>(iter.Next()))) {
     cout<<"  "<<medium->GetName()<<"\n";
   }
 }
@@ -73,7 +81,7 @@ void FairGeoMedia::print()
   TListIter iter(media);
   FairGeoMedium* medium;
   Int_t i=0;
-  while((medium=(FairGeoMedium*)iter.Next())) {
+  while((medium=static_cast<FairGeoMedium*>(iter.Next()))) {
     if (medium->getAutoFlag()!=0) {
       medium->print();
       i++;
@@ -84,16 +92,16 @@ void FairGeoMedia::print()
     cout<<"//----------------------------------------------\n";
     cout<<"AUTONULL\n";
     cout<<"//----------------------------------------------\n";
-    while((medium=(FairGeoMedium*)iter.Next())) {
+    while((medium=static_cast<FairGeoMedium*>(iter.Next()))) {
       if (medium->getAutoFlag()==0) { medium->print(); }
     }
   }
 }
 
-void FairGeoMedia::read(fstream& fin)
+void FairGeoMedia::read(std::fstream& fin)
 {
   // Reads the media from file
-  cout<<"-I- FairGeoMedia  Read media"<<endl;
+  LOG(INFO) << "FairGeoMedia: Read media " << FairLogger::endl;
   const Int_t maxBuf=256;
   char buf[maxBuf];
   Int_t autoflag=1;
@@ -112,7 +120,7 @@ void FairGeoMedia::read(fstream& fin)
   }
 }
 
-void FairGeoMedia::write(fstream& fout)
+void FairGeoMedia::write(std::fstream& fout)
 {
   // Writes the media to file
   if (!author.IsNull()) { fout<<"//Author:      "<<author<<'\n'; }
@@ -121,7 +129,7 @@ void FairGeoMedia::write(fstream& fout)
   TListIter iter(media);
   FairGeoMedium* medium;
   Int_t i=0;
-  while((medium=(FairGeoMedium*)iter.Next())) {
+  while((medium=static_cast<FairGeoMedium*>(iter.Next()))) {
     if (medium->getAutoFlag()!=0) {
       medium->write(fout);
       i++;
@@ -132,7 +140,7 @@ void FairGeoMedia::write(fstream& fout)
     fout<<"//----------------------------------------------\n";
     fout<<"AUTONULL\n";
     fout<<"//----------------------------------------------\n";
-    while((medium=(FairGeoMedium*)iter.Next())) {
+    while((medium=static_cast<FairGeoMedium*>(iter.Next()))) {
       if (medium->getAutoFlag()==0) { medium->write(fout); }
     }
   }
diff --git a/geobase/FairGeoMedia.h b/geobase/FairGeoMedia.h
index fad5ceb..74eef2c 100644
--- a/geobase/FairGeoMedia.h
+++ b/geobase/FairGeoMedia.h
@@ -1,11 +1,20 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOMEDIA_H
 #define FAIRGEOMEDIA_H
 
+#include "TNamed.h"                     // for TNamed
 
-#include "TNamed.h"
-#include "TString.h"
-//#include "TList.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoMedia::Class, etc
+#include "TString.h"                    // for TString
 
+#include <iosfwd>                       // for fstream
 
 class FairGeoMedium;
 class TList;
@@ -29,10 +38,10 @@ class FairGeoMedia : public TNamed
     void addMedium(FairGeoMedium* m);
     FairGeoMedium* getMedium(const char*);
     TList* getListOfMedia() {return media;}
-    void read(fstream&);
+    void read(std::fstream&);
     void print();
     void list();
-    void write(fstream&);
+    void write(std::fstream&);
     void setAuthor(TString& s) {author=s;}
     void setDescription(TString& s) {description=s;}
     TString& getAuthor() {return author;}
diff --git a/geobase/FairGeoMedium.cxx b/geobase/FairGeoMedium.cxx
index d447f5e..a10fd2b 100644
--- a/geobase/FairGeoMedium.cxx
+++ b/geobase/FairGeoMedium.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- ö : Ilse Koenig
 //*-- Modified : 10/11/2003 by Ilse Koenig
 
@@ -8,9 +15,15 @@
 ////////////////////////////////////////////////////////////////////////////////
 #include "FairGeoMedium.h"
 
-#include <iostream>
-#include <cmath>
-#include "stdlib.h"
+#include "TString.h"                    // for TString
+
+#include <stddef.h>                     // for NULL
+#include <cmath>                        // for pow, log
+// IWYU pragma: no_include <architecture/i386/math.h>
+#include <iostream>                     // for cout
+#include <stdlib.h>                     // for abs
+#include <climits>                      // for INT_MAX
+
 using std::cout;
 using std::log;
 using std::pow;
@@ -88,7 +101,7 @@ void FairGeoMedium::setNComponents(Int_t n)
     cz=new Double_t[k];
     cw=new Double_t[k];
   }
-  weightFac=(Int_t)(n/nComponents);
+  weightFac=static_cast<Int_t>(n/nComponents);
 }
 
 Bool_t FairGeoMedium::setComponent (Int_t i,Double_t a,Double_t z,Double_t weight)
@@ -188,7 +201,7 @@ void FairGeoMedium::getMediumPar(Double_t* params)
   params[9]=0.;
 }
 
-void FairGeoMedium::read(fstream& fin, Int_t aflag )
+void FairGeoMedium::read(std::fstream& fin, Int_t aflag )
 {
   // Reads the parameters from file
   autoflag=aflag;
@@ -222,8 +235,9 @@ void FairGeoMedium::read(fstream& fin, Int_t aflag )
     minstep=-1;
   }
   fin>>n;
-  setNpckov(n);
-  if (n>0) {
+  if (n>0 && n<(INT_MAX-1)) {
+    setNpckov(n);
+//  if (n>0) {
     for(Int_t i=0; i<n; i++) {
       fin>>ppckov[i]>>absco[i]>>effic[i]>>rindex[i];
     }
@@ -254,7 +268,7 @@ void FairGeoMedium::print()
   cout<<'\n';
 }
 
-void FairGeoMedium::write (fstream& fout)
+void FairGeoMedium::write (std::fstream& fout)
 {
   // Writes the medium definition into stream
   const char* bl="  ";
@@ -310,7 +324,7 @@ Bool_t FairGeoMedium::calcRadiationLength()
     fc=az2 * (1./(1.+az2) + 0.20206 - 0.0369*az2 + 0.0083*az2*az2
               - .002F*az2*az2*az2);
     y=log(183./pow(z,1./3.)) - fc;
-    xi=(float)(log(1440./pow(z,2./3.)) / y);
+    xi=static_cast<float>(log(1440./pow(z,2./3.)) / y);
     x0i=fac*alpha/a*z*(z+xi)*y;
     x0itot+=(x0i*w);
   }
diff --git a/geobase/FairGeoMedium.h b/geobase/FairGeoMedium.h
index 872ba1c..bbc1160 100644
--- a/geobase/FairGeoMedium.h
+++ b/geobase/FairGeoMedium.h
@@ -1,10 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOMEDIUM_H
 #define FAIRGEOMEDIUM_H
 
-#include "TNamed.h"
+#include "TNamed.h"                     // for TNamed
 
-#include <fstream>
-//#include <iomanip>
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Double_t, Int_t, Bool_t, etc
+
+#include <fstream>                      // for fstream
 
 /**
  * Class for tracking medium
@@ -65,9 +74,9 @@ class FairGeoMedium  : public TNamed
     Int_t getFieldFlag() {return fldFlag;}
     Double_t getField() {return fld;}
     Double_t getEpsil() {return epsil;}
-    void read(fstream&, Int_t autoflag );
+    void read(std::fstream&, Int_t autoflag );
     void print();
-    void write (fstream&);
+    void write (std::fstream&);
     Bool_t calcRadiationLength();
   private:
     FairGeoMedium(const FairGeoMedium&);
diff --git a/geobase/FairGeoNode.cxx b/geobase/FairGeoNode.cxx
index e77607c..aad708a 100644
--- a/geobase/FairGeoNode.cxx
+++ b/geobase/FairGeoNode.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 //*---Modified: 21/06/2005 D.Bertini
@@ -8,11 +15,18 @@
 // Class to hold the basic geometry properties of a GEANT volume
 //
 ////////////////////////////////////////////////////////////////
-
 #include "FairGeoNode.h"
 
-#include "TList.h"
-#include <cmath>
+#include "FairGeoRotation.h"            // for FairGeoRotation
+#include "FairGeoVector.h"              // for FairGeoVector
+
+#include "TList.h"                      // for TList
+
+#include <cmath>                       // IWYU pragma: keep for abs
+// IWYU pragma: no_include <architecture/i386/math.h>
+#include <stdio.h>                      // for NULL, sscanf
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
 using std::cout;
 using std::endl;
 
@@ -163,6 +177,7 @@ void FairGeoNode::print()
   cout<<"//----------------------------------------------------------\n";
   return;
 
+  /*
   cout<<((const char*)fName)<<'\n';
   if (pMother) { cout<<((const char*)mother)<<'\n'; }
   else { cout<<"-- unknown mother --\n"; }
@@ -177,19 +192,20 @@ void FairGeoNode::print()
   transform.getTransVector().print();
   transform.getRotMatrix().print();
   cout<<"//----------------------------------------------------------\n";
+  */
 }
 
-Bool_t FairGeoNode::write(fstream& fout)
+Bool_t FairGeoNode::write(std::fstream& fout)
 {
   // Writes all parameters of a volume to file
   fout<<fName.Data()<<'\n';
-  if (pMother) { fout<<((const char*)mother)<<'\n'; }
+  if (pMother) { fout<<(const_cast<const char*>(mother.Data()))<<'\n'; }
   else {
     Error("write","Unknown mother for %s\n",fName.Data());
     return kFALSE;
   }
   if (!copyNode) {
-    if (pShape) { fout<<((const char*)shape)<<'\n'; }
+    if (pShape) { fout<<(const_cast<const char*>(shape.Data()))<<'\n'; }
     else {
       Error("write","Unknown shape for %s\n",fName.Data());
       return kFALSE;
@@ -316,7 +332,7 @@ Bool_t FairGeoNode::calcRefPos(FairGeoVector& refPos)
     refPos=node->getTransform().transFrom(refPos);
     node=node->getMotherNode();
     if (!node) {
-      Error("calcModuleTransform","Mother volume %s not found!",node->GetName());
+      Error("calcModuleTransform","Mother of volume %s not found!",GetName());
       return kFALSE;
     }
   } while (node&&!node->isModule());
diff --git a/geobase/FairGeoNode.h b/geobase/FairGeoNode.h
index 1f63d67..39a90e3 100644
--- a/geobase/FairGeoNode.h
+++ b/geobase/FairGeoNode.h
@@ -1,23 +1,30 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEONODE_H
 #define FAIRGEONODE_H
 
-#include "FairGeoVolume.h"
-#include "FairGeoBasicShape.h"
-//#include "FairGeoMedium.h"
-#include "FairGeoTransform.h"
+#include "FairGeoVolume.h"              // for FairGeoVolume
 
-//#include "TArrayD.h"
-//#include "TObjArray.h"
-#include "TGeoVolume.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairGeoTransform.h"           // for FairGeoTransform
 
-//#include <fstream>
-//#include <iomanip>
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Bool_t, FairGeoNode::Class, etc
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+
+#include <iosfwd>                       // for fstream
 
-class FairGeoMedium;
 class FairGeoVector;
 class TArrayD;
-class TObjArray;
-//class TGeoVolume;
+class TGeoVolume;
+class TList;
 
 enum EFairGeoNodeType {
   kFairGeoElement = 0,
@@ -58,10 +65,10 @@ class FairGeoNode : public FairGeoVolume
     void AddDaughter(FairGeoNode* fNode) {fDaughterList->AddLast(fNode);}
     TObjArray* GetListOfDaughters() {return fDaughterList;}
     EFairGeoNodeType getVolumeType() { return volumeType; }
-    Bool_t isTopNode() { return (Bool_t)(volumeType == kFairGeoTopNode);}
-    Bool_t isRefNode() { return (Bool_t)(volumeType == kFairGeoRefNode);}
-    Bool_t isKeepin()  { return (Bool_t)(volumeType == kFairGeoKeepin);}
-    Bool_t isModule()  { return (Bool_t)(volumeType == kFairGeoModule);}
+    Bool_t isTopNode() { return static_cast<Bool_t>((volumeType == kFairGeoTopNode));}
+    Bool_t isRefNode() { return static_cast<Bool_t>((volumeType == kFairGeoRefNode));}
+    Bool_t isKeepin()  { return static_cast<Bool_t>((volumeType == kFairGeoKeepin));}
+    Bool_t isModule()  { return static_cast<Bool_t>((volumeType == kFairGeoModule));}
     Int_t getCopyNo();
     FairGeoBasicShape* getShapePointer() { return pShape; }
     FairGeoNode* getMotherNode() {return pMother;}
@@ -93,7 +100,7 @@ class FairGeoNode : public FairGeoVolume
     Bool_t calcRefPos(FairGeoVector&);
     void clear();
     void print();
-    Bool_t write(fstream&);
+    Bool_t write(std::fstream&);
     Int_t compare(FairGeoNode&);
 
 
diff --git a/geobase/FairGeoOldAsciiIo.cxx b/geobase/FairGeoOldAsciiIo.cxx
index a00ab11..762cc7f 100644
--- a/geobase/FairGeoOldAsciiIo.cxx
+++ b/geobase/FairGeoOldAsciiIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -8,14 +15,20 @@
 // This class is only used for conversion to the new format!
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoOldAsciiIo.h"
 
-#include "FairGeoSet.h"
-#include "FairGeoNode.h"
-#include "FairGeoMedium.h"
-#include "FairGeoMedia.h"
-#include "FairGeoShapes.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoSet.h"                 // for FairGeoSet
+#include "FairGeoShapes.h"              // for FairGeoShapes
+#include "FairGeoTransform.h"           // for FairGeoTransform
+
+#include "TList.h"                      // for TList
+
+#include <string.h>                     // for strcmp, NULL
+#include <iostream>                     // for cerr, cout
 
 using std::cout;
 using std::cerr;
@@ -48,7 +61,7 @@ Bool_t FairGeoOldAsciiIo::open(const char* fname,const Text_t* status)
 {
   // Opens the file fname
   close();
-  if (!file) { file=new fstream(); }
+  if (!file) { file=new std::fstream(); }
   else { (file->clear()); }
   if (!filedir.IsNull()) { filename=filedir+"/"+fname; }
   else { filename=fname; }
@@ -115,12 +128,11 @@ Bool_t FairGeoOldAsciiIo::read(FairGeoSet* set,FairGeoMedia* media)
 {
   // Reads the geometry from file and converts it to the new format
   if (!isOpen() || writable || set==0) { return kFALSE; }
-  fstream& fin=*file;
+  std::fstream& fin=*file;
   fin.clear();
   fin.seekg(0,ios::beg);
   FairGeoNode* volu=0;
   Int_t sensitivity=0, na=0;
-  Double_t par[20];
   TList* volumes=set->getListOfVolumes();
   FairGeoShapes* pShapes=set->getShapes();
   while(!fin.eof()) {
@@ -168,10 +180,12 @@ Bool_t FairGeoOldAsciiIo::read(FairGeoSet* set,FairGeoMedia* media)
       return kFALSE;
     }
     Int_t npar = sh->getNumParam();
+    Double_t* par = new Double_t[npar](); //() after array default-initialize an array
     for (Int_t ik=0; ik<npar; ik++) {
       fin >> par[ik];
     }
     Bool_t rc=calculateShapePoints(par,volu);
+    delete[] par;
     if (!rc) {
       cerr << "Conversion for shape "<<type<<" not implemented."<<endl;
       return kFALSE;
diff --git a/geobase/FairGeoOldAsciiIo.h b/geobase/FairGeoOldAsciiIo.h
index 2ef384f..e50a697 100644
--- a/geobase/FairGeoOldAsciiIo.h
+++ b/geobase/FairGeoOldAsciiIo.h
@@ -1,13 +1,25 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOOLDASCIIIO_H
 #define FAIRGEOOLDASCIIIO_H
 
-#include "FairGeoIo.h"
+#include "FairGeoIo.h"                  // for FairGeoIo
 
-#include "TString.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Bool_t, kFALSE, etc
+#include "TString.h"                    // for TString
 
-#include <fstream>
+#include <fstream>                      // for fstream
 
+class FairGeoInterface;
+class FairGeoMedia;
 class FairGeoNode;
+class FairGeoSet;
 
 /**
  * Class for geometry I/O from ASCII file in FAIR format
@@ -18,7 +30,7 @@ class FairGeoOldAsciiIo: public FairGeoIo
     TString  filename;
     TString  filedir;
     Bool_t   writable;
-    fstream* file;
+    std::fstream* file;
   public:
     FairGeoOldAsciiIo();
     ~FairGeoOldAsciiIo();
@@ -33,7 +45,7 @@ class FairGeoOldAsciiIo: public FairGeoIo
     Bool_t read(FairGeoMedia*) {return kFALSE;}
     Bool_t read(FairGeoSet*,FairGeoMedia*);
     Bool_t write(FairGeoMedia*) {return kFALSE;}
-    Bool_t write(FairGeoSet* set) {return kFALSE;}
+    Bool_t write(FairGeoSet*) {return kFALSE;}
     Bool_t readGeomConfig(FairGeoInterface*) {return kFALSE;}
     Bool_t readDetectorSetup(FairGeoInterface*) {return kFALSE;}
     Bool_t setSimulRefRun(const char*) {return kTRUE;}
diff --git a/geobase/FairGeoPcon.cxx b/geobase/FairGeoPcon.cxx
index 1c2ad50..9836a53 100644
--- a/geobase/FairGeoPcon.cxx
+++ b/geobase/FairGeoPcon.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 26/11/2001 by Ilse Koenig
@@ -22,13 +29,18 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoPcon.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for fstream, etc
 
 ClassImp(FairGeoPcon)
 
@@ -60,7 +72,7 @@ FairGeoPcon::~FairGeoPcon()
 }
 
 
-Int_t FairGeoPcon::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoPcon::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 'points' decribed above from ascii file and stores them in the
   // array 'points' of the volume
@@ -75,7 +87,7 @@ Int_t FairGeoPcon::readPoints(fstream* pFile,FairGeoVolume* volu)
   if (n<=0) { return 0; }
   nPoints=n+2;
   if (volu->getNumPoints()!=nPoints) { volu->createPoints(nPoints); }
-  volu->setPoint(0,(Double_t)n,0.0,0.0);
+  volu->setPoint(0,static_cast<Double_t>(n),0.0,0.0);
   for(Int_t i=1; i<nPoints; i++) {
     pFile->getline(buf,maxbuf);
     if (i!=1) {
@@ -90,7 +102,7 @@ Int_t FairGeoPcon::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoPcon::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoPcon::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
@@ -99,9 +111,11 @@ Bool_t FairGeoPcon::writePoints(fstream* pFile,FairGeoVolume* volu)
     FairGeoVector& v=*(volu->getPoint(i));
     switch(i) {
     case 0:
-      sprintf(buf,"%3i\n",(Int_t)v(0));
+      sprintf(buf,"%3i\n",static_cast<Int_t>(v(0)));
+      break;
     case 1:
       sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
+      break;
     default:
       sprintf(buf,"%9.3f%10.3f%10.3f\n",v(0),v(1),v(2));
     }
@@ -118,9 +132,11 @@ void FairGeoPcon::printPoints(FairGeoVolume* volu)
     FairGeoVector& v=*(volu->getPoint(i));
     switch(i) {
     case 0:
-      printf("%3i\n",(Int_t)v(0));
+      printf("%3i\n",static_cast<Int_t>(v(0)));
+      break;
     case 1:
       printf("%9.3f%10.3f\n",v(0),v(1));
+      break;
     default:
       printf("%9.3f%10.3f%10.3f\n",v(0),v(1),v(2));
     }
diff --git a/geobase/FairGeoPcon.h b/geobase/FairGeoPcon.h
index e7d7d17..34495a4 100644
--- a/geobase/FairGeoPcon.h
+++ b/geobase/FairGeoPcon.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOPCON_H
 #define FAIRGEOPCON_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 /**
  * class for geometry shape PCON
@@ -18,8 +31,8 @@ class FairGeoPcon : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoPcon,0) //
 };
diff --git a/geobase/FairGeoPgon.cxx b/geobase/FairGeoPgon.cxx
index f89e558..122962a 100644
--- a/geobase/FairGeoPgon.cxx
+++ b/geobase/FairGeoPgon.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 26/11/2001 by Ilse Koenig
@@ -22,13 +29,18 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoPgon.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for basic_ostream::write
 
 ClassImp(FairGeoPgon)
 
@@ -60,7 +72,7 @@ FairGeoPgon::~FairGeoPgon()
 }
 
 
-Int_t FairGeoPgon::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoPgon::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 'points' decribed above from ascii file and stores them in the
   // array 'points' of the volume
@@ -75,7 +87,7 @@ Int_t FairGeoPgon::readPoints(fstream* pFile,FairGeoVolume* volu)
   if (n<=0) { return 0; }
   nPoints=n+2;
   if (volu->getNumPoints()!=nPoints) { volu->createPoints(nPoints); }
-  volu->setPoint(0,(Double_t)n,0.0,0.0);
+  volu->setPoint(0,static_cast<Double_t>(n),0.0,0.0);
   for(Int_t i=1; i<nPoints; i++) {
     pFile->getline(buf,maxbuf);
     sscanf(buf,"%lf%lf%lf",&x,&y,&z);
@@ -85,7 +97,7 @@ Int_t FairGeoPgon::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoPgon::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoPgon::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
@@ -93,7 +105,7 @@ Bool_t FairGeoPgon::writePoints(fstream* pFile,FairGeoVolume* volu)
   for(Int_t i=0; i<volu->getNumPoints(); i++) {
     FairGeoVector& v=*(volu->getPoint(i));
     if (i!=0) { sprintf(buf,"%9.3f%10.3f%10.3f\n",v(0),v(1),v(2)); }
-    else { sprintf(buf,"%3i\n",(Int_t)v(0)); }
+    else { sprintf(buf,"%3i\n",static_cast<Int_t>(v(0))); }
     pFile->write(buf,strlen(buf));
   }
   return kTRUE;
@@ -106,7 +118,7 @@ void FairGeoPgon::printPoints(FairGeoVolume* volu)
   for(Int_t i=0; i<volu->getNumPoints(); i++) {
     FairGeoVector& v=*(volu->getPoint(i));
     if (i!=0) { printf("%9.3f%10.3f%10.3f\n",v(0),v(1),v(2)); }
-    else { printf("%3i\n",(Int_t)v(0)); }
+    else { printf("%3i\n",static_cast<Int_t>(v(0))); }
   }
 }
 
diff --git a/geobase/FairGeoPgon.h b/geobase/FairGeoPgon.h
index 786ad68..65b862e 100644
--- a/geobase/FairGeoPgon.h
+++ b/geobase/FairGeoPgon.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOPGON_H
 #define FAIRGEOPGON_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 /**
  * class for geometry shape PGON
@@ -18,8 +31,8 @@ class FairGeoPgon : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoPgon,0) //
 };
diff --git a/geobase/FairGeoRootBuilder.cxx b/geobase/FairGeoRootBuilder.cxx
index 3e5bb7c..8a2fb11 100644
--- a/geobase/FairGeoRootBuilder.cxx
+++ b/geobase/FairGeoRootBuilder.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/03 by Ilse Koenig
 
@@ -7,21 +14,23 @@
 // Class to create the geometry in ROOT
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoRootBuilder.h"
 
-#include "FairGeoMedium.h"
-#include "FairGeoNode.h"
-#include "FairGeoTransform.h"
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoRotation.h"            // for FairGeoRotation
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TGeoManager.h"                // for TGeoManager
+#include "TGeoMaterial.h"               // for TGeoMixture, TGeoMaterial
+#include "TGeoMatrix.h"                 // for TGeoCombiTrans, etc
+#include "TGeoMedium.h"                 // for TGeoMedium
+#include "TGeoVolume.h"                 // for TGeoVolume, etc
+#include "TString.h"                    // for TString
 
-#include "TGeoManager.h"
-#include "TGeoMedium.h"
-#include "TGeoMaterial.h"
-#include "TGeoVolume.h"
-#include "TGeoMatrix.h"
-//#include "TGeoPgon.h"
-//#include "TGeoPcon.h"
-#include "TArrayD.h"
+#include <stdio.h>                      // for NULL, sprintf
 
 ClassImp(FairGeoRootBuilder)
 
@@ -105,7 +114,7 @@ Bool_t FairGeoRootBuilder::createNode(FairGeoNode* volu, Int_t hadFormat)
     const FairGeoRotation& rot=trans->getRotMatrix();
     const FairGeoVector& pos=trans->getTransVector();
     TGeoMatrix* tr=0;
-    if (((FairGeoRotation&)rot).isUnitMatrix()) {
+    if ((const_cast<FairGeoRotation&>(rot)).isUnitMatrix()) {
       tr=new TGeoTranslation(pos.getX(),pos.getY(),pos.getZ());
     } else {
       nRot++;
@@ -149,9 +158,9 @@ Int_t FairGeoRootBuilder::createMedium(FairGeoMedium* med)
     for(Int_t i=0; i<nComp; i++) {
       med->getComponent(i,p);
       if (weightFac>0) {
-        ((TGeoMixture*)material)->DefineElement(i,p[0],p[1],p[2]);
+        (static_cast<TGeoMixture*>(material))->DefineElement(i,p[0],p[1],p[2]);
       } else {
-        ((TGeoMixture*)material)->DefineElement(i,p[0],p[1],p[0]*p[2]/sumWeights);
+        (static_cast<TGeoMixture*>(material))->DefineElement(i,p[0],p[1],p[0]*p[2]/sumWeights);
       }
     }
   }
diff --git a/geobase/FairGeoRootBuilder.h b/geobase/FairGeoRootBuilder.h
index 16b131a..6412734 100644
--- a/geobase/FairGeoRootBuilder.h
+++ b/geobase/FairGeoRootBuilder.h
@@ -1,9 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOROOTBUILDER_H
 #define FAIRGEOROOTBUILDER_H
 
-#include "FairGeoBuilder.h"
+#include "FairGeoBuilder.h"             // for FairGeoBuilder
 
+#include "Rtypes.h"                     // for FairGeoRootBuilder::Class, etc
 
+class FairGeoMedium;
+class FairGeoNode;
 class TGeoManager;
 
 /**
diff --git a/geobase/FairGeoRotation.cxx b/geobase/FairGeoRotation.cxx
index 0c6f004..defd220 100644
--- a/geobase/FairGeoRotation.cxx
+++ b/geobase/FairGeoRotation.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 16/06/99
 
@@ -65,9 +72,11 @@
 //   2. angle:  rotation around y1-axis  --> x2, y2=y1, z2
 //   3. angle:  rotation around z2-axis  --> x3, y3, z3=z2
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoRotation.h"
 
+#include "TMath.h"                      // for Cos, Sin
+#include "TRotMatrix.h"                 // for TRotMatrix
+
 ClassImp(FairGeoRotation)
 
 
diff --git a/geobase/FairGeoRotation.h b/geobase/FairGeoRotation.h
index b3db752..581ed6c 100644
--- a/geobase/FairGeoRotation.h
+++ b/geobase/FairGeoRotation.h
@@ -1,14 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOROTATION_H
 #define FAIRGEOROTATION_H
 
-#include "TObject.h"
+#include "TObject.h"                    // for TObject
 
-#include "FairGeoVector.h"
+#include "FairGeoVector.h"              // for FairGeoVector
 
-#include "TRotMatrix.h"
+#include "Riosfwd.h"                    // for ostream
+#include "Rtypes.h"                     // for Double_t, Int_t, Bool_t, etc
 
-#include <iostream>
+#include <iostream>                     // for operator<<, cout, ostream, etc
 
+class TRotMatrix;
 
 /**
  * rotation matrix
diff --git a/geobase/FairGeoSet.cxx b/geobase/FairGeoSet.cxx
index 2758a4b..ce681d7 100644
--- a/geobase/FairGeoSet.cxx
+++ b/geobase/FairGeoSet.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -7,27 +14,28 @@
 // Base class for geometry of detector parts
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoSet.h"
 
-#include "FairGeoNode.h"
-#include "FairGeoShapes.h"
-#include "FairGeoBasicShape.h"
-#include "FairGeoMedium.h"
-#include "FairGeoBuilder.h"
-#include "FairGeoMedia.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+#include "FairGeoBuilder.h"             // for FairGeoBuilder
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoNode.h"                // for FairGeoNode, etc
+#include "FairGeoShapes.h"              // for FairGeoShapes
+#include "FairGeoTransform.h"           // for FairGeoTransform
+
+#include "TArrayI.h"                    // for TArrayI
+#include "TString.h"                    // for TString, operator<<
+
+#include <ctype.h>                      // for isalpha
+#include <string.h>                     // for NULL, strcmp
+#include <iostream>                     // for cout
 
-#include "TString.h"
-#include "TArrayI.h"
+class FairGeoMedium;
 
-//#include "ctype.h"
 using std::cout;
 using std::endl;
 using std::ios;
 
-
-class FairGeoTransform;
-
 ClassImp(FairGeoSet)
 
 FairGeoSet::FairGeoSet()
@@ -94,7 +102,7 @@ Int_t FairGeoSet::getModule(Int_t s,Int_t m)
   return 0;
 }
 
-Bool_t FairGeoSet::read(fstream& fin,FairGeoMedia* media)
+Bool_t FairGeoSet::read(std::fstream& fin,FairGeoMedia* media)
 {
   // Reads the geometry from file
   Int_t s1=-1,s2=0;
@@ -121,21 +129,21 @@ Bool_t FairGeoSet::read(fstream& fin,FairGeoMedia* media)
   return rc;
 }
 
-void FairGeoSet::readInout(fstream& fin)
+void FairGeoSet::readInout(std::fstream& fin)
 {
   // Reads the inout flag (in old files)
   char c=' ';
   do {
-    c=fin.get();
+    fin.get(c);
   } while (c==' ' || c=='\n');
   if (c!='0'&&c!='1') { fin.putback(c); }
   else do {
-      c=fin.get();
+      fin.get(c);
     } while (c!='\n');
   return;
 }
 
-void FairGeoSet::readTransform(fstream& fin,FairGeoTransform& tf)
+void FairGeoSet::readTransform(std::fstream& fin,FairGeoTransform& tf)
 {
   // Reads the transformation from file
   Double_t r[9], t[3];
@@ -145,7 +153,7 @@ void FairGeoSet::readTransform(fstream& fin,FairGeoTransform& tf)
   tf.setTransVector(t);
 }
 
-Bool_t FairGeoSet::readVolumeParams(fstream& fin,FairGeoMedia* media,
+Bool_t FairGeoSet::readVolumeParams(std::fstream& fin,FairGeoMedia* media,
                                     FairGeoNode* volu,TList* refVolumes)
 {
   // Reads the volume definition from file
@@ -178,16 +186,16 @@ Bool_t FairGeoSet::readVolumeParams(fstream& fin,FairGeoMedia* media,
     //  cout << " read copies in Hades format " << endl;
 
     if (nameLength>4) {
-      char c;
+      char c=' ';
       do {
-        c=fin.get();
+        fin.get(c);
       } while (c==' ' || c=='\n');
-      Int_t i=(Int_t)c ;
+      Int_t i=static_cast<Int_t>(c);
       fin.putback(c);
 
       if (!isalpha(i)) { isCopy=kTRUE; }
       refName=name(0,4);
-      refNode=(FairGeoCopyNode*)refVolumes->FindObject(refName);
+      refNode=static_cast<FairGeoCopyNode*>(refVolumes->FindObject(refName));
       if (!refNode) {
         if (isCopy) { return kFALSE; }
         refVolumes->Add(new FairGeoCopyNode(refName.Data(),volu));
@@ -208,13 +216,13 @@ Bool_t FairGeoSet::readVolumeParams(fstream& fin,FairGeoMedia* media,
     if (l>0) {
       char c;
       do {
-        c=fin.get();
+        fin.get(c);
       } while (c==' ' || c=='\n');
-      Int_t i=(Int_t)c;
+      Int_t i=static_cast<Int_t>(c);
       fin.putback(c);
       if (!isalpha(i)) { isCopy=kTRUE; }
       refName=name(0,l);
-      refNode=(FairGeoCopyNode*)refVolumes->FindObject(refName);
+      refNode=static_cast<FairGeoCopyNode*>(refVolumes->FindObject(refName));
       if (!refNode) {
         if (isCopy) { return kFALSE; }
         refVolumes->Add(new FairGeoCopyNode(refName.Data(),volu));
@@ -252,7 +260,7 @@ Bool_t FairGeoSet::readVolumeParams(fstream& fin,FairGeoMedia* media,
   return kTRUE;
 }
 
-Bool_t FairGeoSet::readKeepIn(fstream& fin,FairGeoMedia* media,TString& name)
+Bool_t FairGeoSet::readKeepIn(std::fstream& fin,FairGeoMedia* media,TString& name)
 {
   // Reads the keepin volume from file
   fin.clear();
@@ -288,7 +296,7 @@ Bool_t FairGeoSet::readKeepIn(fstream& fin,FairGeoMedia* media,TString& name)
   return rc;
 }
 
-Bool_t FairGeoSet::readModule(fstream& fin,FairGeoMedia* media,TString& modName,
+Bool_t FairGeoSet::readModule(std::fstream& fin,FairGeoMedia* media,TString& modName,
                               TString& eleName,Bool_t containsActiveMod)
 {
   // Reads the whole geometry of a module from file
@@ -352,27 +360,29 @@ void FairGeoSet::print()
   if (!description.IsNull()) {
     cout<<"//----------------------------------------------------------\n";
   }
-  cout.setf(ios::fixed,ios::floatfield);
+  std::ios_base::fmtflags tmp = cout.setf(ios::fixed,ios::floatfield);
   TListIter iter(volumes);
   FairGeoNode* volu;
-  while((volu=(FairGeoNode*)iter.Next())) {
+  while((volu=static_cast<FairGeoNode*>(iter.Next()))) {
     volu->print();
   }
+  cout.setf(tmp);
 }
 
-void FairGeoSet::write(fstream& fout)
+void FairGeoSet::write(std::fstream& fout)
 {
   // Writes the volumes to file
   if (!author.IsNull()) { fout<<"//Author:      "<<author<<'\n'; }
   if (!description.IsNull()) { fout<<"//Description: "<<description<<'\n'; }
   fout<<"//----------------------------------------------------------\n";
-  fout.setf(ios::fixed,ios::floatfield);
+  std::ios_base::fmtflags tmp = fout.setf(ios::fixed,ios::floatfield);
   TListIter iter(volumes);
   FairGeoNode* volu;
   Bool_t rc=kTRUE;
-  while((volu=(FairGeoNode*)iter.Next())&&rc) {
+  while((volu=static_cast<FairGeoNode*>(iter.Next()))&&rc) {
     rc=volu->write(fout);
   }
+  fout.setf(tmp);
 }
 
 Bool_t FairGeoSet::create(FairGeoBuilder* builder)
@@ -382,7 +392,7 @@ Bool_t FairGeoSet::create(FairGeoBuilder* builder)
   TListIter iter(volumes);
   FairGeoNode* volu;
   Bool_t rc=kTRUE;
-  while((volu=(FairGeoNode*)iter.Next())&&rc) {
+  while((volu=static_cast<FairGeoNode*>(iter.Next()))&&rc) {
     if (volu->isActive()) {
 
       if (hadesGeo == 1) { rc=builder->createNode(volu, hadesGeo); }
@@ -413,7 +423,7 @@ void FairGeoSet::compare(FairGeoSet& rset)
   Int_t n=0, nnf=0, nDiff=0;
   cout<<"name\t mother medium shape  points    pos    rot\n";
   cout<<"------------------------------------------------\n";
-  while((volu=(FairGeoNode*)iter.Next())) {
+  while((volu=static_cast<FairGeoNode*>(iter.Next()))) {
     n++;
     FairGeoNode* rNode=rset.getVolume(volu->GetName());
     if (!rNode) { nnf++; }
@@ -426,7 +436,7 @@ void FairGeoSet::compare(FairGeoSet& rset)
   if (rlist->GetSize()!=(n-nnf)) {
     nnf=0;
     TListIter riter(rlist);
-    while((volu=(FairGeoNode*)riter.Next())) {
+    while((volu=static_cast<FairGeoNode*>(riter.Next()))) {
       FairGeoNode* rNode=getVolume(volu->GetName());
       if (!rNode) { nnf++; }
     }
diff --git a/geobase/FairGeoSet.h b/geobase/FairGeoSet.h
index 1260193..4882ac4 100644
--- a/geobase/FairGeoSet.h
+++ b/geobase/FairGeoSet.h
@@ -1,22 +1,30 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOSET_H
 #define FAIRGEOSET_H
 
+#include "TNamed.h"                     // for TNamed
 
-#include "FairGeoTransform.h"
+#include "FairGeoNode.h"
 
-#include "TNamed.h"
-//#include "TArrayI.h"
-#include "TList.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
 
-#include <fstream>
-//#include <iomanip>
+#include <fstream>                      // for fstream
 
-class FairGeoNode;
+//class FairGeoNode;
 class FairGeoShapes;
 class FairGeoMedia;
 class FairGeoBuilder;
+class FairGeoTransform;
 class TArrayI;
-//class TList;
 
 /**
  * Base class for geometry of detector parts
@@ -55,11 +63,11 @@ class  FairGeoSet : public TNamed
     TString description;    /** description of the version*/
 
     FairGeoSet();
-    void readInout(fstream&);
-    void readTransform(fstream&,FairGeoTransform&);
-    Bool_t readVolumeParams(fstream&,FairGeoMedia*,FairGeoNode*,TList* l=0);
-    Bool_t readKeepIn(fstream&,FairGeoMedia*,TString&);
-    Bool_t readModule(fstream&,FairGeoMedia*,TString&,TString&,Bool_t a=kFALSE);
+    void readInout(std::fstream&);
+    void readTransform(std::fstream&,FairGeoTransform&);
+    Bool_t readVolumeParams(std::fstream&,FairGeoMedia*,FairGeoNode*,TList* l=0);
+    Bool_t readKeepIn(std::fstream&,FairGeoMedia*,TString&);
+    Bool_t readModule(std::fstream&,FairGeoMedia*,TString&,TString&,Bool_t a=kFALSE);
   public :
     virtual ~FairGeoSet();
     void setShapes(FairGeoShapes* s) {pShapes=s;}
@@ -72,8 +80,8 @@ class  FairGeoSet : public TNamed
     void setModules(Int_t,Int_t*);
     Int_t* getModules(void);
     Int_t getModule(Int_t,Int_t);
-    FairGeoNode* getVolume(const char* name) {return (FairGeoNode*)volumes->FindObject(name);}
-    FairGeoNode* getMasterNode(const char* name) {return (FairGeoNode*)masterNodes->FindObject(name);}
+    FairGeoNode* getVolume(const char* name) {return dynamic_cast<FairGeoNode*>(volumes->FindObject(name));}
+    FairGeoNode* getMasterNode(const char* name) {return dynamic_cast<FairGeoNode*>(masterNodes->FindObject(name));}
     TList* getListOfVolumes() {return volumes;}
     FairGeoShapes* getShapes() {return pShapes;}
     void setAuthor(TString& s) {author=s;}
@@ -85,9 +93,9 @@ class  FairGeoSet : public TNamed
     virtual const char* getEleName(Int_t) {return 0;}
     virtual Int_t getSecNumInMod(const TString&) {return -1;}
     virtual Int_t getModNumInMod(const TString&) {return 0;}
-    virtual Bool_t read(fstream&,FairGeoMedia*);
+    virtual Bool_t read(std::fstream&,FairGeoMedia*);
     virtual void addRefNodes() {}
-    virtual void write(fstream&);
+    virtual void write(std::fstream&);
     virtual void print();
     virtual Bool_t create(FairGeoBuilder*);
     void compare(FairGeoSet&);
diff --git a/geobase/FairGeoShapes.cxx b/geobase/FairGeoShapes.cxx
index c401b6f..3df60d3 100644
--- a/geobase/FairGeoShapes.cxx
+++ b/geobase/FairGeoShapes.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 22/06/2003 by Ilse Koenig
 
@@ -85,7 +92,7 @@ FairGeoBasicShape* FairGeoShapes::selectShape(const TString& name)
                          };
   TString sName(name);
   if (sName.Length()==3) { sName+=" "; }
-  FairGeoBasicShape* s=(FairGeoBasicShape*)shapes->FindObject(sName);
+  FairGeoBasicShape* s=static_cast<FairGeoBasicShape*>(shapes->FindObject(sName));
   if (s) { return s; }
   Int_t no=-1;
   for(Int_t i=0; i<13; i++) {if (sName.CompareTo(allShapes[i])==0) { no=i; }}
@@ -125,7 +132,7 @@ FairGeoBasicShape* FairGeoShapes::selectShape(const TString& name)
 }
 
 
-Int_t FairGeoShapes::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoShapes::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the points of the given volume from the Ascii file
   // returns the number of points read
@@ -136,7 +143,7 @@ Int_t FairGeoShapes::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoShapes::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoShapes::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the points of the given volume to the Ascii file
   // return kFALSE if the corresponding shape class is not implemented
diff --git a/geobase/FairGeoShapes.h b/geobase/FairGeoShapes.h
index 31b7b03..e29741a 100644
--- a/geobase/FairGeoShapes.h
+++ b/geobase/FairGeoShapes.h
@@ -1,14 +1,20 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOSHAPES_H
 #define FAIRGEOSHAPES_H
 
+#include "TObject.h"                    // for TObject
 
-//#include "FairGeoTransform.h"
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoShapes::Class, etc
+#include "TString.h"                    // for TString
 
-#include "TObject.h"
-#include "TString.h"
-//#include "TList.h"
-
-#include <fstream>
+#include <fstream>                      // for fstream
 
 class FairGeoVolume;
 class FairGeoBasicShape;
@@ -29,8 +35,8 @@ class  FairGeoShapes : public TObject
     ~FairGeoShapes();
     FairGeoBasicShape* selectShape(FairGeoVolume*);
     FairGeoBasicShape* selectShape(const TString&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoShapes,0) //
 };
diff --git a/geobase/FairGeoSphe.cxx b/geobase/FairGeoSphe.cxx
index eb5bb24..c3437de 100644
--- a/geobase/FairGeoSphe.cxx
+++ b/geobase/FairGeoSphe.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 29/06/99 by Ilse Koenig
@@ -20,13 +27,18 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoSphe.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for basic_ostream::write
 
 ClassImp(FairGeoSphe)
 
@@ -59,7 +71,7 @@ FairGeoSphe::~FairGeoSphe()
 }
 
 
-Int_t FairGeoSphe::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoSphe::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 3 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -79,17 +91,20 @@ Int_t FairGeoSphe::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoSphe::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoSphe::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 3 'points' decribed above to ascii file
-  if (!pFile) { return kFALSE; }
-  Text_t buf[155];
-  for(Int_t i=0; i<nPoints; i++) {
-    FairGeoVector& v=*(volu->getPoint(i));
-    sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
-    pFile->write(buf,strlen(buf));
+  if (!pFile) {
+    return kFALSE;
+  } else {
+    Text_t buf[155];
+    for(Int_t i=0; i<nPoints; i++) {
+      FairGeoVector& v=*(volu->getPoint(i));
+      sprintf(buf,"%9.3f%10.3f\n",v(0),v(1));
+      pFile->write(buf,strlen(buf));
+    }
+    return kTRUE;
   }
-  return kTRUE;
 }
 
 
diff --git a/geobase/FairGeoSphe.h b/geobase/FairGeoSphe.h
index e9ad107..7ebb1a8 100644
--- a/geobase/FairGeoSphe.h
+++ b/geobase/FairGeoSphe.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOSPHE_H
 #define FAIRGEOSPHE_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 /**
  * class for geometry shape SPHE
@@ -18,8 +31,8 @@ class FairGeoSphe : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoSphe,0) //
 };
diff --git a/geobase/FairGeoTorus.cxx b/geobase/FairGeoTorus.cxx
index ab8cbad..0205f4c 100644
--- a/geobase/FairGeoTorus.cxx
+++ b/geobase/FairGeoTorus.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : M. Al-Turany  06/11/2006
 
 /////////////////////////////////////////////////////////////
@@ -12,13 +19,18 @@
 //            Phi1 - starting phi
 //            Dphi - phi extent
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoTorus.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for basic_ostream::write
 
 ClassImp(FairGeoTorus)
 
@@ -50,7 +62,7 @@ FairGeoTorus::~FairGeoTorus()
   }
 }
 
-Int_t FairGeoTorus::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoTorus::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads nPoints with 3 components from Ascii file
   // if the array of points is not existing in the volume it is created and
@@ -89,7 +101,7 @@ TArrayD* FairGeoTorus::calcVoluParam(FairGeoVolume* volu)
   return param;
 }
 
-Bool_t FairGeoTorus::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoTorus::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 4 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
@@ -114,7 +126,7 @@ void FairGeoTorus::printPoints(FairGeoVolume* volu)
 
 
 
-void FairGeoTorus::calcVoluPosition(FairGeoVolume* volu,
+void FairGeoTorus::calcVoluPosition(FairGeoVolume*,
                                     const FairGeoTransform& dTC,const FairGeoTransform& mTR)
 {
   // calls the function posInMother(...) to calculate the position of the
diff --git a/geobase/FairGeoTorus.h b/geobase/FairGeoTorus.h
index f5d1d71..5342782 100644
--- a/geobase/FairGeoTorus.h
+++ b/geobase/FairGeoTorus.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTORUS_H
 #define FAIRGEOTORUS_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoTorus : public FairGeoBasicShape
 {
@@ -14,8 +27,8 @@ class FairGeoTorus : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream* pFile,FairGeoVolume* volu);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream* pFile,FairGeoVolume* volu);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
 
     ClassDef(FairGeoTorus,0) // class for geometry shape TORUS
diff --git a/geobase/FairGeoTransform.cxx b/geobase/FairGeoTransform.cxx
index 1f6906f..a5b3927 100644
--- a/geobase/FairGeoTransform.cxx
+++ b/geobase/FairGeoTransform.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 16/06/1999
 //*-- Modified : 21/06/2005 D.Bertini
diff --git a/geobase/FairGeoTransform.h b/geobase/FairGeoTransform.h
index 51ffb1e..de4237a 100644
--- a/geobase/FairGeoTransform.h
+++ b/geobase/FairGeoTransform.h
@@ -1,8 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTRANSFORM_H
 #define FAIRGEOTRANSFORM_H
 
-#include "FairGeoVector.h"
-#include "FairGeoRotation.h"
+#include "TObject.h"                    // for TObject
+
+#include "FairGeoRotation.h"            // for FairGeoRotation
+#include "FairGeoVector.h"              // for FairGeoVector
+
+#include "Rtypes.h"                     // for Double_t, etc
 
 /**
  * basic geometry transformation class
@@ -46,7 +57,8 @@ class FairGeoTransform : public TObject
 };
 
 inline FairGeoTransform::FairGeoTransform(const FairGeoTransform& t)
-  : rot(t.getRotMatrix()),
+  : TObject(t),
+    rot(t.getRotMatrix()),
     trans(t.getTransVector()),
     trans_cm(FairGeoVector(0,0,0))
 {
diff --git a/geobase/FairGeoTrap.cxx b/geobase/FairGeoTrap.cxx
index 21c580e..2967bc6 100644
--- a/geobase/FairGeoTrap.cxx
+++ b/geobase/FairGeoTrap.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 16/05/99 by Ilse Koenig
@@ -21,15 +28,19 @@
 // created in the function calcVoluPosition(...)
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoTrap.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
 
-#include "TArrayD.h"
+#include "Riosfwd.h"                    // for ostream
+#include "TArrayD.h"                    // for TArrayD
+#include "TMath.h"                      // for ATan, Pi, Sqrt, atan
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include <iostream>
+#include <iostream>                     // for operator<<, cout, etc
 
 using std::cout;
 
diff --git a/geobase/FairGeoTrap.h b/geobase/FairGeoTrap.h
index fe83356..6e631fa 100644
--- a/geobase/FairGeoTrap.h
+++ b/geobase/FairGeoTrap.h
@@ -1,11 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTRAP_H
 #define FAIRGEOTRAP_H
 
-#include "FairGeoBasicShape.h"
-#include "FairGeoRotation.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "FairGeoRotation.h"            // for FairGeoRotation
+
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoTrap : public FairGeoBasicShape
 {
diff --git a/geobase/FairGeoTrd1.cxx b/geobase/FairGeoTrd1.cxx
index 0f5a531..c50da4b 100644
--- a/geobase/FairGeoTrd1.cxx
+++ b/geobase/FairGeoTrd1.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 16/05/99 by Ilse Koenig
@@ -21,13 +28,15 @@
 // created in the function calcVoluPosition(...)
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoTrd1.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
 
-#include "TArrayD.h"
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
 ClassImp(FairGeoTrd1)
 
diff --git a/geobase/FairGeoTrd1.h b/geobase/FairGeoTrd1.h
index d2aacc6..ac6d809 100644
--- a/geobase/FairGeoTrd1.h
+++ b/geobase/FairGeoTrd1.h
@@ -1,11 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTRD1_H
 #define FAIRGEOTRD1_H
 
-#include "FairGeoBasicShape.h"
-#include "FairGeoRotation.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "FairGeoRotation.h"            // for FairGeoRotation
+
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoTrd1 : public FairGeoBasicShape
 {
diff --git a/geobase/FairGeoTube.cxx b/geobase/FairGeoTube.cxx
index 1c6ef5f..cb1db00 100644
--- a/geobase/FairGeoTube.cxx
+++ b/geobase/FairGeoTube.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 28/06/99 by Ilse Koenig
@@ -21,13 +28,19 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoTube.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for basic_ostream::write
 
 ClassImp(FairGeoTube)
 
@@ -60,7 +73,7 @@ FairGeoTube::~FairGeoTube()
 }
 
 
-Int_t FairGeoTube::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoTube::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 3 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -85,7 +98,7 @@ Int_t FairGeoTube::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoTube::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoTube::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 3 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoTube.h b/geobase/FairGeoTube.h
index 9c3ed62..079ac17 100644
--- a/geobase/FairGeoTube.h
+++ b/geobase/FairGeoTube.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTUBE_H
 #define FAIRGEOTUBE_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoTube : public FairGeoBasicShape
 {
@@ -14,8 +27,8 @@ class FairGeoTube : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoTube,0) // class for geometry shape TUBE
 };
diff --git a/geobase/FairGeoTubs.cxx b/geobase/FairGeoTubs.cxx
index 577e68b..53493da 100644
--- a/geobase/FairGeoTubs.cxx
+++ b/geobase/FairGeoTubs.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 11/11/2003 by Ilse Koenig
 //*-- Modified : 28/06/99 by Ilse Koenig
@@ -24,13 +31,19 @@
 // not rotated, is identical with the laboratory system.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairGeoTubs.h"
 
-#include "FairGeoVolume.h"
-#include "FairGeoVector.h"
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "TArrayD.h"                    // for TArrayD
+#include "TMathBase.h"                  // for Abs
+#include "TString.h"                    // for TString
 
-#include "TArrayD.h"
+#include <stdio.h>                      // for printf, sprintf, sscanf
+#include <string.h>                     // for strlen
+#include <ostream>                      // for basic_ostream::write
 
 ClassImp(FairGeoTubs)
 
@@ -63,7 +76,7 @@ FairGeoTubs::~FairGeoTubs()
 }
 
 
-Int_t FairGeoTubs::readPoints(fstream* pFile,FairGeoVolume* volu)
+Int_t FairGeoTubs::readPoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // reads the 4 'points' decribed above from ascii file
   // if the array of points is not existing in the volume it is created and
@@ -87,7 +100,7 @@ Int_t FairGeoTubs::readPoints(fstream* pFile,FairGeoVolume* volu)
 }
 
 
-Bool_t FairGeoTubs::writePoints(fstream* pFile,FairGeoVolume* volu)
+Bool_t FairGeoTubs::writePoints(std::fstream* pFile,FairGeoVolume* volu)
 {
   // writes the 4 'points' decribed above to ascii file
   if (!pFile) { return kFALSE; }
diff --git a/geobase/FairGeoTubs.h b/geobase/FairGeoTubs.h
index a16ba70..8fb3826 100644
--- a/geobase/FairGeoTubs.h
+++ b/geobase/FairGeoTubs.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOTUBS_H
 #define FAIRGEOTUBS_H
 
-#include "FairGeoBasicShape.h"
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoPcon::Class, Bool_t, etc
+
+#include <iosfwd>                       // for fstream
 
 class FairGeoTransform;
 class FairGeoVolume;
+class TArrayD;
 
 class FairGeoTubs : public FairGeoBasicShape
 {
@@ -14,8 +27,8 @@ class FairGeoTubs : public FairGeoBasicShape
     TArrayD* calcVoluParam(FairGeoVolume*);
     void calcVoluPosition(FairGeoVolume*,
                           const FairGeoTransform&,const FairGeoTransform&);
-    Int_t readPoints(fstream*,FairGeoVolume*);
-    Bool_t writePoints(fstream*,FairGeoVolume*);
+    Int_t readPoints(std::fstream*,FairGeoVolume*);
+    Bool_t writePoints(std::fstream*,FairGeoVolume*);
     void printPoints(FairGeoVolume* volu);
     ClassDef(FairGeoTubs,0) // class for geometry shape TUBS
 };
diff --git a/geobase/FairGeoVector.cxx b/geobase/FairGeoVector.cxx
index cca6dcf..ec0c6f8 100644
--- a/geobase/FairGeoVector.cxx
+++ b/geobase/FairGeoVector.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 16/06/99
 
diff --git a/geobase/FairGeoVector.h b/geobase/FairGeoVector.h
index e558049..d0461a7 100644
--- a/geobase/FairGeoVector.h
+++ b/geobase/FairGeoVector.h
@@ -1,11 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOVECTOR_H
 #define FAIRGEOVECTOR_H
 
-#include "TObject.h"
-#include "TMath.h"
+#include "TObject.h"                    // for TObject
 
-#include <iostream>
+#include "Riosfwd.h"                    // for ostream, istream
+#include "Rtypes.h"                     // for Double_t, Bool_t, Int_t, etc
+#include "TMath.h"                      // for pow, floor, sqrt
+#include "TMathBase.h"                  // for Abs
 
+#include <stdio.h>                      // for printf
+#include <iostream>                     // for operator<<, ostream, etc
 
 class FairGeoVector : public TObject
 {
@@ -71,8 +82,8 @@ class FairGeoVector : public TObject
     void clear() {x=y=z=0.;}
     void print() const {printf("%10.3f%10.3f%10.3f\n",x,y,z);}
     inline void round(Int_t n);
-    inline friend ostream& operator << (ostream& put,const FairGeoVector& v);
-    inline friend istream& operator >> (istream& get,FairGeoVector& v);
+    inline friend std::ostream& operator << (std::ostream& put,const FairGeoVector& v);
+    inline friend std::istream& operator >> (std::istream& get,FairGeoVector& v);
     ClassDef(FairGeoVector,1) // vector with 3 components
 };
 
@@ -246,12 +257,12 @@ inline void FairGeoVector::round(Int_t n)
   round(z,n);
 }
 
-inline ostream& operator << (ostream& put,const FairGeoVector& v)
+inline std::ostream& operator << (std::ostream& put,const FairGeoVector& v)
 {
   return put<<v(0)<<"  "<<v(1)<<"  "<<v(2)<<'\n';
 }
 
-inline istream& operator >> (istream& get,FairGeoVector& v)
+inline std::istream& operator >> (std::istream& get,FairGeoVector& v)
 {
   Double_t x[3];
   get>>x[0]>>x[1]>>x[2];
diff --git a/geobase/FairGeoVolume.cxx b/geobase/FairGeoVolume.cxx
index df08a64..222240d 100644
--- a/geobase/FairGeoVolume.cxx
+++ b/geobase/FairGeoVolume.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Modified : 27/05/99
 
@@ -21,7 +28,9 @@
 /////////////////////////////////////////////////////////////
 #include "FairGeoVolume.h"
 
-#include <iostream>
+#include "Riosfwd.h"                    // for ostream
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using std::cout;
 using std::endl;
@@ -84,7 +93,7 @@ void FairGeoVolume::setPoint(const Int_t n,const Double_t x,
 {
   // set the 3 values of the point with index n
   if (points && n<nPoints) {
-    FairGeoVector* v=(FairGeoVector*)points->At(n);
+    FairGeoVector* v=static_cast<FairGeoVector*>(points->At(n));
     v->setX(x);
     v->setY(y);
     v->setZ(z);
@@ -95,7 +104,7 @@ void FairGeoVolume::setPoint(const Int_t n,const FairGeoVector& p)
 {
   // sets point with index n by copying the 3 components of point p
   if (points && n<nPoints) {
-    FairGeoVector& v=*((FairGeoVector*)points->At(n));
+    FairGeoVector& v=*(static_cast<FairGeoVector*>(points->At(n)));
     v=p;
   }
 }
@@ -116,12 +125,12 @@ void FairGeoVolume::clear()
 void FairGeoVolume::print()
 {
   // prints all parameters of a volume
-  cout<<"Volume: " <<((const char*)fName)<<"  Shape: "<<((const char*)shape)<<"  Mother: "
-      <<((const char*)mother)<<'\n';
+  cout<<"Volume: " <<(const_cast<const char*>(fName.Data()))<<"  Shape: "<<(const_cast<const char*>(shape.Data()))<<"  Mother: "
+      <<(const_cast<const char*>(mother.Data()))<<'\n';
   cout << "Points definition " << endl;
   if (points) {
     for (Int_t i=0; i<nPoints; i++) {
-      cout<<(*((FairGeoVector*)points->At(i)));
+      cout<<(*(static_cast<FairGeoVector*>(points->At(i))));
     }
   }
   cout << "Lab Transform " << endl;
@@ -131,7 +140,7 @@ void FairGeoVolume::print()
 
 Double_t FairGeoVolume::getVolParameter( Int_t nPoint, Int_t pos )
 {
-  FairGeoVector* vec = (FairGeoVector*) points->At( nPoint );
+  FairGeoVector* vec = static_cast<FairGeoVector*>( points->At( nPoint ));
   if ( vec ) { return vec->getValues( pos ); }
   else { return -1; }
 }
diff --git a/geobase/FairGeoVolume.h b/geobase/FairGeoVolume.h
index f8ae6bb..0f4985e 100644
--- a/geobase/FairGeoVolume.h
+++ b/geobase/FairGeoVolume.h
@@ -1,12 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEOVOLUME_H
 #define FAIRGEOVOLUME_H
 
-#include "FairGeoTransform.h"
-#include "FairGeoMedium.h"
-#include "TNamed.h"
-#include "TObjArray.h"
+#include "TNamed.h"                     // for TNamed
 
-class FairGeoVector;
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairGeoTransform.h"           // for FairGeoTransform
+#include "FairGeoVector.h"              // for FairGeoVector
+
+#include "Rtypes.h"                     // for Int_t, Text_t, Double_t, etc
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+
+#include <stddef.h>                     // for NULL
 
 /**
  * basic geometry parameters of a volume
@@ -75,7 +87,7 @@ inline FairGeoVolume::FairGeoVolume()
 
 inline FairGeoVector* FairGeoVolume::getPoint(const Int_t n)
 {
-  if (points && n<nPoints) { return (FairGeoVector*)points->At(n); }
+  if (points && n<nPoints) { return static_cast<FairGeoVector*>(points->At(n)); }
   else { return 0; }
 }
 
diff --git a/geobase/GeoBaseLinkDef.h b/geobase/GeoBaseLinkDef.h
index 8b71d2d..fe19b17 100644
--- a/geobase/GeoBaseLinkDef.h
+++ b/geobase/GeoBaseLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifdef __CINT__
 
 #pragma link off all globals;
diff --git a/geobase/README.md b/geobase/README.md
new file mode 100644
index 0000000..013a8e6
--- /dev/null
+++ b/geobase/README.md
@@ -0,0 +1,9 @@
+geobase
+========
+
+The base classes for the geometry description, including:
+
+- different geometry shapes;
+- assemblies of shapes;
+- geometry transformations;
+- geometry building from ASCII or from ROOT.
\ No newline at end of file
diff --git a/geometry/emc_tr_400_3_empty.geo b/geometry/emc_tr_400_3_empty.geo
new file mode 100644
index 0000000..495a1ca
--- /dev/null
+++ b/geometry/emc_tr_400_3_empty.geo
@@ -0,0 +1,10 @@
+//*************************************************
+emc1EmptyChamber1#1
+cave
+TUBE
+vacuum
+0.0000000000 0.0000000000 -2760.0000000000
+1748.8000000000 2155.8000000000
+0.0000000000 0.0000000000 2760.0000000000
+0.000000 0.000000 0.000000
+1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000 0.0000000000 0.0000000000 0.0000000000 1.0000000000
\ No newline at end of file
diff --git a/input/cbmlogo.gif b/input/cbmlogo.gif
deleted file mode 100644
index ef7d171455ddb0c05539780ffc443af30af9f687..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001

literal 5365
zcmeHJ={wX5!2NBr*k>4H35|W%*vgg$#bmo<4Jl&@iJIhwP-85)ts^B=8v7_RcHNdc
z6S9<=BwOl^PzZNgxl!}p_pf-ryyxTja-Qcr=RD_l>~^=ak30vQ1y%uID#DLjSJ(F8
zvqeE`XIEGAyJerE&dyiwB@)SvYVMhPBL`~x*7w`iUA^4X)4TrGvaWw*?%ThWZC#SJ
zr?hK=8`rO^WZr5Ve|MK&cUdq|b6@c51GWF-m*!hJOC!{}=P?H_)Q45{ytwsbr72}Y
z*gm=NN$`51^HuiP#8}@*`;WUtNw=SLoo3b#O-sIVKfUP_uWvLCzu|Td{9L*4yp1>c
zX;rd(WFzCZzu%3{yh_b4t>QE^iTeCs^`@L^6E5@1hG$nso?e^0d*R{3zXl8L{VY$N
zUle_=@t;}w`tQ$QsZE31FWnz_GBlO-d(-st6XEE<-%HQ#(uRkHX_Z}r<)ytHi46@6
zZKG4m-+wed8(kQExAE)O=o7(*i+N-3@9(dB{+2)9dn~qfW~FUb{NRH)_wM<9b!XdW
zmRHw*F8?F`w)Ue{w74o+ui$Y0rRx9t?KAJq{Km%5=H?dO+^4nglJ$*^U+a>a{ciyP
zc)s#&U9u5*{k~*FlGrrDYrc~AAoV}~|M7q5fZ6|Q|8ExntOWRk)u8e?f*h=pNq9f6
zqWd&XMyG_@T-ke8)jDCSzqzXKBFW8{VAN7QP-GNPsaM}p^W-YovE|%uYh5BqKe-rS
z)zm&OOgkyPi`|pUlBHU&ku5L3e_CtlRZ@}wop}M%BAtg875l+k0a^69$z;=s%lj3$
zLAPU;Ca$>r-H|)2lmAB5{BjRl=4z9tQfe5Mc)v0)q9|4&$EI-lLUf;utf_oyT5=z}
zyJ#hwt`;-*OkKf9)#rqD{KcEUMVy<?`5F&j4?5!A=zz|BEuA_4Hi_PwgiW0qL_2I$
zsvCLA8bxrb?|#`ncxB6g|8<?^XYquF@n;Y2t)iS410{ye<vMKC{L9-Bzk#0V$e801
zKV0R*pX=XLXtb8Otc_>-xfJjuq7L+Ah<o!$keZo`AP48(l?%!I8Vg0V&G2vX(eWkj
zdD0f~j}-NaL*4<++VR@)p0aeEKVTZ?F-vNg>L&%ya%TV{_CrL0jR{?FfoK#NecnTd
ziMnVnKT&kvw7fVQ6&OaDF7#vN_bLX;lXZ(JljG2p5&csA_`NhzX=x<!Dni7MurZjF
zJ1&Np^bs6L+|3;~C<__kgKAL(QBMVmKz6S<?cm2$jbYGW;!ovNgFx~Kg<Ey;%=AJX
zhgHT^V*5Hw)$B;ZgP15g^~Kw~d`SXVRbwaZU>tXp0IL1*c=2OXxq+uU!kLp+QcwRX
zz0?$q6)m-%Men6(#fQW;c-?yjF1Ivoz2{C;r;@VKmIc}X*H_kYqTM*Duup?Aj&_kf
zgvFV6o*m@CSW=+S9i_Yk2vk=MJeMPv$`KgDh-XtEU=N##R=Iv}NtLk#K&Y(D=F=L%
zh`0%jRCzrvO4bkeN1zx11OPlB835O0vU?w1@Z-xXs|ru=AyCN(m^{(|J`<dANgO=2
zHK<z^#}hr4+eW7J3Q3ZTFHKN9EnC^Efx*`##Pg9++dgJW1!{!f7H*5hxj_J#@<?V|
z%BNg7L?X!$JgA78at9D^{EQ-8z=V`Cy@dG))9d5+P?J*xL6zeYE`O6Qm(Q1Tr3&o8
z;6RdK@}@K(7(?thOf}B}CW!w{DBP(erw4e<3M__#<}@QMA8S~)MWU1scYXR-!9zoP
zCr&GkwrkU=?#bUbCCdsBX~VSUJfbRHoc_v;EBCR=$PKmOzFTa<lzpra=?H|;3(;Q`
z66xLOpu{(gGZU}hV(v46?eq#MSsEyH7+{)lEJ9-D1A<5E3Z2-CC%~N`x{ZdhrAML_
z7y=}g534!R0AQq?;7rf8<ACU(01~V@Z)!L@o$6CHFz1x#vV0IHixuVICCOr@S{EO!
z@1(uaqLQnT24F(Sj}#7boX}m`vdZfOLC5$#srTZL`|qX|rFh$A3n&Wv*Z5LS?7uK6
z{8JT|u6;Ve`RixB2&*fCl<CBLO{2kZC<NB908T^WUVg6<q)}U<T+E5jr5nFwgG5q}
zLN)!U%Y61`6WW82WsaNzPk<QkKrP0!R8_0%ChzeEnRroAQhc|(4S)gdvf<7j13IRx
zJpOWnT;5)m!Ve0FF?$B?ESjtAh;ND?XoR%JnKH4wY!dm-5h?B-P!E?+=8*vH^*x&o
zzeoOF_<YuU!d2DfRZEkaNQTCIq(We9t*jXejZ)Rq{@5<zt_Dqmz&8Lym$h%@CdCcj
z4pYM38kFv*%i}c$Ee!o(|KGjfBr>zCzXNWw{~C^CQ{YFq*3jUFP@LF}aEqQ-e8!Bf
z{IP80427jb=7X87ai|vZ>46)^j24#yMUOdKRLrNNryKY$tVZ+EdY3`7v~m7Z6h@8T
zA}7VB5PO6TcZb?)WwCGOXPK{L*xFZpUE(~CtKN>?rwx*XE@of{jCrIDUUcKgg0!}a
z$w2^0_+e$~fW^5m?ew5~E?-XabG5`A>CLurVW)?wcW!{;?}jNvS$lM!i+@uZ%-mid
z*KD3#csptwoc=zaZ=mXO#zW-tYt1m*UNR-F+i~zF?bvs-_;#gB@*Ee}H$s$wo>KBt
zR=231>!QOG<k(^7kZ>NjquPsQJE6b#?zbIF|MH{&P8sgIyF-q%Fn|SHNdH%aPeScK
zE35DPE<*}!<bKn;GH1ah7Xy#%DbjR4@L$?lx{T?>7~9BaD~o@BixSBtP<1zLqj~O_
z#C6(A-8u=UX0NFoJDx~^iSA^Up=@?T-ILG+n1s3h*;K}mS4~Lf=V+D4^WuJDiEL5n
zx^Fd#R*>UCXXMNEeJTvV3beM4Z?+YQu=exdne;wiwLprzA_Hgngvsi?(G_ds1j{;9
z=EL*)S*>@Q)K^5XSffCq`&u($U~)1NXI2rd%@-Ux54cKy;mCP-9X?gZ%Ozf>fHGYM
z3*IW`KazV8Ppm+i$j~q4re8AUUWC#b3eP+o3`K=>t3TZ}XW0;mafT;1JM$A3{8!I^
z@YzS4q<?UvxPTe_GLzrqEDhJb>QKZ2CXolhYa(5VA6%<~gU)vVjf8=JBAQ5Gp+3F1
zeRkj2Tl)_Ee$EqrF(va&mtzS2Y3Pv2qT)kduJO6i`#1mO9kmixL^d&@EARVHz2hZ<
zzsIAFbYL;L>QpJQ4DwUCPWF96ujzOwg+ON!s>O)T%0-Oc$6!(uJI^ef&khx4CsQb`
zr<VDdHzg(j#v+P^>x!pnleVHVnfZDn)9?58+lO^lqV-7Hh7`cn$%nGE+fCyrEC%b0
zTYS%<=+V;i-F>mK4kN+o5i44((e{;bBZM;*Mqrw*D(?v$q{zmxvyle2ePfwduzfie
z7tGd`6WpJ7rg+lBIK{WB|1qZW20`T5Y1vu#ZJy*GIrNxpDRZB0hnZ5c7lX-3w-K&u
z!tSAF7<-)gA*ueTE3Y{@`ne(*G<8khx6H^*k+`B{48A$NQ|J8qIFzSw$WNntwMm16
zjQR<Q5R7VX<B0RehK`p!NUOG9kk68i9(&laLNwyPjz)c%#G=9b^1d<6mnjnSnfN(C
zm4slJtdXKpp#8?y;1~)EO0&_cnsk2Ob!2D-{-SI&?yyF%%%sF-_NS&jNlkgSN8gJ9
z<XWLsXkc!%ogM`3WI~n4qAqqjzJ<VP9SbY*w!$yoX0?6`tEd2`cT78ch;m?EAFWN(
zcks_hy?UzZh3dv0Wr>Ftmc;DcmWJYHp78+5!+QIopxn>S4Ksih9c_i9tKz~tm4fIh
zcJm$RJF6$czU~etBcWSKFSSwq)t+h?vrm2c-{MYLmt@%XXZ*aHLv6|F@nBLTnJ#v@
zU$+4()6T|vl($9bC0l1&Uh=yB@#z*gbeF|3#ulBD?fx7vRw9C1bKoi^;LmOrE*GG3
zkbSKD&bs`2hN?;PS`K!ZmZY@YxU{=RnM0@T+%AFEih(!g_CYZSmWCk<QOA|SSOxo|
zn10QO?-m#UNhhe>{e}$a2;i&(AV%Y8n^{v7E|tau+Tv0>ubyg*%*n*4R<7lDZ##Xr
zFm1jWlfgOTT96_w)+SgojP%Z$#vt(=G+u~0Ohd|Hpz`$o*GTpa55Pab_Am{6A8;<F
z&2>K=gT>LY2oT5yq|xV1_uvh97>ndnJ!s9@0xcUm^*3t-=CrD)Anj*I8qC9hDoMWN
zEcRu1lL*|xMsFcQ9&D$9Zpas~dnxIQLdb|bZoi($KC6v|s39(5@E{FylyNp7z*Y|M
z_@Gp%jK_TWK<ez=>`<uWeDzAi=X{Nd#Gc2Q>Ja$uC|+5gm0|<0>lV54Q8s|J841*Q
ze9_7HsPlro-!3caJm$q$z@CYO(0AN)gY@`7B=2mK&Jh(q$dhu#>gth$-|_qH4-)9W
z0vC^`m^2$5u4)6fGd!zi?0hFKI0_y7nXnE31at$kY}<q)lrkS4-sxj6hOO$$On}P)
zSks3c_?;f$`9Bh`=4)AFGB<&+Q_3EmJxn4XnbtNnu>ERO0%MnsrwEwVg?5PTZJ5~}
z0e}>zw7Lh@m581CtI7Z#T)bu+e;gnG-xYQ#<x7>Sw-dBpI6I9%ngC6K4<oPkII^!r
zix^7DS*_8?2>@<87!^?K;79XNU_;(aPk9RJP0#M;_r~~Lv7z+DPYd`2(pF(DUW4uz
z^#Kzk1Z@J6YpqW%%`(IY62U=^2sg)bApP$L9Qi>vlu<8q5l4HQozVrp_19<%cq*U3
zJsPo>O(jhqbP5Et^Y)CnTgZ+vj^`7+=x9SalEOquoylel1g+cI1q;)6e`EjEa?QEf
zE1nh;8JEDI=dHyYK14aB*8&*x6O6@>79Y-Z3ohx)!YNs%94L8c6?<qg+Q5?WM)LV&
zl0K-Y3rg~!bcelAO;+R{Ae01O|B*fP$lSz`pfp$Q{@Cr#K-4j{!<C5ZNs^cP*xsR@
zeF<e;w`{aSYh>*%GW%9hSY2t8dsw6)T7`|miH=r3-WScUo~Yp(XeT{QwqW2Izg-H$
zh14cfJl1DGWx!*q&l(@?6iTaUW|g!#5Xg+%d_`*Tw=IS0a2!zo%hfuF5BrHQ=1l8a
zbp79B{tOhP$Yb$!VikKE3|wwC4_o2BWZ6`~4&o+D5}2lM=}3Z&>vz>XzF6)7IEqL`
z^{is*ojK{ik1^YCM?3vA!er1gCXkTf6Akq<w)YnSZytugA!<tisASdT1-C)lk?>$=
zoFcqC>;n*53s?#<Bxd<t^{ZbdVR<p4)QQn1D@Op(h}(e+wN&J61X0;eQ3wW+kjXEI
zkqFK^9*^cVHjmoM{kg-Q4Os@GKYm9M_}2EDj&#<vhga;?D85N3hW&xgQ)D2E0}#ll
z!I5B;2(!z^Re|HapN=rvAw@PT7~?W-%ZrJ;K8v|#LD|<Zx*aFd382{|v9E>ABIg`o
z-8L{h0h35Ul;?q6GaiMl<*LQX=-0NQyP!Q2PGF+J{D8CH&t=abQoyx|GW07Jx-|!~
z`{7Y;b$hY3-MBC!@gpbP0pF4XMRo-!NZO2Uy@Ivaum=ZvdKUGY5lXeB>IKwtB7?Y>
zT<MhS=Y-py)^oqv@!nY?Y&P!Z%}1quh4ukJZ|{u<`CgZ!A1u56WghJmqsP~!BU=E#
z2gu)5<Re+9HtHVLWroP|Xf@H!orKCVQ<W806WNX;E$>~oCJ_3Gist!rH!;%h7O+*{
zs{eqSLFS`OKRAkv5$m>j^O24P`#_H8FVlFO6S7S<SWbNNm~iV!OFw}d+FQTPjcm)3
z3c8(A;gka2>`CX=mu01ZxS)ub$X?BCv(Tk<AKqnIA)r@OUf+tg5@jV({LLuM9lfnb
z1dp}w;6Lh3AkQ8U0`iiWz8oy(nhA_!fW92_1dV=KZzVDtV=4AbGK43BZw-Am`=bO?
z@TbMqaHY~IlcIBZHG@Xce6VY8Z{3noX^Zi_nuvVG^R~3XUaKedibgRU>w@Gb!z`m{
z3c6^x`;2z~G6WyBG7@-`Uu2?VaK<MfcrelYq1j(sa#7MuR6G-HkI{c^rh=h^ro1b&
z*Y%XL(XsO-q({%N3=Fv|#pcmd%L;TXRlg5yu;irgXa)47Kc9Q5OciDNv|yM{T5B7M
z&h$WoDA4$wp$CL)iPAxHE)aZlLwJBnmX0`FQ?5}lmEVk4)JBtqbC$zK*$6Im*eFSF
z(|MBGBybE#-i&5eo9+|3`avH*y<EUUp5$WLp_k5nn1c73o<o}RtGd|#mVtdxy?$g7
zf2?`x3AP2L>2o22opEm(9*6|OlYk7r5t$ZL0(&%sLx?cnjbV>69=zP$g5u7r+dp{b
zVU_7oNa(74Y3-xCR|u8*rDX`upUN7w6sulr2J)9j(zmDOxTu~tA4^YyEP2G7I;1FR
z^vd~(#G{ukB<b#@D}S;{aRw$YXX#OaiJYU8X*cwk_z83R^9u9l9Yez%no3<aUT?wU
TAO3vJ*PME^eJTxy104Sc|AclM

diff --git a/kalman/CMakeLists.txt b/kalman/CMakeLists.txt
index 4b5c98a..6782630 100644
--- a/kalman/CMakeLists.txt
+++ b/kalman/CMakeLists.txt
@@ -4,7 +4,10 @@
 
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/base 
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field 
 ${CMAKE_SOURCE_DIR}/mpdfield 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/kalman
diff --git a/lhetrack/CMakeLists.txt b/lhetrack/CMakeLists.txt
index e1b1de9..a177c43 100644
--- a/lhetrack/CMakeLists.txt
+++ b/lhetrack/CMakeLists.txt
@@ -1,10 +1,15 @@
 # Create a library called "libLHETrack" 
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
+${CMAKE_SOURCE_DIR}/parbase
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field 
 ${CMAKE_SOURCE_DIR}/mpdfield 
 ${CMAKE_SOURCE_DIR}/trackbase 
 ${CMAKE_SOURCE_DIR}/mcstack
diff --git a/macro/eventdisplay/eventdisplay.C b/macro/eventdisplay/eventdisplay.C
index b8dee46..2b841c4 100644
--- a/macro/eventdisplay/eventdisplay.C
+++ b/macro/eventdisplay/eventdisplay.C
@@ -76,7 +76,7 @@ void eventdisplay (char* sim_file = 0, char* dst_file = 0, char* out_file = 0)
   fMan->AddTask(TofPoint);
   FairMCPointDraw *ZdcPoint = new FairMCPointDraw("ZdcPoint", kOrange, kFullSquare);
   fMan->AddTask(ZdcPoint);
-  FairMCPointDraw *EmcPoint = new FairMCPointDraw("MpdEmcPoint", kOrange, kDot);
+  FairMCPointDraw *EmcPoint = new FairMCPointDraw("EmcPoint", kOrange, kDot);
   fMan->AddTask(EmcPoint);
 
   // draw MC geometry tracks
@@ -96,14 +96,34 @@ void eventdisplay (char* sim_file = 0, char* dst_file = 0, char* out_file = 0)
   //fMan->AddTask(MpdTpcHit);
 
   // DST tracks
-  MpdTrackDraw *MpdGlobalTrack = new MpdTrackDraw("GlobalTracks");
+  MpdGlobalTrackDraw *MpdGlobalTrack = new MpdGlobalTrackDraw("GlobalTracks");
   fMan->AddTask(MpdGlobalTrack);
 
-  if (gGeoManager)
-      gGeoManager->SetVisLevel(3);
+    // draw EMC towers : MpdEmcTowerDraw(TaskName, emcEnergyThreshold in GeV, 2)
+    MpdEmcTowerDraw *MpdEmcTower= new MpdEmcTowerDraw("MpdEmcTower", 0.0075, 2);
+    fMan->AddTask(MpdEmcTower);
+
+    // draw ZDC towers : MpdZdcTowerDraw(TaskName, zdcEnergyThreshold in GeV, kFALSE, 2)
+    MpdZdcTowerDraw *MpdZdcTower= new MpdZdcTowerDraw("MpdZdcTower", 0.0001, kFALSE, 2);
+    fMan->AddTask(MpdZdcTower);
+
+    if (gGeoManager)
+        gGeoManager->SetVisLevel(3);
 
   //fMan->background_color = 17;
 
   //FairEventManager::Init(Int_t visopt = 1, Int_t vislvl = 3, Int_t maxvisnds = 10000);
   fMan->Init();
+
+    // -----   Finish   -------------------------------------------------------
+    timer.Stop();
+    Double_t rtime = timer.RealTime();
+    Double_t ctime = timer.CpuTime();
+    cout << endl << endl;
+    cout << "Event Display was initialized successfully." << endl;
+    cout << "Output file is "    << outFile << endl;
+    cout << "Parameter file is " << parFile << endl;
+    cout << "Initialization: Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
+    cout << endl;
+    // ------------------------------------------------------------------------
 }
diff --git a/macro/eventdisplay/examples/coloring_bmn_detector.xml b/macro/eventdisplay/examples/coloring_bmn_detector.xml
new file mode 100644
index 0000000..414619b
--- /dev/null
+++ b/macro/eventdisplay/examples/coloring_bmn_detector.xml
@@ -0,0 +1,21 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="detector">
+    <subdetector name="Magnet" color="gray" transparency="67" isRecursiveColoring="true"/>
+    <subdetector name="Coil" color="red" transparency="67" isRecursiveColoring="true"/>
+    <subdetector name="targ" color="yellow" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="pipe1cave" color="orange" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="recoil01" color="khaki" transparency="67" isRecursiveColoring="true"/>
+    <subdetector name="GEMS" color="cyan" transparency="15" isRecursiveColoring="true"/>
+    <subdetector name="TOFB1" color="spring" transparency="15" isRecursiveColoring="true"/>
+    <subdetector name="dch1" color="orange+7" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="dch2" color="orange+7" transparency="67" isRecursiveColoring="true"/>
+    <subdetector name="tof2" color="spring" transparency="15" isRecursiveColoring="true"/>
+    <subdetector name="t2reg2mod" color="spring+2" transparency="67" isRecursiveColoring="true"/>
+</coloring>
+
diff --git a/macro/eventdisplay/examples/coloring_bmn_hierarchy.xml b/macro/eventdisplay/examples/coloring_bmn_hierarchy.xml
new file mode 100644
index 0000000..5446c81
--- /dev/null
+++ b/macro/eventdisplay/examples/coloring_bmn_hierarchy.xml
@@ -0,0 +1,15 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="hierarchy">
+    <level number="1" color="gray" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="2" color="yellow" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="3" color="cyan" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="4" color="white" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="5" color="green" isFillLine="true" visibility="true" transparency="30"/>
+</coloring>
+
diff --git a/macro/eventdisplay/examples/coloring_default.xml b/macro/eventdisplay/examples/coloring_default.xml
new file mode 100644
index 0000000..60ea2f6
--- /dev/null
+++ b/macro/eventdisplay/examples/coloring_default.xml
@@ -0,0 +1,10 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="default">
+</coloring>
+
diff --git a/macro/eventdisplay/examples/coloring_mpd_detector.xml b/macro/eventdisplay/examples/coloring_mpd_detector.xml
new file mode 100644
index 0000000..e3a794e
--- /dev/null
+++ b/macro/eventdisplay/examples/coloring_mpd_detector.xml
@@ -0,0 +1,23 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="detector">
+    <subdetector name="ms01yokebarrel" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01cryostat" color="gray" transparency="15" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeii" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeio" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeim" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeoi" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeom" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="ms01yokeendeoo" color="blue" transparency="30" isRecursiveColoring="true"/>
+    <subdetector name="pipe1" color="orange" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="tpcChamber1" color="cyan" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="tof1" color="spring" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="emc1Chamber1" color="violet" transparency="0" isRecursiveColoring="true"/>
+    <subdetector name="zdc01" color="green" transparency="0" isRecursiveColoring="true"/>
+</coloring>
+
diff --git a/macro/eventdisplay/examples/coloring_mpd_hierarchy.xml b/macro/eventdisplay/examples/coloring_mpd_hierarchy.xml
new file mode 100644
index 0000000..4d7fe08
--- /dev/null
+++ b/macro/eventdisplay/examples/coloring_mpd_hierarchy.xml
@@ -0,0 +1,15 @@
+ <!-- // COLOR SET:
+ white, black, gray,
+ blue, azure (темно-синий), cyan (морской волны), teal (бирюзовый),
+ green, spring (светло-зеленый), green+2 (темно-зеленый), spring+2 (темно-зеленый), khaki
+ yellow, orange (желтый с оттенком), orange+2 (оранжевый кор.), orange+1 (светло-оранжевый кор.), orange+7 (выделенно-оранжевый)
+ red, violet, magenta (бардовый), magenta-6 (светло-бардовый), pink (темно-розовый)
+ -->
+<coloring type="hierarchy">
+    <level number="1" color="gray" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="2" color="cyan" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="3" color="violet" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="4" color="azure" isFillLine="true" visibility="true" transparency="30"/>
+    <level number="5" color="green" isFillLine="true" visibility="true" transparency="30"/>
+</coloring>
+
diff --git a/macro/eventdisplay/examples/run_exp_offline.C b/macro/eventdisplay/examples/run_exp_offline.C
new file mode 100644
index 0000000..be38b39
--- /dev/null
+++ b/macro/eventdisplay/examples/run_exp_offline.C
@@ -0,0 +1,7 @@
+//run eventdisplay in offline mode for experimental root data files
+void run_exp_offline()
+{    
+    //gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest_run3.root\", \"$VMCWORKDIR/macro/run/bmn_run0607_digit.root\", 1, false)");
+    //gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest_run3.root\", \"$VMCWORKDIR/macro/run/bmndst_run688.root\", 1, false)");
+    gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest_run3.root\", \"$VMCWORKDIR/macro/run/bmndst_run688_gl.root\", 1, false)");
+}
diff --git a/macro/eventdisplay/examples/run_exp_online.C b/macro/eventdisplay/examples/run_exp_online.C
new file mode 100644
index 0000000..7a3695f
--- /dev/null
+++ b/macro/eventdisplay/examples/run_exp_online.C
@@ -0,0 +1,6 @@
+//run eventdisplay in offline mode for raw root file
+void run_exp_online()
+{
+    //gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest_run3.root\", \"$VMCWORKDIR/macro/run/bmn_run0607_digit.root\", 1, true)");
+    gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest_run3.root\", \"$VMCWORKDIR/macro/run/bmndst_run688.root\", 1, true)");
+}
diff --git a/macro/eventdisplay/examples/run_mc_online.C b/macro/eventdisplay/examples/run_mc_online.C
new file mode 100644
index 0000000..ca0a459
--- /dev/null
+++ b/macro/eventdisplay/examples/run_mc_online.C
@@ -0,0 +1,5 @@
+//run eventdisplay in online mode for simulation data
+void run_mc_online()
+{
+    gROOT->ProcessLine(".x ../eventdisplay.C(\"$VMCWORKDIR/macro/run/evetest.root\", \"$VMCWORKDIR/macro/run/bmndst.root\", 0, true)");
+}
diff --git a/macro/eventdisplay/examples/short_ru.doc b/macro/eventdisplay/examples/short_ru.doc
new file mode 100644
index 0000000000000000000000000000000000000000..7e5aa37ab50d2dc0188bb1efa07bbaec12c83e3a
GIT binary patch
literal 36352
zcmeI54|G)3nZWNPLrjo_5Ym(a;(#e4VhjPo5JE^oz!>>wq11y2BnAo;LL|`w%b_XF
zx*XS9q^{d_Ih1m!hg#Q@QqC^Nax80mfMr>*9LupT>k*bk*Sg(ES?XWd-*@jk=DwME
zGm}3E+Pv^%-hJ=B@7=%O{qA?)ym{q#zc+vMvw^2o#5Pf-s!NwMRGM|%$9|O)&Q>ag
zeK~gN^5x6UVRn1A&rk_`5=yJop`S|Z1ybiXKssbVZ@3X8P9~pO&=+U|svqP)f5?R|
zKpuP%2EdnKAPj=Ra1#uHn;`&0VHn&3`S4{J4!6PxxD7_a?Jx@NfC9J^3Sl%9!5A0|
z<DeMELl7oF2~31im;_}o8OosoDq#vp{-%aLL&fsB|M-ep&0jNhF;zA2xkjy{1d`wK
zXfbvnC3B^%FOrF$C{EA)!zGZYtmM31{=QIHjwR~<eTe&c>Hm`7a`N-%-v52HhEx>1
zw4k&M8PSzGp#N9XM1Rj%{@|L`O{<qS2fns?P5m8JtH1H^swEB0dQ6xxM~+pkeo&7D
zvR^<zpDzfi3lsJ{WCX?gpY~^N8ZT0ub2*F}y|F^>XGC%YEo5kV?{bRbld)_j`fZI`
zrE1km!ZMDH&Q~MzeH9EhV^rlxHLE67-3wD{2B=llU-CD>J=H!nyCzLFRQuDLVPVY;
zs+RMMsweo7=*#}LZ>w)6vNBY)T7v9)wH*EVb@Zr=NP|dG`Eb>HxVmwg&-v)Tt6k;p
zS}Wt{l$v}sF5Oql$AWa^q{NXYquU_zRzBR<d$`ZY(;xkJ9S+M27<mCBFEx%l87T*0
z-IWhd={-Ef$kQMFcRe1KH`vG<Eb_P@#x_h{y7~O&_w?wUp}xjnkdk?rk{+$r>#<oz
zc8TNj4deRgI8sthoPHj0B==67p&oH0M^2p49&yAraN<;W#1Y%UiF2<<9I-8&IJF*e
z#P)FFJme8aY!juXQ9eGk)i;g(8zNeg=-L6wX*6m1K0>o<(rK#cw4cGcd75T97|W+J
zTjWSCGt^vK<XSzZSJL+D^@yI0C6-ek@cEF4rAAeY{dH&dlfIq40Q-J5ofh20Rnj2`
z5?)x7p~}@T<nHm6bMyvmq*~QTjO9pe;7BIzs6P!_8g(Dim!rE-ak@_~mEQ6|x^KA7
z;mdrAZFx7>)$7zrXt2J@+^Hs15;erjP+#;H`p5Xo{1c%FN*J0lu^p2ujY=)+jIR<|
z>FOqAjYmqMf094wAEzY^Nto^eE#tgTY|RXH3n>sOh5kw;O!QAjN-u0!$+by;sg9qL
zA~t4kbuaxutg6~8rPajoJW70F>-dxhU~wxp^De20LG-U8Ri=BawDw-q-*T>7NjXXS
zhpN<kUv0imv_{bM%AoYh5>=zG5$iTx&Ebx9`fkpZ+4MehW&d5Jx{jpX<Wn*EYMxGQ
zQOZ27?Wbm=AD5`5SM+2va+Xj}fh#RZ@^nimy<*qTsv(asr6!klcq474H*#~4rqqj=
z`4o>d5Iw5MG~y_x!w{wmv->O6#`NF~rUea{{3V$9=SC^D0&~8Y%s+~`-bfLysp#Cy
zK<;$}6Xk3Uvk0aj+ephsrV@`(jrGXiPGL18TWU4Y41yU>yXmEA?J^Sj$W#iS0#&Aw
z{c<(rJ(&q{T2y5^$I|~KlOqPC_U)X=R_X1e%UnpTzACj{rY?Pzzn%OeD5G5jIGeBK
z@?{}K_14#kWSN#p{F!{_gpNysWG>dEZfut+(zkt#;p#h*HuXziHupV1cUS5Es*hau
zrBgb-6iFVH-Yyr*318@cDywhgpNVm0Zf~+6;`Q8bVQZUjaqH|$UpUxHWTYjET~4Dv
z@JX_<Um<p3(y<q(E^giNv6j6!HDOBHiJfg?w<nI>;$Pg_@{yL^;!h|$yVv5@_78RJ
z>|P0D?;!SK6MIME*oA3}TVMG=%Pvd{$<~#ttHk^#h8*qZ$`R>~vZXjpOb*P}jX){7
zrMfF`OE|WU8v8%dN~_QdO)9`RzeIhLPnkW6W!1nX<B%i$A<;I6@n{vgYPGh<#tcvH
z?iJ{$<=kl{;+JzLU%y26QF=tHBc*FBJsdz&%8}*hJEb*kygZG`=T3=l#4IA5x{3be
zu9-mzG(Zz$YOQ*ZR4FwpExBu}xZi5>AUb-EE`O<&X}Ww?Qnn)R8_1iGq`Ya!Tf(0s
zOQ|{33pym>CRRhNGL|+WW1d|y6Ot^==+rD4+m+NfB`sc_)r^x;SJDQYc8oVj<R{Fl
z_w|+NXkYqw875w#3oO&3&fZh{_2<7)@pTbvWWU9^QhHyiZpD7}oh{Ou-ACn!Y`3P8
zJlRA~_iUXmft<olU+Q^bgq90<Ms%O(a7tR-*T)Q9Vs!Rt)53jPTHKp|`NQ)c%vzTH
z(<jr_?YI8?cai`xQN)KM=Nm!tvKCUI6{NXs0WmnX0i%rC4dM^p3u4F|0PzbS1zZQ}
zHIRArS?B}pAoutfME-w&Vtl@GPuYe*ckN5Mi<tnH^Qm6UJSOIs-j^_2Io!T6@9vF7
zztOXpzPHuy`_qiyIJd|95xe{lqf&nRZ@=AEFev-`e@pp|`rw5sj`fN-wt!>WI^<J?
zW`kTSdG<Qa>FZ{D_s2fpj6ep}-k$SIld3}fK}CzD%&en!^~&0YpgHPFcZNSt70J*a
z+8k5E2}gcjzTB7DjA<LPU%<Y!BiWDKHtPdVNHb(}K20e0{}RW{Kw_VdJi3$kqHVKi
z;?u2@WhALunpGFKn<Q(U*dC<|)kzZyZMPvuR#mR`HlK2O>slwG6Zfw`b&1CLgcdD5
z@>*|Spgu*5I-9f;(VCz3mZE<5Y2UKvemy17Qv%mj3EYfNvm8qCYgV#%k3XPF374>6
z=C5Ecz+CAOkkw&X<&gR6N@ker7{8~efGQ$J1+mBZ$3lSB^i{-l)|E@J1e>^Om0HB=
z$P(sXi<o&YN5T@W%?$)p75A8cPgSJIz00(miTG+I1;%eXiFB26B%sC;dlG+6IOxAq
z1-V+zjp6=fS8^i0-U<2&$=Nt^RLNN*Gr+ww^_=&?gej7om2l-GN<&I$N|Gs?%r)-(
z1g@lX1`;d$laXAGG%5Q@$e!ZQq=dz1TuUi6h32Z_889VPN!-cE4C<7W`S0SYAd;kx
z!sRm6U!rrD!5WOYE?lP5b;(IBh2xLot{JS^n7FZ1R;Yd6QtHvyN{d)TS{tZSSp#!Y
zD<w8j*X<<kH$q8yRKRGYNKPi`v`p~d#+@hYda0l!%5)h^Td-qhQd^m%v4FTY$A}xw
zVPvbBs>>^&64#={G<7DWTIwpJsr~})@6?UEW+suQLeA!QsU44q*?Mo|*%hb%iBDeE
zX9{Sy=9!JidnV3ftUe@nsMCG6K1zP38cvN%soWK6XR-z&ZHF*<7LU_%(lY~1Fq>3K
z{WtTBn0Va8KR6OSumoR}oLOnb2=E+EK(`f%6<^8-)-hsB8O9Sq0sLHYwqEZyUP;3Y
zQm}?|;^(=Ir++fhI&!RmCy2`MO4ai>mv9qtMtI0K*Tqkr<Z%XTpR*}}(Ot-4EE(OG
zzgW^cn!BQI$ek^t`*UYY?`ZDEbVKfJ8Qq^dTY9p&tD;p_cd1=QOX$9wMa%A3zU=z$
zs75jOwk33TzHHga=4-B+g*NPp9*LIFeff%(oqWDlqkqFAL`Q3DE_&U*zB}{emK>cU
zSv{y{)j%v(dt{r<*ioNUo?=OmQ7uwJ_vI>5a&)f3bz$de4x@KdQhAELUUC$9y~)uk
zEC3TfJX*`>-;8#WRX}+@OGffW_KXG5vC%v7t|qr`>twFBNn};5i4i-X?xHqVV*!Yz
zB1gSjWH?R}mcp>8E1NiG?ikO)h`e898mq~9vsLo4O6j(w%)CnEtU{+t?AU3JFG+G>
zOOmpa^{~c}Os5T2QZJ@tx>7UtolLsiEiryt#kO*EPS<kmmeRd>bj$8&{!9r~(FT{H
z_q&$MSh5PKZ(}8QXN|hk+m$>Qbz`0#Sywa9&OJJpXETmDGP>4(-LkGmExYeva-12`
z9$~HMj31&^o&GL5U7kW%>8W8&%xEb_!^XNk87&*{{_Yy{nz71k*qQN#$GAvsY{znD
zk(p|s_IFg^<uD!%@rX@gt~_4<f0y?1i05UZe-<%{@Po*+jWU}Se@A>DhWM^TLJ4sz
z@qiegl=$A{4gn>88}Z{!@=I?Qe~R2)JXVF=Wum^f_;19^F_&>yN?3d~P5KE983osA
zJt2M<@#B^Ii@EadkS9c>kLPG9z5q$R@e`I@$*-iqDK&S=ir>UO6U!C~XfKBotE1&9
z9trVKOeF8(M+@rG6(6S5L{NJWrA#De;$12tR;4bPB0O$0$>TWvtf`cw@g5p~C{J=D
zqgu-hsQK7_Q*=5VubR|`l=67;ZemVCnn)2Jnek{%MdDb}VEmJJ=`@M&YZ^5nX>z=7
zUa}HPi7el6kCG>Xx>mBCZK?5Er|~kHIw+we0_vwREUI6`Y>UR9>(zRV|2W)IO*<9O
zw%o<tR_8|DQ))xJyv9d-kM<nfeIdvh>9ZBOc1>@T^viX2?b$M<9f%h+vNcp{Z=%!Q
z6WKtvuK6@Il2eP`es9qwQz-)}4benW&YvAUWy)RpPY&rHuk~*+wIyDA(V8V_K&K~1
z>rz===t%CRe2OS5vqmx*`J!be@+baP@$1VyOgT!gm$DSCCZmFA;m8*3ZavNzZ2Egx
z7t8biYxNV4;kktP(Cv}RkrXSgS!*!bbvk7<g;YvEu(hjQ=Xa21Cuj1Ue5~BLdt$7+
zJ6?XXGE(mHG@Dv;@+&sST;?thCSgT7*NBB-Ut=t%(MinV?5m75;bp~K9nG6uk91oH
zwp|gurY1euz0#6sJulkcklGr6UW{%f6=;RBkS3M(J&krOZ9Yg#id?6Wl{z^m-};c&
zUrEb1J;1F!r*PDa9`daaRu5_2b4h`-iYS(dsTF4h(u@m|60rxQXG<TqZ6Y&5I6B=K
zF^o1dWp0j%uE^BuPjYUGOPU$Ws>p$Sb45}SYh6rMJ!HQ9FqW5-FImlV>;&msQjX@^
zCeC={RZHPKOAND08@)<o^m1Ly6&{lY$&FZ%V)2P};)F%#NLfuLJyP!CE09$c@jSTK
z`y$tcrJRa9R_l^&#bJBbu|pzTs@GbjDMPU=DzLM}RxS1af;5NMJf&@kMs`-x?zqx^
z#wA$k8%@sKD}Aw6on_2+*T*7V>kWM4(0l#PPH!+O#jNxq)zqUSt&s1!7xG>AMR+2Y
zv%W4~AzOZ;^*hs3s;*q?=t$A4Gg!eB%^E&SE8)1z8f4YZ>sryTPAXT0WZ3C*^sQJ<
zVUJ(;cmku-Z0qT8PV9UdUq<*`$8%Y)y*JT$EQ;`Ic26E7(;GjB#v*V=*^bVwoSqlm
zXG^p;7flgvwNoS7tY{@;O*!kwazwPh^hGm!lIJ_5EzRINC5vclcVn5~tu?yHcF&Qc
zQxQ3eh<w`ujWstGEizSGUz7azqTifZvFHP@xrMY<dp6LynXzMWnr9d!e?jgpv%&DV
zSa_ve!z=9))64{=?2OMqM#u_1)0H`k%>B(%6=IbZg~k)n-7=oqqvQ2DhDo{|ts&!M
z19~l<Zo8Tzm+0tN&zW?*{YlNa?J?&$7&%%-9|*TU8TXymE8~Buelo`Cfys`2(o&_Z
zM9*04c7A=0dx^_6nderVF|nBMp$9uL3P#T?oYBObi8U^`uL-ZMxUV!L-qjlGOd9M_
zz?~`?%gvb4@qF0Vbv+kbhekekW6L)=aQw?tnYT8gkDc{7d&G81H+(i$-FQimT5=@F
zI%BgQz2ym_usm7Qlb+<Pl{xWE2`1x-cCHA^v}?#KZQ;5KU)RyRnKBJuADI`s%#+DU
zq&zzx?v~a)wnkUSe7C-hWdX$3kAEIEfU(}a+TpdVNoO<=d+d6ty(!u@3HK?-KDbsk
z9GXdw@y6?5o=Yyn8gy*JXj?+GnPc_N3a#rH`%%hy23Lx&F`$gk)A1~r+3@w~^9b9E
z=BZV$(f?}NiDSEHC)zDNo?RHr8!Ud-60AJ&XPKv2<k{9Gcrn8(j6F7^+vj6@P-3+j
z`G&&E9?KDH(LBE$wnlm^M|qyT$8waXl#;iBdo0K9e6GTj`?a<_63x$gEJyeHW{>4)
zte5L&wd~qkj@Q)}K=~?qK9oZxEQUJx5T4+h>92vGmwc4Nv+z8O<Ygb#upb8V)%5_B
z!U9+bkHA`34;x?;w8Bo<1uww?cp2o)a3B5g_h&vbn>w=R8Mg1WJj7pJ%l96d!wzqa
zt{iz|<1*F48+dB6dD~ns-Zq!bTj+Z67P?+?Hmh-2i}zU{*RpwBo87qVz<~oX&*sLu
zMBN$WeS0I-czK`R09Bl>CZwyfk-VCZl==0G4;Q4XvGQV3Kk4&(#P@YDzP$P`EZ=9z
z?>D7ppriqTwd`^8EIASmI$>ToDyMxaUCv7&Amx7y-iC|7mqAqk%ApeOgZZ!k7D7EN
zg;sbJw!;qC3D3g|a2QU)S-1p4cu8FViXjLkPzse$1$9sl8(<@}z+><@JPUi_WjF;N
z!zIY&l_7aB00u$;hCw-0!hBc&3t<_ofL7QFJK#ll9Zo?zoQDf=5k7`XFqoIQ$Xg5B
zPoF+{`egfQ{tmUDJiSkLI&(<cU{_jl?AD0HPPcDWE%_S@#Snx_sDg#C64t|3*aLgv
zFdTuSa136BlW+kpLLc7CmIc``5C%grRKZtZ1w00i!w%R9yWm-P9$tW>a174EId~h+
z!v)CV&5na%Bve8j)WajN7S_WC*aWSx6L!HqcoFu)K{yO&pdBtjE^nqRh9K0ybeIY9
z#>)27C-^&k==34^JhAV@A?m*qheGuqM^|~)a2y?#u>Rv{PE{@Wn+Ny7T38QHz!umF
z+h9BFgM;uYyaT;?)lMH60s$BX`7jbjfxHZKIxL1dsE5bkad;N?!pra)oPvw+KBV)i
zo8Hg|vLF}opb(}(4crGyVFR?lv#=ZX!%J`gUWUVP1kOVaZyn8rJjjRPP!2O;0W`xl
z*bXm%yrs1L^vOf}sP)r_4xK!7Qa-77>(I~jIgSyF7<SOQNNOE@o2`ee#Qi@`U+!e<
zh|}KGG|A^4*b6VhemDbX;Uc^bA3_>$Q%#57kPk&r4s&4xY=o!aY4`y=13O?R9EKxs
z7S6%jZ~-pD`;fzHc>+)X)zAoQU^6@hkHZu26g&<4;U#ztUWZfgHoODxLK<(E&4po5
z3iYrQHo!(`flaU(9)mX614rN}9D~>46v&%urL!Mu-$y;8_!$DE8Fc1YsQ<_5kDfIg
zrw-}=oz@PjTJrZkr12vixljN_Fdb&X3RnpZ&<KyfTG$HDLmRvVN8t~U#SeYdKppQn
zY=jNa3eUjHaNs6B;S^kewKvmF;1r|`MbE%7xClQOM&E|4Tc}5v2lCe7_V)kc@1*=4
zI!V0{*s*!@jvf5RhyEuYo4@s~9h;@hy|;eW*qK8I&GE3+y3e-j%J?6@rajwE9F3wz
zNqH80nL3A2!|Bg359UMetsI99a0=dpk72+F#&#G51yBe@5CnOn^MAf^@cFF=*Vi3n
zn^Pr!<9Kx*slQ6CIJQ0BefD)xLVN##bg{ZElUzk!<BOUj@N)EsYhvfayX`Tm44~1X
z@q$;{al)j!@0lz0H5Z!U5m*cBVFPT0r{HO5gO}haoP|rkVuMP79LR+{7yv^c06{2$
z`(QpSfQ7Ia>R>Ibho@jCw824m6E4E}+xY}}LpU1u#IM><@JEN=r*}^L<ODj|I{f6i
zb<OKMI(xXRI$FxH<9oNR`0d=YmuAQuwI${(G=9J5Y@88=v+?@>ZBn*bcVMqWF7zqD
zhJ$7}1Lq*+PU;l~!eAH)qo4o^p%{WN9cIE(SO)S|_j5=0Zfo7kwr<7!@;Ckdbt@*V
zxSv`|nC`2jEn?R|M{7BDeEO=#9Nja%htD8Ve?<Ejx<%)FQR=7#Ho-P{4)(!OI0I+l
z9Gr&>a1q{zOTZ&~Di`u#6cj)qOoM8ugC}4sw80+O3kTsa9D$>70$zplZ~+F6rk%kM
zD25WKhI!BcPrw$~3OivJJPW(w1!#j~@CuxRx8WU-9}4qB4g^4caX>6Ou_UxfcZgZO
zs1!NoK7^4G8A~7X&^F$OyVB}ow_GH4-u{~`WiTD;;NlqSax8TT!-|<BLDqQ634%}x
z<w0~f?1sS;C`TxTufSZG2lcQNmca^Wgf$?)?(o*}<NP~vyzS}Z8`(L2ys7@H@;B|P
zO;^!Eh+T4?ebS>3e@cB)W{aV5-7|$AS|fIR@3Be^k~-N8J76d5f)`;woP@J*9@0vv
zZx{jr7zG7T2t^Qt5||0IVJR$w70?2kU>h8Uqwo&A3x5D!&!tkp4{6W`vS1Vxz+9LI
z_dz2x!zS1QyWub#funE=-hemZ47?5RKzb>2R|vo`$cGXrgXu6I<d;Y2``XB0mS>C%
zyggTrxeuASpevR><lXr>LvM{UuElPr343_w$Nwpk=SN{16qZqUuoM=QW2ZrN1?2*3
zAk=r;o^Feq#n0`@$o`*<O&@tpGUNEC*#CRWtBC92W7v{`-viQE<Eez*@EpjR&nVV<
z_@N*55)5ITK-PT9;2ju-k6(Uu=M%f;Ke7WK*nvOUf&a4uf3ySd*@6GH1OH<O-mn9|
zvjeZ%f#Y`Ih#mN6JMfQo;5j?6-42BIZ@h)yb5iO72>+fF=e&;hzD1?xtJ-|mRZ;`y
zsQEppc_>2XNP@jACth?an#}9yeWWHHIZ|)(BSO334S2LKx*ry2GcSW+Km0$Cor4b_
z&Vs9&-U^k4{`hx0;41Q8*=PRA4*b*({Ll`3-wynh9rz17u-Xnp?0eNj&vAYcjI!z@
z^_kb7F(2NA-T2^N2l2^I$8Ww7#K&HlhkpR%SGE3V7jkFnf1fSjAMC)7?7-7@;IHk#
zx9mWZ9q`!iXnn`-sp!EN{ntx&cgXOP-Cf7~NPW(O+yUr!NdFRg9X^D@f!KDi2ijr!
zAjXQp*b30)Hqd1qu+gsSb#|cH4mkT-r>55Cry8BA_bkmj&-91xD%a17oJ^_9U*m_r
z2<!2|zXATC=mGrh+4zRbpb-i~KH~dAzTrIlz+*vvUGGDujOEicptsv+es2fP*@6GC
z1FzYEqjuns9dPN8pWA0%umeA_1JBrjzp(>b?0{=O)>zCqnVK&xDCW2uaYaO%i*qga
z4PWckg8X7bXqme8%AT<sN<vrbb747p&+}Ne)ZZH*zWqzEX9PYIcpCrfVR#=d+)n#|
zoI8w<FslH25ad@Cz3cv6yBOcJ1FzbF!**c59Z0fLciGpt><3q+y2g)3?Q6pO5v3-U
zn%G92scU_0xa@UZ$+7;sJ|#_K-H}@3u2$O$=d-WW;aLzrFR#*9+u<107cw7!tx$^Z
ztP#?Rum?eYN%Jb!dt10d@JHBzAJ~D%?Ldni_@*6j?^~tvDb<5lKfc<>t(?ZG|4gaN
z_s8I88H-P(*!cWP#v5N>WsrFQJO@K2Fz16Zcn#7~H}Y$$u6FRAUD&Sv|CW8`j2&?4
z{$uu;f3X9<wgbPk125WvpV@&Q+kwBc1K+g+Ui;luL&?=dxKD=nvaXWu(Ra{eLSL!F
zBOpGxM<!C&P+p3^2ev~|8GbxiSZ@45@|$4YYx})mm;X=fzz#d`_jbTFGkDTIa~1Z(
zr4_E3@G+})LmDOCx$bIH-6f|_p}M(kQ$e8ZV8zh32LCX)WlMuUABtuxHF`_XSJ=4p
z+~vz-2#qLGSquj~+vlhR!f(l%%J&DG`R3QU4&^RS_0qrc?fmF)T1JY#{(zA(EtarU
z4z~0&XMFk{;H&tq|17>^yCPQfxW{r-3V+(T(dmdA**fXm$;W-oFRfcAJFwfEyG!0B
zPx6_}rIKFUD|#EvTL)^%d1up*6}rFNTegtcxF3?%w;5Yx>&08W9_HO(t4M{^{oS+z
z`<LLCD|yqG_cnt2_u}*oknH^@6E`ScNw%*ce+}<msN(ZMof7j)Q|4^q{|9paG@|Lu
zCz<~~#CLwT(zH7HjT-azb@Qv#iSO&g$iuzr+&kI)U$WBKD=Oz5tB+tO>c5J_J3f;C
E2Xfn5ZvX%Q

literal 0
HcmV?d00001

diff --git a/macro/eventdisplay/www/eventIndex.js b/macro/eventdisplay/www/eventIndex.js
new file mode 100755
index 0000000..c227083
--- /dev/null
+++ b/macro/eventdisplay/www/eventIndex.js
@@ -0,0 +1 @@
+0
\ No newline at end of file
diff --git a/macro/eventdisplay/www/index.html b/macro/eventdisplay/www/index.html
new file mode 100755
index 0000000..7c095ed
--- /dev/null
+++ b/macro/eventdisplay/www/index.html
@@ -0,0 +1,24 @@
+<!doctype html public "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF8" />
+<title>EventDisplay</title>
+<script src="index.js"></script>
+<link rel="stylesheet" type="text/css" href="style.css">
+<style>
+@import url("style.css");
+</style>
+</head>
+<body onload="setReloading('event.png'); loadDoc();">
+<div class="TextCenter Chapter">WebEventDisplay</div>
+<div class="TextCenter Hidden">
+
+<span>Current event number:</span>
+	<span id="frmFile"></span>
+</div>
+	<img src="event.png" id="BufferImage" class="BufferImage">
+<canvas id="mainImage" class="BasicImage"></canvas>
+<!<input id="open" type="button" value="READ" onClick="readBOX()" />
+
+</body>
+</html>	
diff --git a/macro/eventdisplay/www/index.js b/macro/eventdisplay/www/index.js
new file mode 100755
index 0000000..886cae4
--- /dev/null
+++ b/macro/eventdisplay/www/index.js
@@ -0,0 +1,31 @@
+function prtHello(){
+alert("HelloWrold");
+}
+
+function setReloading(arg){
+	setInterval(function() {
+		var BufferImage = document.getElementById('BufferImage');
+		BufferImage.src=arg+'?rand=' + Math.random();
+		var MainImage = document.getElementById('mainImage');
+		MainImage.width=BufferImage.clientWidth;
+		MainImage.height=BufferImage.clientHeight;
+		ctx     = MainImage.getContext('2d');
+		ctx.drawImage(BufferImage,0,0,MainImage.width,MainImage.height);
+	}, 1000);
+}
+
+function loadDoc() {
+	setInterval(function() {
+		var xmlhttp, text;
+		xmlhttp = new XMLHttpRequest();
+		xmlhttp.open('GET', 'eventIndex.js', false);
+		xmlhttp.send();
+		text = xmlhttp.responseText;
+		var div = document.getElementById('frmFile');
+		div.innerHTML =text;
+	}, 1000);
+}
+
+function LoadFile(){
+	setInterval(loadDoc(), 1000);
+}
\ No newline at end of file
diff --git a/macro/eventdisplay/www/mime.types b/macro/eventdisplay/www/mime.types
new file mode 100755
index 0000000..6ef38c5
--- /dev/null
+++ b/macro/eventdisplay/www/mime.types
@@ -0,0 +1,19 @@
+# This is a comment. I love comments.
+
+# This file controls what Internet media types are sent to the client for
+# given file extension(s).  Sending the correct media type to the client
+# is important so they know how to handle the content of the file.
+# Extra types can either be added here or by using an AddType directive
+# in your config files. For more information about Internet media types,
+# please read RFC 2045, 2046, 2047, 2048, and 2077.  The Internet media type
+# registry is at <http:/www.iana.org/assignments/media-types/>.
+
+# MIME type					Extensions
+application/javascript				js
+image/jpeg					jpeg jpg jpe
+image/jpm
+image/jpx
+image/naplps
+image/png					png
+text/css					css
+text/html					html htm
\ No newline at end of file
diff --git a/macro/eventdisplay/www/style.css b/macro/eventdisplay/www/style.css
new file mode 100755
index 0000000..6a4fb63
--- /dev/null
+++ b/macro/eventdisplay/www/style.css
@@ -0,0 +1,11 @@
+*.BasicImage{width:40%;display: block;margin: 0 auto;border-style: solid;border-width: 1px;}
+
+*.BufferImage{width:40%;position:absolute;display: block;margin: -9990 auto;}
+
+*.Hidden{visibility: hidden;}
+
+*.TextCenter{width:100%;text-align:center;}
+
+*.Chapter{background: radial-gradient(#55ffaa, #00b581);height:40px;border-style: solid;border-width: 0px;vertical-align: middle;font-size:30;}
+
+body{background: radial-gradient(#888888,#ffffff);}
diff --git a/macro/mpd/geometry_stage1.C b/macro/mpd/geometry_stage1.C
index 19e8a0f..478c1b4 100644
--- a/macro/mpd/geometry_stage1.C
+++ b/macro/mpd/geometry_stage1.C
@@ -42,6 +42,10 @@ geometry_stage1(FairRunSim *fRun, Bool_t build)
     FairDetector *Emc= new MpdEmc("ECAL", kTRUE);
     Emc->SetGeometryFileName("emc_tr_400_3.geo");
     fRun->AddModule(Emc);
+
+    FairDetector *EmcEmpty= new MpdEmc("ECAL", kFALSE);
+    EmcEmpty->SetGeometryFileName("emc_tr_400_3_empty.geo");
+    fRun->AddModule(EmcEmpty);
 	
     FairDetector *Zdc = new MpdZdc("ZDC",kTRUE );
     Zdc->SetGeometryFileName("zdc_10x10_modules96_layers40_16_4.geo");
diff --git a/macro/mpd/mpdloadlibs.C b/macro/mpd/mpdloadlibs.C
index 1f12cfa..4497403 100644
--- a/macro/mpd/mpdloadlibs.C
+++ b/macro/mpd/mpdloadlibs.C
@@ -17,7 +17,6 @@ void mpdloadlibs (Bool_t reco=kFALSE, Bool_t detectors=kFALSE)
   gSystem->Load("libTrkBase");
   gSystem->Load("libMpdBase");
   gSystem->Load("libMpdData");
-  gSystem->Load("libMpdgenerators");
 
   // HADGEN
   gSystem->Load("libHADGEN.so");
diff --git a/macro/mpd/reco.C b/macro/mpd/reco.C
index 8946bba..80198cb 100644
--- a/macro/mpd/reco.C
+++ b/macro/mpd/reco.C
@@ -63,10 +63,7 @@ using namespace std;
 void reco(TString inFile = "$VMCWORKDIR/macro/mpd/evetest.root", TString outFile = "mpddst.root", Int_t nStartEvent = 0, Int_t nEvents = 10, TString run_type = "local") {
     // ========================================================================
     // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug)
-    Int_t iVerbose = 1;
-
-    // Parameter file
-    TString parFile = inFile;
+    Int_t iVerbose = 0;
 
     // ----  Load libraries   -------------------------------------------------
     gROOT->LoadMacro("$VMCWORKDIR/macro/mpd/mpdloadlibs.C");
@@ -92,24 +89,35 @@ void reco(TString inFile = "$VMCWORKDIR/macro/mpd/evetest.root", TString outFile
         run_type = run_type(0, ind);
     }
 
-    if (run_type != "proof")
+    FairRunAna* fRun;
+    if (run_type == "proof")
+    {
+        fRun = new FairRunAnaProof(proof_name);
+        fRun->SetProofParName("$VMCWORKDIR/gconfig/libMpdRoot.par");
+    }
+    else
+    {
         if (!CheckFileExist(inFile)) return;
+        fRun = new FairRunAna();
+    }
 
-    FairRunAna *fRun = new FairRunAna(run_type, proof_name);
-    fRun->SetInputFile(inFile);
-    //fRun->AddFriend(inFile);
+    FairSource* fFileSource = new FairFileSource(inFile);
+    fRun->SetSource(fFileSource);
     fRun->SetOutputFile(outFile);
-    fRun->SetProofParName("$VMCWORKDIR/gconfig/libMpdRoot.par");
+    fRun->SetGenerateRunInfo(false);
+    fRun->SetUseFairLinks(true);
     // ------------------------------------------------------------------------
 
+    // Parameter file
+    TString parFile = inFile;
+
     // -----  Parameter database   --------------------------------------------
     FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
-    FairParRootFileIo* parInput1 = new FairParRootFileIo();
-    parInput1->open(parFile.Data());
-    rtdb->setFirstInput(parInput1);
-
-    // fRun->LoadGeometry();  // EL
-
+    FairParRootFileIo* parIo1 = new FairParRootFileIo();
+    parIo1->open(parFile.Data());
+    rtdb->setFirstInput(parIo1);
+    rtdb->setOutput(parIo1);
+    rtdb->saveOutput();
     // ------------------------------------------------------------------------
 
     MpdKalmanFilter *kalman = MpdKalmanFilter::Instance("KF");
@@ -153,7 +161,7 @@ void reco(TString inFile = "$VMCWORKDIR/macro/mpd/evetest.root", TString outFile
 
     // -----   Intialise   ----------------------------------------------------
     fRun->Init();
-    if (run_type != "proof") cout << "Field: " << fRun->GetField()->GetBz(0., 0., 0.) << endl;
+    if (run_type != "proof") cout<<"Field: "<<fRun->GetField()->GetBz(0., 0., 0.)<<endl;
     else {
         TProof* pProof = fRun->GetProof();
         pProof->SetParameter("PROOF_PacketizerStrategy", (Int_t) 0);
@@ -174,17 +182,14 @@ void reco(TString inFile = "$VMCWORKDIR/macro/mpd/evetest.root", TString outFile
     // ------------------------------------------------------------------------
 
     // -----   Finish   -------------------------------------------------------
-
-    delete fRun;
-
     timer.Stop();
     Double_t rtime = timer.RealTime();
     Double_t ctime = timer.CpuTime();
     cout << endl << endl;
+    cout << "Macro finished succesfully." << endl;
     cout << "Output file is " << outFile << endl;
     cout << "Parameter file is " << parFile << endl;
     cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
-    cout << "Macro finished succesfully." << endl;
     cout << endl;
     // ------------------------------------------------------------------------
 }
diff --git a/macro/mpd/runMC.C b/macro/mpd/runMC.C
index a6a3c54..945aba2 100644
--- a/macro/mpd/runMC.C
+++ b/macro/mpd/runMC.C
@@ -303,7 +303,6 @@ void runMC(TString inFile = "auau.04gev.0_3fm.10k.f14.gz", TString outFile = "$V
     (TDatabasePDG::Instance())->WritePDGTable(Pdg_table_name.Data());
 #endif
 
-    Bool_t file = fRun->GetWriteRunInfoFile();
     timer.Stop();
     Double_t rtime = timer.RealTime(), ctime = timer.CpuTime();
     printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime);
diff --git a/mcstack/CMakeLists.txt b/mcstack/CMakeLists.txt
index 31d66b4..fdd6507 100644
--- a/mcstack/CMakeLists.txt
+++ b/mcstack/CMakeLists.txt
@@ -3,10 +3,15 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/base 
+${CMAKE_SOURCE_DIR}/geobase
+${CMAKE_SOURCE_DIR}/parbase
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mcstack 
 )
 
@@ -19,7 +24,7 @@ ${CMAKE_SOURCE_DIR}/mcstack
 
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(SRCS
 FairStack.cxx 
diff --git a/mpdbase/CMakeLists.txt b/mpdbase/CMakeLists.txt
index c1ff703..7244e7f 100644
--- a/mpdbase/CMakeLists.txt
+++ b/mpdbase/CMakeLists.txt
@@ -5,7 +5,8 @@
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR}
 ${CLHEP_INCLUDE_DIR}
-${CMAKE_SOURCE_DIR}/base
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/mpdbase
 )
diff --git a/mpdbase/MpdHelix.cxx b/mpdbase/MpdHelix.cxx
index 2d6b698..c7f122c 100644
--- a/mpdbase/MpdHelix.cxx
+++ b/mpdbase/MpdHelix.cxx
@@ -310,11 +310,11 @@ pair<double, double> MpdHelix::pathLength(double r) const
 	//   Solution can be off by +/- one period, select smallest
 	//
 	double p = period();
-	if (!isnan(value.first)) {
+    if (!std::isnan(value.first)) {
 	    if (fabs(value.first-p) < fabs(value.first)) value.first = value.first-p;
 	    else if (fabs(value.first+p) < fabs(value.first)) value.first = value.first+p;
 	}
-	if (!isnan(value.second)) {
+    if (!std::isnan(value.second)) {
 	    if (fabs(value.second-p) < fabs(value.second)) value.second = value.second-p;
 	    else if (fabs(value.second+p) < fabs(value.second)) value.second = value.second+p;
 	}
diff --git a/mpddata/CMakeLists.txt b/mpddata/CMakeLists.txt
index 2a79825..4875020 100644
--- a/mpddata/CMakeLists.txt
+++ b/mpddata/CMakeLists.txt
@@ -6,7 +6,10 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR}
 ${CMAKE_SOURCE_DIR}/geobase
 ${CMAKE_SOURCE_DIR}/parbase
-${CMAKE_SOURCE_DIR}/base
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/mpddata
 ${CMAKE_SOURCE_DIR}/kalman
diff --git a/mpdfield/CMakeLists.txt b/mpdfield/CMakeLists.txt
index a901914..6564d00 100644
--- a/mpdfield/CMakeLists.txt
+++ b/mpdfield/CMakeLists.txt
@@ -3,8 +3,11 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/base 
+${ROOT_INCLUDE_DIR}
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field 
 ${CMAKE_SOURCE_DIR}/parbase 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/mpdfield 
diff --git a/mpdfield/MpdMultiField.cxx b/mpdfield/MpdMultiField.cxx
index b4db30d..1a69b31 100644
--- a/mpdfield/MpdMultiField.cxx
+++ b/mpdfield/MpdMultiField.cxx
@@ -149,7 +149,7 @@ void MpdMultiField::GetFieldValue(const Double_t point[3], Double_t* bField)
 void MpdMultiField::Print() {  
   for (Int_t n=0; n<=fNoOfMaps; n++){
     FairField *fieldMap = dynamic_cast<FairField *>(fMaps->At(n));
-    if(fieldMap) fieldMap->Print();
+    if(fieldMap) fieldMap->Print("");
   }
 }
 
diff --git a/mpdgenerators/CMakeLists.txt b/mpdgenerators/CMakeLists.txt
deleted file mode 100644
index 0e18e8a..0000000
--- a/mpdgenerators/CMakeLists.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-# Create a library called "libMpdgenerators" which includes the source files given in
-# the array .
-# The extension is already found.  Any number of sources could be listed here.
-
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${PLUTO_INCLUDE_DIR}
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base
-${CMAKE_SOURCE_DIR}/mcstack 
-${CMAKE_SOURCE_DIR}/mpdgenerators
-${CMAKE_SOURCE_DIR}/mpddata
-${CMAKE_SOURCE_DIR}/gconfig
-)
-
-include_directories( ${INCLUDE_DIRECTORIES})
-
-find_library(Z_LIB z)
-message(STATUS "Z_LIB: - ${Z_LIB}")
-
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
-${Z_LIB}
-)
- 
-link_directories( ${LINK_DIRECTORIES})
-
-set(SRCS
-MpdMCEventHeader.cxx
-MpdLAQGSMGenerator.cxx
-MpdHypYPtGenerator.cxx
-MpdRainGenerator.cxx
-MpdPlutoGenerator.cxx
-MpdPHSDGenerator.cxx
-MpdUrqmdGenerator.cxx
-MpdGetNumEvents.cxx
-MpdHistoGenerator.cxx
-Mpd3fdGenerator.cxx
-MpdVHLLEGenerator.cxx
-)
-
-
-Set(HEADERS
-)
-
-Set(LINKDEF MpdgeneratorsLinkDef.h)
-
-Set(LIBRARY_NAME Mpdgenerators)
-
-Set(DEPENDENCIES
-    MpdData Base z
- )
-
-GENERATE_LIBRARY()
diff --git a/mpdgenerators/MpdgeneratorsLinkDef.h b/mpdgenerators/MpdgeneratorsLinkDef.h
deleted file mode 100644
index a22ba1b..0000000
--- a/mpdgenerators/MpdgeneratorsLinkDef.h
+++ /dev/null
@@ -1,21 +0,0 @@
-#ifdef __CINT__
-
-#pragma link off all globals;
-#pragma link off all classes;
-#pragma link off all functions;
-
-#pragma link C++ class MpdMCEventHeader+;
-#pragma link C++ class MpdLAQGSMGenerator+;
-#pragma link C++ class MpdHypYPtGenerator+;
-#pragma link C++ class MpdPlutoGenerator+;
-#pragma link C++ class MpdRainGenerator+;
-#pragma link C++ class MpdPHSDGenerator+;
-#pragma link C++ class MpdLibZ+;
-#pragma link C++ class MpdGetNumEvents+;
-#pragma link C++ class MpdHistoGenerator+;
-#pragma link C++ class Mpd3fdGenerator+;
-#pragma link C++ class MpdUrqmdGenerator+;
-#pragma link C++ class map<TString, FairIon*>;
-#pragma link C++ class MpdVHLLEGenerator+;
-#endif
-
diff --git a/ndet/CMakeLists.txt b/ndet/CMakeLists.txt
index 07b2ea6..b03bcf2 100644
--- a/ndet/CMakeLists.txt
+++ b/ndet/CMakeLists.txt
@@ -6,20 +6,19 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/ndet
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(NDET_SRCS
 MpdNDetPoint.cxx
diff --git a/parbase/CMakeLists.txt b/parbase/CMakeLists.txt
index 03fac0e..2e949cf 100644
--- a/parbase/CMakeLists.txt
+++ b/parbase/CMakeLists.txt
@@ -1,22 +1,36 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libParbase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR}
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/base
-${CMAKE_SOURCE_DIR}/geobase
-${CMAKE_SOURCE_DIR}/parbase
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/fairtools
+  ${CMAKE_SOURCE_DIR}/base/steer
+  ${CMAKE_SOURCE_DIR}/base/event
+  ${CMAKE_SOURCE_DIR}/base/field
+  ${CMAKE_SOURCE_DIR}/base/sim
+  ${CMAKE_SOURCE_DIR}/geobase
+  ${CMAKE_SOURCE_DIR}/parbase
+ )
+
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR}
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
- 
-link_directories( ${LINK_DIRECTORIES})
+
+Link_Directories(${LINK_DIRECTORIES})
 
 set(SRCS
 FairContFact.cxx       
@@ -38,7 +52,12 @@ FairRuntimeDb.cxx
 Set(HEADERS )
 Set(LINKDEF ParBaseLinkDef.h)
 Set(LIBRARY_NAME ParBase)
-Set(DEPENDENCIES FairTools RIO Cint Core)
+
+if(ROOT_VERSION_MAJOR VERSION_LESS 6 )
+Set(DEPENDENCIES FairTools RIO Cint Core )
+else()
+Set(DEPENDENCIES FairTools  RIO Core )
+endif()
 
 GENERATE_LIBRARY()
 
diff --git a/parbase/FairContFact.cxx b/parbase/FairContFact.cxx
index d25fd67..c0bc1f4 100644
--- a/parbase/FairContFact.cxx
+++ b/parbase/FairContFact.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #//*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 
@@ -10,12 +17,16 @@
 /////////////////////////////////////////////////////////////
 
 #include "FairContFact.h"
-#include "FairRuntimeDb.h"
 
-#include "TObjString.h"
+#include "FairLogger.h"                 // for FairLogger
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
 
+#include "Riosfwd.h"                    // for ostream
+#include "TCollection.h"                // for TIter
+#include "TObjString.h"                 // for TObjString
 
-#include <iostream>
+#include <string.h>                     // for strlen, NULL
+#include <iostream>                     // for operator<<, ostream, cout, etc
 
 using std::cout;
 
@@ -80,7 +91,7 @@ Bool_t FairContainer::setActualContext(const char* c)
 const char* FairContainer::getDefaultContext()
 {
   // Returns the default context
-  return ((TObjString*)contexts->At(0))->String().Data();
+  return (static_cast<TObjString*>(contexts->At(0)))->String().Data();
 }
 
 void FairContainer::print()
@@ -94,7 +105,7 @@ void FairContainer::print()
     Int_t i=0;
     TObjString* c;
     cout<<"  all contexts:"<<"\n";
-    while ((c=(TObjString*)next())) {
+    while ((c=static_cast<TObjString*>(next()))) {
       if (c->String().IsNull()) { cout<<"     \"\""; }
       else { cout<<"     "<<c->String(); }
       if (i==0) { cout<<"\t default"; }
@@ -113,7 +124,7 @@ TString FairContainer::getConcatName()
   // container is concatinated as
   //      original container name  +  _  +  actualcontext
   TString cn=fName;
-  if (!actualContext.IsNull() && actualContext!=((TObjString*)contexts->At(0))->String()) {
+  if (!actualContext.IsNull() && actualContext!=(static_cast<TObjString*>(contexts->At(0)))->String()) {
     cn+="_";
     cn+=actualContext;
   }
@@ -151,7 +162,7 @@ Bool_t FairContFact::addContext(const char* name)
   FairContainer* c=0;
   Bool_t found=kFALSE;
   TIter next(containers);
-  while ((c=(FairContainer*)next())) {
+  while ((c=static_cast<FairContainer*>(next()))) {
     if (c->setActualContext(name)) { found=kTRUE; }
   }
   return found;
@@ -164,7 +175,7 @@ FairParSet* FairContFact::getContainer(const char* name)
   // createContainer(FairContainer*), which is implemented in the derived classes
   // and calls the corresponding constructor. Then the pointer it added in the
   // runtime database.
-  FairContainer* c=(FairContainer*)(containers->FindObject(name));
+  FairContainer* c=static_cast<FairContainer*>((containers->FindObject(name)));
 
   FairParSet* cont=0;
   if (c) {
@@ -187,5 +198,5 @@ void FairContFact::print()
   cout<<"---------------------------------------------------------------------------"<<"\n";
   FairContainer* c;
   TIter next(containers);
-  while ((c=(FairContainer*)next())) { c->print(); }
+  while ((c=static_cast<FairContainer*>(next()))) { c->print(); }
 }
diff --git a/parbase/FairContFact.h b/parbase/FairContFact.h
index a8e6416..2bfc6d6 100644
--- a/parbase/FairContFact.h
+++ b/parbase/FairContFact.h
@@ -1,14 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRCONTFACT_H
 #define FAIRCONTFACT_H
 
-#include "FairLogger.h"
+#include "TNamed.h"                     // for TNamed
 
-#include "TList.h"
-#include "TNamed.h"
+#include "Rtypes.h"                     // for Bool_t, ClassDef, etc
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
 
-class FairParSet;
+class FairLogger;
 class FairParIo;
-//class TList;
+class FairParSet;
 
 class FairContainer : public TNamed
 {
@@ -51,7 +59,7 @@ class FairContFact : public TNamed
 
     TList* containers;   // all parameter containers managed by this factory
     const char* getActualContext(const char* name) {
-      return ((FairContainer*)containers->FindObject(name))->getActualContext();
+      return (static_cast<FairContainer*>(containers->FindObject(name)))->getActualContext();
     }
     /** Fair Logger */
     FairLogger*  fLogger;//!
diff --git a/parbase/FairDetParAsciiFileIo.cxx b/parbase/FairDetParAsciiFileIo.cxx
index f6991c5..8461aef 100644
--- a/parbase/FairDetParAsciiFileIo.cxx
+++ b/parbase/FairDetParAsciiFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 //*-- modified : 28/01/2009 by Ilse Koenig
@@ -9,17 +16,16 @@
 //
 /////////////////////////////////////////////////////////////
 
-
 #include "FairDetParAsciiFileIo.h"
-#include "FairParSet.h"
-
-using std::ios;
-
 
+#include "FairParSet.h"                 // for FairParSet
 
+#include <stdio.h>                      // for printf, sprintf
+#include <string.h>                     // for strlen, strncmp
 
+using std::ios;
 
-FairDetParAsciiFileIo::FairDetParAsciiFileIo(fstream* f)
+FairDetParAsciiFileIo::FairDetParAsciiFileIo(std::fstream* f)
   :FairDetParIo(),
    fHeader(""),
    sepLine("##############################################################################\n"),
@@ -40,11 +46,13 @@ Bool_t FairDetParAsciiFileIo::findContainer(const Text_t* name)
   Text_t buf[maxbuf];
   Text_t buf2[maxbuf];
   sprintf(buf2,"%s%s%s","[",name,"]");
+  //cout << " buf2 " <<  buf2 << endl;
   pFile->clear();
   pFile->seekg(0,ios::beg);
   while (!pFile->eof()) {
     pFile->getline(buf,maxbuf);
     if (buf[0]!='[') { continue; }
+    //cout << " buf: " <<  buf << endl;
     if (!strncmp(buf,buf2,strlen(buf2))) { break; }
   }
   if (pFile->eof()) { return kFALSE; }
@@ -151,7 +159,7 @@ void FairDetParAsciiFileIo::writeComment(FairParSet* pPar)
 
 ClassImp(FairDetParAsciiFileIo)
 /*
-FairDetParAsciiFileIo::FairDetParAsciiFileIo(fstream* f) {
+FairDetParAsciiFileIo::FairDetParAsciiFileIo(std::fstream* f) {
   // constructor
   pFile=f;
   sepLine=
diff --git a/parbase/FairDetParAsciiFileIo.h b/parbase/FairDetParAsciiFileIo.h
index 967131d..9e3751e 100644
--- a/parbase/FairDetParAsciiFileIo.h
+++ b/parbase/FairDetParAsciiFileIo.h
@@ -1,20 +1,29 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRDETPARASCIIFILEIO_H
 #define FAIRDETPARASCIIFILEIO_H
 
-#include <fstream>
-#include "FairDetParIo.h"
-#include "TArrayI.h"
-//#include "hgeomtransform.h"
-#include "FairParGenericSet.h"
-class FairDetGeomPar;
-class FairGeomShapes;
+#include "FairDetParIo.h"               // for FairDetParIo
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Text_t, Bool_t, etc
+#include "TString.h"                    // for TString
+
+#include <fstream>                      // for fstream
+
+class FairParSet;
 
 class FairDetParAsciiFileIo : public FairDetParIo
 {
   protected:
     TString fHeader;  //! header of container output in file
     TString sepLine;  //! comment line
-    fstream* pFile;   //! pointer to ascii file
+    std::fstream* pFile;   //! pointer to ascii file
 // virtual Bool_t write(HDetector*) {return kTRUE;}
     Bool_t findContainer(const Text_t* name);
     Bool_t checkAllFound(Int_t*,Int_t);
@@ -30,7 +39,7 @@ class FairDetParAsciiFileIo : public FairDetParIo
 //  void writeVolume(HGeomVolume*,HGeomShapes*);
 
   public:
-    FairDetParAsciiFileIo(fstream* f);
+    FairDetParAsciiFileIo(std::fstream* f);
     virtual ~FairDetParAsciiFileIo() {}
 //  Bool_t read(HDetGeomPar*,Int_t*);
 //  Int_t writeFile(HDetGeomPar*);
diff --git a/parbase/FairDetParIo.cxx b/parbase/FairDetParIo.cxx
index a83744f..d4cc230 100644
--- a/parbase/FairDetParIo.cxx
+++ b/parbase/FairDetParIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 20/10/2004
 #include "FairDetParIo.h"
diff --git a/parbase/FairDetParIo.h b/parbase/FairDetParIo.h
index 558f9f3..6c9bf60 100644
--- a/parbase/FairDetParIo.h
+++ b/parbase/FairDetParIo.h
@@ -1,9 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRDETPARIO_H
 #define FAIRDETPARIO_H
 
+#include "TNamed.h"                     // for TNamed
 
-//#include "Rtypes.h"
-#include "TNamed.h"
+#include "Rtypes.h"                     // for Int_t, FairDetParIo::Class, etc
 
 class FairParSet;
 
diff --git a/parbase/FairDetParRootFileIo.cxx b/parbase/FairDetParRootFileIo.cxx
index b9ea861..d5b46a1 100644
--- a/parbase/FairDetParRootFileIo.cxx
+++ b/parbase/FairDetParRootFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ *                                                                              *
+ *              This software is distributed under the terms of the *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3, *
+ *                  copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 
@@ -13,109 +20,125 @@
 // implemeted without knowing the exact type of the detector or of the detector
 // dependend parameter containers using only the base class types.
 ///////////////////////////////////////////////////////////////////////////////
-
-
 #include "FairDetParRootFileIo.h"
 
-#include "FairParRootFileIo.h"
-#include "FairRtdbRun.h"
-#include "FairRuntimeDb.h"
-#include "FairParSet.h"
+#include "FairParRootFileIo.h" // for FairParRootFile
+#include "FairParSet.h"        // for FairParSet
+#include "FairRtdbRun.h"       // for FairParVersion, FairRtdbRun
+#include "FairRuntimeDb.h"     // for FairRuntimeDb
+
+#include "Riosfwd.h"    // for ostream
+#include "TDirectory.h" // for TDirectory, gDirectory
+#include "TKey.h"       // for TKey
+#include "TROOT.h"      // for TROOT, gROOT
 
-#include "TKey.h"
-#include "TROOT.h"
+#include <stdio.h>  // for sprintf
+#include <iostream> // for operator<<, basic_ostream, etc
 
-#include <iostream>
+class TObject;
 
 using std::cout;
 using std::endl;
 
 ClassImp(FairDetParRootFileIo)
 
-FairDetParRootFileIo::FairDetParRootFileIo(FairParRootFile* f)
-  :FairDetParIo(),
-   pFile(f)
-{
+FairDetParRootFileIo::FairDetParRootFileIo(FairParRootFile *f)
+    : FairDetParIo(), pFile(f) {
   // Constructor takes a pointer to the parameter ROOT file
   //  pFile=f;
 }
 
-Bool_t FairDetParRootFileIo::read(FairParSet* pPar)
-{
+Bool_t FairDetParRootFileIo::read(FairParSet *pPar) {
   // generic read function for parameter containers
-  Text_t* name=(char*)pPar->GetName();
-  Int_t version=findInputVersion(name);
-  if (version<=0) {
-    pPar->setInputVersion(-1,inputNumber);
+  Text_t *name = const_cast<char*>(pPar->GetName());
+  Int_t version = findInputVersion(name);
+
+  // cout << "-I- FairDetParRootFileIo#  " << name << " : " << version <<  endl;
+
+  if (version <= 0) {
+    pPar->setInputVersion(-1, inputNumber);
     return kFALSE;
   }
-  if (pPar->getInputVersion(inputNumber)==version
-      && pPar->getInputVersion(inputNumber)!=-1) { return kTRUE; }
-  TKey* key = (TKey*)gDirectory->GetKey(name,version);
-  if(key) {
+
+  if (pPar->getInputVersion(inputNumber) == version &&
+      pPar->getInputVersion(inputNumber) != -1) {
+    return kTRUE;
+  }
+
+  TKey *key = dynamic_cast<TKey *>(gDirectory->GetKey(name, version));
+  if (key) {
     pPar->clear();
     key->Read(pPar);
-    pPar->setInputVersion(version,inputNumber);
+    pPar->setInputVersion(version, inputNumber);
     pPar->setChanged();
-    cout<<"Container "<<pPar->GetName()<<" initialized from ROOT file."<<endl;
+    cout << "Container " << pPar->GetName() << " initialized from ROOT file."
+         << endl;
     return kTRUE;
   }
-  pPar->setInputVersion(-1,inputNumber);
+  pPar->setInputVersion(-1, inputNumber);
   return kFALSE;
 }
 
-Int_t FairDetParRootFileIo::write(FairParSet* pPar)
-{
+Int_t FairDetParRootFileIo::write(FairParSet *pPar) {
   // writes a parameter container to the ROOT file and returns the new version
   // number (returns -1 if the file is not writable)
   if (pFile) {
     pFile->cd();
     if (pFile->IsWritable()) {
-      Text_t* name=(char*)pPar->GetName();
+      Text_t *name = const_cast<char*>(pPar->GetName());
       pPar->Write(name);
       pPar->setChanged(kFALSE);
       FairRuntimeDb::instance()->setVersionsChanged(kTRUE);
       return getMaxVersion(name);
-    } else { Error(":write","Output is not writable"); }
+    } else {
+      Error(":write", "Output is not writable");
+    }
   }
-  Error(":write","No output open");
+  Error(":write", "No output open");
   return -1;
 }
 
-Int_t FairDetParRootFileIo::getMaxVersion(Text_t* name)
-{
+Int_t FairDetParRootFileIo::getMaxVersion(Text_t *name) {
   // returns the maximum version of the container given by name in the ROOT
   // file (return -1 if not found)
-  TKey* key=pFile->GetKey(name);
-  if (key) { return key->GetCycle(); }
-  else { return -1; }
+  TKey *key = pFile->GetKey(name);
+  if (key) {
+    return key->GetCycle();
+  } else {
+    return -1;
+  }
 }
 
-Int_t FairDetParRootFileIo::findInputVersion(Text_t* name)
-{
+Int_t FairDetParRootFileIo::findInputVersion(Text_t *name) {
   // finds the input version to initialize the container given by name;
   // returns -1 if the version cannot be determined
-  FairParVersion* currVers=
-    FairRuntimeDb::instance()->getCurrentRun()->getParVersion(name);
-  Int_t v=currVers->getInputVersion(inputNumber);
-  if (v>0) { return v; }      // predefined
-  FairRtdbRun* r=pFile->getRun();
-  if (!r) { return -1; }        // run not in ROOT file
-  FairParVersion* vers=r->getParVersion(name);
-  if (!vers) { return -1; }     // container not in ROOT file
+  FairParVersion *currVers =
+      FairRuntimeDb::instance()->getCurrentRun()->getParVersion(name);
+  Int_t v = currVers->getInputVersion(inputNumber);
+  if (v > 0) {
+    return v;
+  } // predefined
+  FairRtdbRun *r = pFile->getRun();
+  // cout << "-I- FairDetParRootFileIo::findInputVersion " << r << endl;
+  if (!r) {
+    return -1;
+  } // run not in ROOT file
+  FairParVersion *vers = r->getParVersion(name);
+  if (!vers) {
+    return -1;
+  } // container not in ROOT file
   return vers->getRootVersion();
 }
 
-TObject* FairDetParRootFileIo::findContainer(Text_t* name, Int_t vers)
-{
+TObject *FairDetParRootFileIo::findContainer(Text_t *name, Int_t vers) {
   // finds the parameter container given by its name with a special version in
   // the ROOT file (returns 0 if not successful)
   // This funtion uses internally the ROOT function FindObject(Text_t*), which
   // creates a new object. The calling function must therefore delete the
   // object after usage!
   Text_t cn[80];
-  sprintf(cn,"%s;%i",name,vers);
+  sprintf(cn, "%s;%i", name, vers);
   pFile->cd();
-  TObject* p=gROOT->FindObject(cn);
+  TObject *p = gROOT->FindObject(cn);
   return p;
 }
diff --git a/parbase/FairDetParRootFileIo.h b/parbase/FairDetParRootFileIo.h
index 7d92865..5dbddbe 100644
--- a/parbase/FairDetParRootFileIo.h
+++ b/parbase/FairDetParRootFileIo.h
@@ -1,10 +1,22 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRDETPARROOTFILEIO_H
 #define FAIRDETPARROOTFILEIO_H
 
-#include "FairDetParIo.h"
+#include "FairDetParIo.h"               // for FairDetParIo
+
+#include "Rtypes.h"                     // for Int_t, Text_t, etc
+
+using std::fstream;
 
 class FairParRootFile;
 class FairParSet;
+class TObject;
 
 class FairDetParRootFileIo : public FairDetParIo
 {
diff --git a/parbase/FairGenericParAsciiFileIo.cxx b/parbase/FairGenericParAsciiFileIo.cxx
index 32974c3..2c74b06 100644
--- a/parbase/FairGenericParAsciiFileIo.cxx
+++ b/parbase/FairGenericParAsciiFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
+ *                                                                              *
+ *              This software is distributed under the terms of the *
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3, *
+ *                  copied verbatim in the file "LICENSE" *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 
@@ -11,298 +18,315 @@
 
 #include "FairGenericParAsciiFileIo.h"
 
-#include "FairParGenericSet.h"
-#include "FairParamList.h"
-#include "FairParGenericSet.h"
-//#include "TClass.h"
-#include <iostream>
+#include "FairParGenericSet.h" // for FairParGenericSet
+#include "FairParSet.h"        // for FairParSet
+#include "FairParamList.h"     // for FairParamObj, FairParamList
+
+#include "TCollection.h" // for TIter
+#include "TList.h"       // for TList
+#include "TString.h"     // for TString, operator<<
+
+#include <stdio.h>  // for printf, sscanf
+#include <string.h> // for strcmp, memcpy, strtok, etc
+
 using std::ios;
 
 ClassImp(FairGenericParAsciiFileIo)
 
-FairGenericParAsciiFileIo::FairGenericParAsciiFileIo(fstream* f) : FairDetParAsciiFileIo(f)
-{
+FairGenericParAsciiFileIo::FairGenericParAsciiFileIo(std::fstream *f)
+    : FairDetParAsciiFileIo(f) {
   // constructor
   // sets the name of the I/O class "FairGenericParIo"
   // gets the pointer to the ASCII file
-  fName="FairGenericParIo";
+  fName = "FairGenericParIo";
 }
 
-Bool_t FairGenericParAsciiFileIo::init(FairParSet* pPar)
-{
+Bool_t FairGenericParAsciiFileIo::init(FairParSet *pPar) {
   // initializes the parameter container from ASCII file
-  if (!pFile) { return kFALSE; }
+  if (!pFile) {
+    return kFALSE;
+  }
 
   if (pPar->InheritsFrom("FairParGenericSet")) {
-//      std::cout << "airGenericParAsciiFileIo ##########calling read function " << std::endl;
-    return readGenericSet((FairParGenericSet*)pPar);
+    return readGenericSet(static_cast<FairParGenericSet*>(pPar));
   }
 
-
-  Error("init(FairParSet*)",
-        "%s does not inherit from FairParGenericSet",pPar->GetName());
+  Error("init(FairParSet*)", "%s does not inherit from FairParGenericSet",
+        pPar->GetName());
   return kFALSE;
 }
 
-Int_t FairGenericParAsciiFileIo::write(FairParSet* pPar)
-{
+Int_t FairGenericParAsciiFileIo::write(FairParSet *pPar) {
   // writes the parameter container to ASCII file
-  if (!pFile) { return -1; }
+  if (!pFile) {
+    return -1;
+  }
   if (pPar->InheritsFrom("FairParGenericSet")) {
-    return writeGenericSet((FairParGenericSet*)pPar);
+    return writeGenericSet(static_cast<FairParGenericSet*>(pPar));
   }
-  Error("write(FairParSet*)",
-        "%s does not inherit from FairParGenericSet",pPar->GetName());
+  Error("write(FairParSet*)", "%s does not inherit from FairParGenericSet",
+        pPar->GetName());
   return -1;
 }
 
-template <class type> const UChar_t* FairGenericParAsciiFileIo::readData(
-  type t,const Char_t* format,TString& line, Int_t& length)
-{
+template <class type>
+const UChar_t *FairGenericParAsciiFileIo::readData(type t, const Char_t *format,
+                                                   TString &line,
+                                                   Int_t &length) {
   // reads c-type single data and arrays
-  const Int_t st=sizeof(t);
-  const Int_t maxbuf=8000;
-  const Int_t bufSizeExt=10000*st;
-  const Char_t d[]=" ";
+  const Int_t st = sizeof(t);
+  const Int_t maxbuf = 8000;
+  const Int_t bufSizeExt = 10000 * st;
+  const Char_t d[] = " ";
   Text_t buf[maxbuf];
   TString s;
-  Int_t l=0, bufSize=bufSizeExt;
-  UChar_t* val=new UChar_t[bufSize];
-  Ssiz_t m=line.Last('\\');
-  if (m<0) {
-    sscanf(line.Data(),format,&t);
-    memcpy(&val[l],&t,st);
-    length=st;
+  Int_t l = 0, bufSize = bufSizeExt;
+  UChar_t *val = new UChar_t[bufSize];
+  Ssiz_t m = line.Last('\\');
+  if (m < 0) {
+    sscanf(line.Data(), format, &t);
+    memcpy(&val[l], &t, st);
+    length = st;
   } else {
     do {
-      pFile->getline(buf,maxbuf);
-      if (buf[0]!='/' && buf[0]!='#') {
-        s=buf;
-        m=s.Last('\\');
-        if (m>0) { s=s(0,s.Length()-2); }
-        if ((bufSize-1000)<l) {
-          bufSize+=bufSizeExt;
-          UChar_t* va=new UChar_t[bufSize];
-          memcpy(va,val,l);
-          delete [] val;
-          val=va;
+      pFile->getline(buf, maxbuf);
+      if (buf[0] != '/' && buf[0] != '#') {
+        s = buf;
+        m = s.Last('\\');
+        if (m > 0) {
+          s = s(0, s.Length() - 2);
+        }
+        if ((bufSize - 1000) < l) {
+          bufSize += bufSizeExt;
+          UChar_t *va = new UChar_t[bufSize];
+          memcpy(va, val, l);
+          delete[] val;
+          val = va;
         }
-        Char_t* ss=strtok((Char_t*)s.Data(),d);
-        while (ss!=0) {
-          sscanf(ss,format,&t);
-          memcpy(&val[l],&t,st);
-          l+=st;
-          ss=strtok(NULL,d);
+        Char_t *ss = strtok(const_cast<Char_t*>(s.Data()), d);
+        while (ss != 0) {
+          sscanf(ss, format, &t);
+          memcpy(&val[l], &t, st);
+          l += st;
+          ss = strtok(NULL, d);
         }
       }
-    } while (buf[0]!='#' && !pFile->eof() && m>0);
-    length=l;
+    } while (buf[0] != '#' && !pFile->eof() && m > 0);
+    length = l;
   }
   return val;
 }
 
-template <class type> void FairGenericParAsciiFileIo::writeData(type* val, Int_t nParams)
-{
+template <class type>
+void FairGenericParAsciiFileIo::writeData(type *val, Int_t nParams) {
   // writes c-type arrays
-  Int_t i=0, k=0;
-  while (k<nParams) {
-    if (i==10) {
-      *pFile<<" \\\n  ";
-      i=0;
+  Int_t i = 0, k = 0;
+  while (k < nParams) {
+    if (i == 10) {
+      *pFile << " \\\n  ";
+      i = 0;
     }
-    *pFile<<val[k]<<" ";
+    *pFile << val[k] << " ";
     i++;
     k++;
   }
-  *pFile<<std::endl;
+  *pFile << std::endl;
 }
 
-
-
-Bool_t FairGenericParAsciiFileIo::readGenericSet(FairParGenericSet* pPar)
-{
+Bool_t FairGenericParAsciiFileIo::readGenericSet(FairParGenericSet *pPar) {
   // reads condition-stype parameter containers from ASCII file
-  if (!pFile) { return kFALSE; }
+  if (!pFile) {
+    return kFALSE;
+  }
   pFile->clear();
-  pFile->seekg(0,ios::beg);
-  Text_t* name=(Char_t*)pPar->GetName();
-  if (!findContainer(name)) { return kFALSE; }
-  FairParamList* paramList = new FairParamList;
-  const Int_t maxbuf=8000;
+  pFile->seekg(0, ios::beg);
+  const Text_t *name = (pPar->GetName());
+
+  if (!findContainer(name)) {
+    return kFALSE;
+  }
+  
+
+  FairParamList *paramList = new FairParamList;
+  const Int_t maxbuf = 8000;
   Text_t buf[maxbuf];
-  buf[0]='\0';
+  buf[0] = '\0';
   TString s, pName, pVal, pType;
   Ssiz_t n, m;
-  while (buf[0]!='#' && !pFile->eof()) {
-    pFile->getline(buf,maxbuf);
-    if (buf[0]!='/' && buf[0]!='#') {
-      s=buf;
-      n=s.First(':');
-      if (n==-1) {
+  while (buf[0] != '#' && !pFile->eof()) {
+    pFile->getline(buf, maxbuf);
+    if (buf[0] != '/' && buf[0] != '#') {
+      s = buf;	  
+      n = s.First(':');
+      // <DB> Check if empty buffer  
+      if (s.IsNull()) continue;   
+      if (n == -1) {
         Error("readCond(FairParGenericSet*)",
-              "%s:\n  Missing backslash for parameter %s",name,pName.Data());
+              "%s:\n  Missing backslash for parameter %s", name, pName.Data());
         delete paramList;
-        return  kFALSE;
+        return kFALSE;
       }
-      pName=s(0,n);
-      s=s(n+1,s.Length()-n-1);
-      s=s.Strip(s.kLeading);
-      if (pName.CompareTo("author")==0 || pName.CompareTo("description")==0) {
-        m=s.Last('\\');
-        if (m<=0) {
-          pVal=s;
+      pName = s(0, n);
+      s = s(n + 1, s.Length() - n - 1);
+      s = s.Strip(s.kLeading);
+      if (pName.CompareTo("author") == 0 ||
+          pName.CompareTo("description") == 0) {
+        m = s.Last('\\');
+        if (m <= 0) {
+          pVal = s;
         } else {
-          pVal=s(0,m);
-          pVal+="\n";
-          while (m>0) {
-            pFile->getline(buf,maxbuf);
-            if (buf[0]!='/') {
-              s=buf;
-              m=s.Last('\\');
-              if (m>0) {
-                pVal+=s(0,m);
-                pVal+="\n";
+          pVal = s(0, m);
+          pVal += "\n";
+          while (m > 0) {
+            pFile->getline(buf, maxbuf);
+            if (buf[0] != '/') {
+              s = buf;
+              m = s.Last('\\');
+              if (m > 0) {
+                pVal += s(0, m);
+                pVal += "\n";
               } else {
-                pVal+=s;
+                pVal += s;
               }
             }
           }
         }
-        if (pName.CompareTo("author")==0) {
+        if (pName.CompareTo("author") == 0) {
           pPar->setAuthor(pVal.Data());
-        } else if (pName.CompareTo("description")==0) {
+        } else if (pName.CompareTo("description") == 0) {
           pPar->setDescription(pVal.Data());
         }
       } else {
-        n=s.First(' ');
-        pType=s(0,n);
-        s=s(n+1,s.Length()-n-1);
-        s=s.Strip(s.kLeading);
-        if (pType.CompareTo("Text_t")==0) {
-          m=s.Last('\\');
-          if (m<0) {
-            pVal=s;
+        n = s.First(' ');
+        pType = s(0, n);
+        s = s(n + 1, s.Length() - n - 1);
+        s = s.Strip(s.kLeading);
+        if (pType.CompareTo("Text_t") == 0) {
+          m = s.Last('\\');
+          if (m < 0) {
+            pVal = s;
           } else {
-            pVal="";
-            while (m>=0) {
-              pFile->getline(buf,maxbuf);
-              if (buf[0]!='/') {
-                s=buf;
-                m=s.Last('\\');
-                if (m>0) {
-                  pVal+=s(0,m);
-                  pVal+="\n";
+            pVal = "";
+            while (m >= 0) {
+              pFile->getline(buf, maxbuf);
+              if (buf[0] != '/') {
+                s = buf;
+                m = s.Last('\\');
+                if (m > 0) {
+                  pVal += s(0, m);
+                  pVal += "\n";
                 } else {
-                  pVal+=s;
+                  pVal += s;
                 }
               }
             }
           }
-          pVal=pVal.Strip(pVal.kLeading);
-          if (pVal.Length()>0) {
-            paramList->add(pName.Data(),pVal.Data());
+          pVal = pVal.Strip(pVal.kLeading);
+          if (pVal.Length() > 0) {
+            paramList->add(pName.Data(), pVal.Data());
           }
         } else {
-          const UChar_t* val=0;
-          Int_t length=0;
-          if (pType.CompareTo("Int_t")==0) {
-            Int_t v=0;
-            val=readData(v,"%i",s,length);
-          } else if  (pType.CompareTo("Float_t")==0) {
-            Float_t v=0.F;
-            val=readData(v,"%f",s,length);
-          } else if (pType.CompareTo("Double_t")==0) {
-            Double_t v=0.;
-            val=readData(v,"%lf",s,length);
-          } else if (pType.CompareTo("Char_t")==0) {
-            Char_t v='0';
-            val=readData(v,"%c",s,length);
+          const UChar_t *val = 0;
+          Int_t length = 0;
+          if (pType.CompareTo("Int_t") == 0) {
+            Int_t v = 0;
+            val = readData(v, "%i", s, length);
+          } else if (pType.CompareTo("Float_t") == 0) {
+            Float_t v = 0.F;
+            val = readData(v, "%f", s, length);
+          } else if (pType.CompareTo("Double_t") == 0) {
+            Double_t v = 0.;
+            val = readData(v, "%lf", s, length);
+          } else if (pType.CompareTo("Char_t") == 0) {
+            Char_t v = '0';
+            val = readData(v, "%c", s, length);
           } else {
             Error("readCond(FairParGenericSet*)",
-                  "%s:\n  Parameter %s with unsupported type %s",
-                  name,pName.Data(),pType.Data());
+                  "%s:\n  Parameter %s with unsupported type %s", name,
+                  pName.Data(), pType.Data());
             delete paramList;
             return kFALSE;
           }
-          FairParamObj* obj=new FairParamObj(pName.Data());
+          FairParamObj *obj = new FairParamObj(pName.Data());
           obj->setParamType(pType.Data());
-          UChar_t* pValue=obj->setLength(length);
-          memcpy(pValue,val,length);
+          UChar_t *pValue = obj->setLength(length);
+          memcpy(pValue, val, length);
           paramList->getList()->Add(obj);
-          if (val) { delete [] val; }
+          if (val) {
+            delete[] val;
+          }
         }
       }
     }
   }
-  Bool_t allFound=pPar->getParams(paramList);
+  Bool_t allFound = pPar->getParams(paramList);
   if (allFound) {
-    pPar->setInputVersion(1,inputNumber);
+    pPar->setInputVersion(1, inputNumber);
     pPar->setChanged();
-    printf("%s initialized from Ascii file\n",name);
-  } else { pPar->setInputVersion(-1,inputNumber); }
+    printf("%s initialized from Ascii file\n", name);
+  } else {
+    pPar->setInputVersion(-1, inputNumber);
+  }
   delete paramList;
   return allFound;
 }
 
-
-Int_t FairGenericParAsciiFileIo::writeGenericSet(FairParGenericSet* pPar)
-{
+Int_t FairGenericParAsciiFileIo::writeGenericSet(FairParGenericSet *pPar) {
   // writes condition-stype parameter containers to ASCII file
   if (pFile) {
-    Int_t version=1;
-    const Text_t* name=pPar->GetName();
-    const Text_t* context=pPar->getParamContext();
-    *pFile<<sepLine;
-    *pFile<<"# Class:   "<<name<<"\n# Context: "<<context<<"\n";
-    *pFile<<sepLine;
-    *pFile<<"["<<name<<"]\n";
+    //   Int_t version=1;
+    const Text_t *name = pPar->GetName();
+    const Text_t *context = pPar->getParamContext();
+    *pFile << sepLine;
+    *pFile << "# Class:   " << name << "\n# Context: " << context << "\n";
+    *pFile << sepLine;
+    *pFile << "[" << name << "]\n";
     writeComment(pPar);
-    *pFile<<"//-----------------------------------------------------------"
-          "-----------------\n";
-    FairParamList* paramList = new FairParamList;
+    *pFile << "//-----------------------------------------------------------"
+              "-----------------\n";
+    FairParamList *paramList = new FairParamList;
     pPar->putParams(paramList);
-    TList* pList=paramList->getList();
+    TList *pList = paramList->getList();
     TIter next(pList);
-    FairParamObj* po;
-    while ((po=(FairParamObj*)next())) {
-      const Char_t* pType=po->getParamType();
-      UChar_t* pValue=po->getParamValue();
-      if (po->isBasicType()&&strcmp(pType,"UChar_t")!=0) {
-        if (strcmp(pType,"Text_t")==0) {
-          TString val((Char_t*)pValue,po->getLength());
-          val.ReplaceAll("\n"," \\\n");
-          *pFile<<po->GetName()<<":  "<<pType<<" \\\n  "<<val.Data()<<std::endl;
+    FairParamObj *po;
+    while ((po = static_cast<FairParamObj*>(next()))) {
+      const Char_t *pType = po->getParamType();
+      UChar_t *pValue = po->getParamValue();
+      if (po->isBasicType() && strcmp(pType, "UChar_t") != 0) {
+        if (strcmp(pType, "Text_t") == 0) {
+          TString val(reinterpret_cast<Char_t*>(pValue), po->getLength());
+          val.ReplaceAll("\n", " \\\n");
+          *pFile << po->GetName() << ":  " << pType << " \\\n  " << val.Data()
+                 << std::endl;
         } else {
-          Int_t nParams=po->getNumParams();
-          if (nParams==1) {
-            *pFile<<po->GetName()<<":  "<<pType<<"  ";
+          Int_t nParams = po->getNumParams();
+          if (nParams == 1) {
+            *pFile << po->GetName() << ":  " << pType << "  ";
           } else {
-            *pFile<<po->GetName()<<":  "<<pType<<" \\\n  ";
+            *pFile << po->GetName() << ":  " << pType << " \\\n  ";
           }
-          if (strcmp(pType,"Char_t")==0) {
-            writeData((Char_t*)pValue,nParams);
-          } else if (strcmp(pType,"Int_t")==0) {
-            writeData((Int_t*)pValue,nParams);
-          } else if (strcmp(pType,"Float_t")==0) {
-            writeData((Float_t*)pValue,nParams);
-          } else if (strcmp(pType,"Double_t")==0) {
-            writeData((Double_t*)pValue,nParams);
+          if (strcmp(pType, "Char_t") == 0) {
+            writeData(reinterpret_cast<Char_t*>(pValue), nParams);
+          } else if (strcmp(pType, "Int_t") == 0) {
+            writeData(reinterpret_cast<Int_t*>(pValue), nParams);
+          } else if (strcmp(pType, "Float_t") == 0) {
+            writeData(reinterpret_cast<Float_t*>(pValue), nParams);
+          } else if (strcmp(pType, "Double_t") == 0) {
+            writeData(reinterpret_cast<Double_t*>(pValue), nParams);
           }
         }
       } else {
         Error("writeCond(FairParGenericSet*)",
-              "Type %s of parameter %s not supported by ASCII I/O",
-              pType,po->GetName());
-        version=-1;
+              "Type %s of parameter %s not supported by ASCII I/O", pType,
+              po->GetName());
+        //       version=-1;
       }
     }
-    *pFile<<sepLine;
+    *pFile << sepLine;
     delete paramList;
     pPar->setChanged(kFALSE);
     return 1;
   }
-  Error("writeCond(FairParGenericSet*)",
-        "Output is not writable");
+  Error("writeCond(FairParGenericSet*)", "Output is not writable");
   return -1;
 }
-
diff --git a/parbase/FairGenericParAsciiFileIo.h b/parbase/FairGenericParAsciiFileIo.h
index 10db343..169252e 100644
--- a/parbase/FairGenericParAsciiFileIo.h
+++ b/parbase/FairGenericParAsciiFileIo.h
@@ -1,16 +1,28 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGENERICPARASCIIFILEIO_H
 #define FAIRGENERICPARASCIIFILEIO_H
 
-#include "FairDetParAsciiFileIo.h"
+#include "FairDetParAsciiFileIo.h"      // for FairDetParAsciiFileIo
 
-#include <fstream>
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+
+#include <fstream>                      // for fstream
 
 class FairParGenericSet;
+class FairParSet;
+class TString;
 
 class FairGenericParAsciiFileIo : public FairDetParAsciiFileIo
 {
   public:
-    FairGenericParAsciiFileIo(fstream* f=0);
+    FairGenericParAsciiFileIo(std::fstream* f=0);
     ~FairGenericParAsciiFileIo() {}
     Bool_t init(FairParSet*);
     Int_t write(FairParSet*);
diff --git a/parbase/FairGenericParRootFileIo.cxx b/parbase/FairGenericParRootFileIo.cxx
index 15d85a8..560f3eb 100644
--- a/parbase/FairGenericParRootFileIo.cxx
+++ b/parbase/FairGenericParRootFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 
@@ -10,6 +17,10 @@
 
 #include "FairGenericParRootFileIo.h"
 
+#include "TString.h"                    // for TString
+
+class FairParSet;
+
 ClassImp(FairGenericParRootFileIo)
 
 FairGenericParRootFileIo::FairGenericParRootFileIo(FairParRootFile* f) : FairDetParRootFileIo(f)
diff --git a/parbase/FairGenericParRootFileIo.h b/parbase/FairGenericParRootFileIo.h
index 67a78dc..58de2f9 100644
--- a/parbase/FairGenericParRootFileIo.h
+++ b/parbase/FairGenericParRootFileIo.h
@@ -1,9 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGENERICPARROOTFILEIO_H
 #define FAIRGENERICPARROOTFILEIO_H
 
-#include "FairDetParRootFileIo.h"
+#include "FairDetParRootFileIo.h"       // for FairDetParRootFileIo
+
+#include "Rtypes.h"                    // for ClassDef macro
 
 class FairParRootFile;
+class FairParSet;
 
 class FairGenericParRootFileIo : public FairDetParRootFileIo
 {
diff --git a/parbase/FairParAsciiFileIo.cxx b/parbase/FairParAsciiFileIo.cxx
index 30b6e38..bdb3489 100644
--- a/parbase/FairParAsciiFileIo.cxx
+++ b/parbase/FairParAsciiFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 
@@ -10,19 +17,20 @@
 // It contains pointers to the ascii file and to the interface classes for all
 // detectors defined in the actual setup.
 ///////////////////////////////////////////////////////////////////////////////
-
 #include "FairParAsciiFileIo.h"
 
-#include "FairDetParIo.h"
-#include "FairRuntimeDb.h"
+#include "FairDetParIo.h"               // for FairDetParIo
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "FairLogger.h"
 
-#include "TString.h"
-#include "TObjString.h"
-#include "TList.h"
-#include "TSystem.h"
+#include "TCollection.h"                // for TIter
+#include "TList.h"                      // for TList, TListIter
+#include "TObjString.h"                 // for TObjString
+#include "TString.h"                    // for TString, operator<<
+#include "TSystem.h"                    // for TSystem, gSystem
 
-//#include <cstring>
-#include <iostream>
+#include <string.h>                     // for strcmp, NULL
+#include <iostream>                     // for cout, cerr
 
 using std::cout;
 using std::cerr;
@@ -57,7 +65,7 @@ Bool_t FairParAsciiFileIo::open(const Text_t* fname, const Text_t* status)
         <<"\n  writing state : out\n   reading state : in  \nopen  aborted \n";
     return kFALSE;
   }
-  file=new fstream();
+  file=new std::fstream();
   if(strcmp(status,"in")==0) {file->open( fname, ios::in);};
   if(strcmp(status,"out")==0) {file->open( fname, ios::out);};
   filebuf* buf = file->rdbuf();
@@ -73,15 +81,22 @@ Bool_t FairParAsciiFileIo::open(const Text_t* fname, const Text_t* status)
 
 Bool_t FairParAsciiFileIo::open(const TList* fnamelist, const Text_t* status)
 {
+  TString outFileName = gSystem->WorkingDirectory();
 
-  TString outFileName = "all_";
+  outFileName += "/all_";
   Int_t pid = gSystem->GetPid();
   outFileName += pid;
   outFileName += ".par";
   TString catCommand = "cat ";
   TObjString* string;
   TListIter myIter(fnamelist);
-  while((string = (TObjString*)myIter.Next())) {
+  while((string = static_cast<TObjString*>(myIter.Next()))) {
+    // check if the file exist
+    // if file exist return value is false
+      TString strParPath = string->GetString();
+      gSystem->ExpandPathName(strParPath);
+      if (gSystem->AccessPathName(strParPath))
+        LOG(FATAL) << "Parameter file " << strParPath << " does not exist." << FairLogger::endl;
     //    cout <<  string->GetString() <<endl;
     catCommand += string->GetString();
     catCommand += " ";
@@ -117,14 +132,14 @@ void FairParAsciiFileIo::print()
     TIter next(detParIoList);
     FairDetParIo* io;
     cout<<"detector I/Os: ";
-    while ((io=(FairDetParIo*)next())) {
+    while ((io=static_cast<FairDetParIo*>(next()))) {
       cout<<" "<<io->GetName();
     }
     cout<<'\n';
   } else { cout<<"No file open\n"; }
 }
 
-fstream* FairParAsciiFileIo::getFile()
+std::fstream* FairParAsciiFileIo::getFile()
 {
   // returns the file pointer
   return file;
diff --git a/parbase/FairParAsciiFileIo.h b/parbase/FairParAsciiFileIo.h
index 7c24e0e..0d2344f 100644
--- a/parbase/FairParAsciiFileIo.h
+++ b/parbase/FairParAsciiFileIo.h
@@ -1,16 +1,26 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARASCIFILEIIO_H
 #define FAIRPARASCIFILEIIO_H
 
-#include "FairParIo.h"
+#include "FairParIo.h"                  // for FairParIo
 
-#include <fstream>
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Bool_t, Text_t, etc
+
+#include <fstream>                      // for fstream, etc
 
 class TList;
 
 class FairParAsciiFileIo : public FairParIo
 {
   protected:
-    fstream* file;      // pointer to a file
+    std::fstream* file;      // pointer to a file
   public:
     FairParAsciiFileIo();
 
@@ -40,7 +50,7 @@ class FairParAsciiFileIo : public FairParIo
     // prints information about the file and the detector I/Os
     void print();
 
-    fstream* getFile();
+    std::fstream* getFile();
   private:
     FairParAsciiFileIo(const FairParAsciiFileIo&);
     FairParAsciiFileIo& operator=(const FairParAsciiFileIo&);
diff --git a/parbase/FairParGenericSet.cxx b/parbase/FairParGenericSet.cxx
index b804d49..41960cb 100644
--- a/parbase/FairParGenericSet.cxx
+++ b/parbase/FairParGenericSet.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 28/01/2009
 
@@ -19,16 +26,18 @@
 //                                   not in the list.
 //
 ///////////////////////////////////////////////////////////////////////////
-
 #include "FairParGenericSet.h"
-#include "FairParamList.h"
-#include <iostream>
-#include <iomanip>
-#include "FairDetParIo.h"
-#include "FairParIo.h"
-ClassImp(FairParGenericSet)
 
+#include "FairDetParIo.h"               // for FairDetParIo
+#include "FairParIo.h"                  // for FairParIo
+#include "FairParamList.h"              // for FairParamList
+
+#include "Riosfwd.h"                    // for ostream
+#include "TString.h"                    // for operator<<, TString
 
+#include <iostream>                     // for operator<<, ostream, cout, etc
+
+ClassImp(FairParGenericSet)
 
 Bool_t FairParGenericSet::init(FairParIo* inp)
 {
@@ -46,6 +55,7 @@ Int_t FairParGenericSet::write(FairParIo* output)
   return -1;
 }
 
+
 void FairParGenericSet::printParams()
 {
   // prints information about the container
@@ -62,3 +72,6 @@ void FairParGenericSet::printParams()
   delete condList;
 }
 
+
+
+
diff --git a/parbase/FairParGenericSet.h b/parbase/FairParGenericSet.h
index 25a1ad7..eeab935 100644
--- a/parbase/FairParGenericSet.h
+++ b/parbase/FairParGenericSet.h
@@ -1,17 +1,25 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARGENERICSET_H
 #define FAIRPARGENERICSET_H
 
-#include "FairParSet.h"
+#include "FairParSet.h"                 // for FairParSet
+
+#include "Rtypes.h"                     // for Bool_t, etc
 
-class FairParamList;
-class FairDetParIo;
 class FairParIo;
+class FairParamList;
 
 class FairParGenericSet : public FairParSet
 {
   public:
-    FairParGenericSet(const char* name,const char* title,const char* context)
-      : FairParSet(name,title,context) {}
+    FairParGenericSet(const char* name,const char* title,const char* context, Bool_t ownership=kFALSE)
+      : FairParSet(name,title,context,ownership) {}
     virtual ~FairParGenericSet() {}
     virtual void putParams(FairParamList*)=0;
     virtual Bool_t getParams(FairParamList*)=0;
@@ -20,6 +28,9 @@ class FairParGenericSet : public FairParSet
     Bool_t init(FairParIo* inp);
     Int_t  write(FairParIo* output);
 
+   // DB add on
+    void fill(UInt_t) {};
+    void store(UInt_t) {};
 
   protected:
     FairParGenericSet()
diff --git a/parbase/FairParIo.cxx b/parbase/FairParIo.cxx
index 7c0be4c..5ba88fa 100644
--- a/parbase/FairParIo.cxx
+++ b/parbase/FairParIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 20/10/2004
 
@@ -11,7 +18,12 @@
 
 #include "FairParIo.h"
 
-#include "FairDetParIo.h"
+#include "FairDetParIo.h"               // for FairDetParIo
+
+#include "TCollection.h"                // for TIter
+#include "TList.h"                      // for TList
+
+using namespace std;
 
 ClassImp(FairParIo)
 
@@ -40,7 +52,7 @@ void FairParIo::setDetParIo(FairDetParIo* detParIo)
 {
   // stores pointer of the input/output class for a detector
   // used for I/O from ROOT file or Ascii file
-  Text_t* detName=(char*)detParIo->GetName();
+  const Text_t* detName=detParIo->GetName();
   if (!detParIoList->FindObject(detName)) { detParIoList->Add(detParIo); }
 }
 
@@ -49,7 +61,7 @@ void FairParIo::setInputNumber(Int_t num)
   // sets in all detector I/Os the number of the input
   TIter next(detParIoList);
   FairDetParIo* io;
-  while ((io=(FairDetParIo*)next())) {
+  while ((io=static_cast<FairDetParIo*>(next()))) {
     io->setInputNumber(num);
   }
 }
@@ -57,7 +69,8 @@ void FairParIo::setInputNumber(Int_t num)
 FairDetParIo* FairParIo::getDetParIo(const Text_t* detName)
 {
   // returns pointer to input/output class for a detector
-  return ((FairDetParIo*)detParIoList->FindObject(detName));
+  //std::cout << " DetParIO # " << detName << detParIoList->GetEntries()  <<  std::endl;
+  return (static_cast<FairDetParIo*>(detParIoList->FindObject(detName)));
 }
 
 void FairParIo::removeDetParIo(Text_t* detName)
diff --git a/parbase/FairParIo.h b/parbase/FairParIo.h
index 831c2ba..9a212df 100644
--- a/parbase/FairParIo.h
+++ b/parbase/FairParIo.h
@@ -1,11 +1,21 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARIO_H
 #define FAIRPARIO_H
 
-#include "TObject.h"
-#include "TList.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Bool_t, Text_t, etc
+#include "TString.h"                    // for TString
 
 class FairDetParIo;
 class FairRtdbRun;
+class TList;
 
 class FairParIo : public TObject
 {
diff --git a/parbase/FairParRootFileIo.cxx b/parbase/FairParRootFileIo.cxx
index 449f2c1..ccdf031 100644
--- a/parbase/FairParRootFileIo.cxx
+++ b/parbase/FairParRootFileIo.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 21/10/2004
 //*-- Modified: 21/06/2005  Denis bertini
@@ -15,29 +22,21 @@
 // It contains also a list of detector interface classes all having the common
 // base type FairDetParRootFileIo. Every detector has its own interface class.
 //////////////////////////////////////////////////////////////////////////////
-
-
 #include "FairParRootFileIo.h"
-
-#include "FairDetParIo.h"
-#include "FairRuntimeDb.h"
-#include "FairRtdbRun.h"
-
-//#include "TDirectory.h"
-//#include "TROOT.h"
-
-#include <TKey.h>
-#include <TObjString.h>
-#include <TFileMerger.h>
-
-//#include <fstream>
-//#include "stdio.h"
-#include <iostream>
-//#include <iomanip>
-
-#ifdef XROOTD
- #include "TXNetFile.h"
-#endif
+#include "FairDetParIo.h"               // for FairDetParIo
+#include "FairRtdbRun.h"                // for FairRtdbRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "Riosfwd.h"                    // for ostream, fstream
+#include "TCollection.h"                // for TIter
+#include "TDatime.h"                    // for TDatime
+#include "TKey.h"                       // for TKey
+#include "TList.h"                      // for TListIter, TList
+#include "TObject.h"                    // for TObject
+#include "TObjString.h"                 // for TObjString
+#include "TString.h"                    // for TString, Form
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 using std::cout;
 using std::cerr;
@@ -50,17 +49,13 @@ ClassImp(FairParRootFileIo)
 FairParRootFile::FairParRootFile(const Text_t* fname, Option_t* option,
                                  const Text_t* ftitle, Int_t compress)
   :TNamed(fname,  ftitle),
-   run(NULL)
-   //RootFile(new TFile(fname,option,ftitle,compress))
+   run(NULL),
+   RootFile(new TFile(fname,option,ftitle,compress))
 {
 //              : TFile(fname,option,ftitle,compress) {
   // constructor opens a ROOT file
   //  RootFile=new TFile(fname,option,ftitle,compress);
   //run=0;
-    RootFile = new TFile(fname,option,ftitle,compress);
-    #ifdef XROOTD
-     if (!RootFile->IsOpen()) RootFile = new TXNetFile(fname,option,ftitle,compress);
-    #endif
 }
 //--------------------------------------------------------------------
 
@@ -98,7 +93,9 @@ void FairParRootFile::readVersions(FairRtdbRun* currentRun)
   if (run) {
     delete run;
   }
-  run=(FairRtdbRun*)RootFile->Get(((char*)currentRun->GetName()));
+
+  run=static_cast<FairRtdbRun*>(RootFile->Get((const_cast<char*>(currentRun->GetName()))));
+  //cout << "-I- FairParRootFile :: readversions " << currentRun->GetName() << " : " << run << endl;
 }
 //--------------------------------------------------------------------
 
@@ -147,7 +144,7 @@ Bool_t FairParRootFileIo::open(const Text_t* fname, Option_t* option,
   close();
   if (fMerging ) {
     // used test merging
-    fstream* f = new fstream(fname);
+    std::fstream* f = new std::fstream(fname);
     if (f->good()) {
       // check if file already exists
       option = "UPDATE";
@@ -179,7 +176,7 @@ Bool_t FairParRootFileIo::open(const TList* fnamelist, Option_t* option,
 {
   TDatime currentDate;
   TString newParFileName = "";
-  TFile*  newParFile;
+  TFile*  newParFile=0;
 
   TObjString* string;
   TListIter myIter(fnamelist);
@@ -189,7 +186,7 @@ Bool_t FairParRootFileIo::open(const TList* fnamelist, Option_t* option,
   TFile*  inFile;
 
   Int_t nofFiles = 0;
-  while((string = (TObjString*)myIter.Next())) {
+  while((string = static_cast<TObjString*>(myIter.Next()))) {
     inFile = TFile::Open(string->GetString().Data());
     if ( !inFile ) {
       cout << "-W- File \"" << string->GetString().Data() << "\" does not exist" << endl;
@@ -200,17 +197,17 @@ Bool_t FairParRootFileIo::open(const TList* fnamelist, Option_t* option,
       newParFileName = string->GetString();
       newParFileName.Replace(newParFileName.Last('/')+1,
                              newParFileName.Length(),"");
-      newParFileName = Form("%sallParams_%d_%d.root",
+      newParFileName = Form("%sallParams_%d_%06d.root",
                             newParFileName.Data(),
                             currentDate.GetDate(),
                             currentDate.GetTime());
       newParFile = new TFile(newParFileName.Data(),"RECREATE");
     }
 
-    TList* inputKeys = (TList*)inFile->GetListOfKeys();
+    TList* inputKeys = static_cast<TList*>(inFile->GetListOfKeys());
 
     TListIter keyIter(inputKeys);
-    while((inpKey = (TKey*)keyIter.Next())) {
+    while((inpKey = static_cast<TKey*>(keyIter.Next()))) {
       TObject* tempObj = inFile->Get(inpKey->GetName());
 
       newParFile->cd();
@@ -220,8 +217,11 @@ Bool_t FairParRootFileIo::open(const TList* fnamelist, Option_t* option,
 
     nofFiles++;
   }
-  newParFile->Close();
-
+  if(newParFile!=0){
+    newParFile->Close();
+  }else{
+    std::cout << "****NO file to close file = \"" << std::endl;
+  }
   std::cout << "**** merged file = \"" << newParFileName.Data() << "\"" << std::endl;
 
   return this->open(newParFileName,option,ftitle,compress);
@@ -269,7 +269,7 @@ void FairParRootFileIo::print()
     FairDetParIo* io;
     cout<<"Root file I/O "<<file->GetName()<<" is open\n";
     cout<<"detector I/Os: ";
-    while ((io=(FairDetParIo*)next())) {
+    while ((io=static_cast<FairDetParIo*>(next()))) {
       cout<<" "<<io->GetName();
     }
     cout<<'\n';
diff --git a/parbase/FairParRootFileIo.h b/parbase/FairParRootFileIo.h
index c5086ef..8d5edbe 100644
--- a/parbase/FairParRootFileIo.h
+++ b/parbase/FairParRootFileIo.h
@@ -1,13 +1,25 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARROOTFILEIO_H
 #define FAIRPARROOTFILEIO_H
 
-#include "FairParIo.h"
+#include "FairParIo.h"                  // for FairParIo
 
-#include "TNamed.h"
-#include "TFile.h"
-#include "TList.h"
+#include "Rtypes.h"                     // for Bool_t, Text_t, Int_t, etc
+#include "TFile.h"                      // for TFile
+#include "TNamed.h"                     // for TNamed
+
+#include <fstream>
+using std::fstream;
 
 class FairRtdbRun;
+class TKey;
+class TList;
 
 class FairParRootFile : public TNamed
 {
diff --git a/parbase/FairParSet.cxx b/parbase/FairParSet.cxx
index 3cc03c9..3e7c2f0 100644
--- a/parbase/FairParSet.cxx
+++ b/parbase/FairParSet.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 20/10/2004
 
@@ -6,22 +13,28 @@
 //
 //  Base class for all parameter containers
 /////////////////////////////////////////////////////////////
-
 #include "FairParSet.h"
 
-#include "FairRuntimeDb.h"
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+
+#include "Riosfwd.h"                    // for ostream
 
-#include <iostream>
+#include <iostream>                     // for operator<<, ostream, etc
 
 using std::cout;
 
 ClassImp(FairParSet)
 
-FairParSet::FairParSet(const char* name,const char* title,const char* context)
-  : TNamed(name,title),
+FairParSet::FairParSet(const char* name,const char* title,const char* context, Bool_t owner)
+  : TObject(),
+    fName(name),
+    fTitle(title),
     detName(""),
+    versions(),
     status(kFALSE),
     changed(kFALSE),
+    owned(owner),
     paramContext(context),
     author(""),
     description(""),
@@ -52,7 +65,7 @@ Bool_t FairParSet::init()
     } else { setInputVersion(-1,2); }
   }
   if (allFound) { return kTRUE; }
-  fLogger->Error(MESSAGE_ORIGIN, "init() %s  not initialized",GetName());
+  if (fLogger ) { fLogger->Error(MESSAGE_ORIGIN, "init() %s  not initialized",GetName()); }
   return kFALSE;
 }
 
@@ -64,7 +77,7 @@ Int_t FairParSet::write()
   // (calls internally the init function in the derived class)
   FairParIo* output=FairRuntimeDb::instance()->getOutput();
   if (output) { return write(output); }
-  fLogger->Error(MESSAGE_ORIGIN,"write() %s could not be written to output",GetName());
+  if (fLogger) { fLogger->Error(MESSAGE_ORIGIN,"write() %s could not be written to output",GetName()); }
   return -1;
 }
 
@@ -91,3 +104,59 @@ void FairParSet::resetInputVersions()
     changed=kFALSE;
   }
 }
+
+FairParSet::FairParSet(const FairParSet& from)
+  : TObject(from),
+    fName(from.fName),
+    fTitle(from.fTitle),
+    detName(from.detName),
+    versions(),
+    status(from.status),
+    changed(from.changed),
+    owned(from.owned),
+    paramContext(from.paramContext),
+    author(from.author),
+    description(from.description),
+    fLogger(FairLogger::GetLogger())
+
+{
+/*
+ fName    = from.fName;
+ fTitle   = from.fTitle;
+ detName  = from.detName;
+*/
+ for (Int_t i=0;i<3;i++) versions[i] = from.versions[i];
+/*
+ status   = from.status;
+ changed  = from.changed;
+ owned    = from.owned;
+ paramContext = from.paramContext;
+ author       = from.author;
+ description  = from.description; 
+ fLogger      = from.fLogger;
+*/
+}
+
+
+FairParSet& FairParSet::operator=(const FairParSet& from)
+{
+  if (this == &from) {return *this;}
+  
+ TObject::operator=(from);  
+ fName    = from.fName;
+ fTitle   = from.fTitle;
+ detName  = from.detName;
+ for (Int_t i=0;i<3;i++) versions[i] = from.versions[i];
+ status   = from.status;
+ changed  = from.changed;
+ owned    = from.owned;
+ paramContext = from.paramContext;
+ author       = from.author;
+ description  = from.description; 
+ fLogger      = from.fLogger;
+ 
+ return *this;
+}
+
+
+
diff --git a/parbase/FairParSet.h b/parbase/FairParSet.h
index 2a93650..3193fca 100644
--- a/parbase/FairParSet.h
+++ b/parbase/FairParSet.h
@@ -1,33 +1,50 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARSET_H
 #define FAIRPARSET_H
 
-#include "FairLogger.h"
 #include "TNamed.h"
-//#include "TArrayI.h"
+#include "Rtypes.h"                     // for Int_t, Bool_t, etc
+#include "TString.h"                    // for TString
 
+class FairLogger;
 class FairParIo;
 
-class FairParSet : public TNamed
+class FairParSet : public TObject
 {
   protected:
+    TString fName;         //
+    TString fTitle;        //
     TString detName;         //! name of the detector the container belongs to
     Int_t versions[3];       //! versions of container in the 2 possible inputs
     Bool_t status;           //! static flag
     Bool_t changed;          //! flag is kTRUE if parameters have changed
+    Bool_t  owned;          //! if flag is KTRUE FairDB has the par. class ownership
     TString paramContext;    // Context/purpose for parameters and conditions
     TString author;          // Author of parameters
     TString description ;    // Description of parameters
     /** Fair Logger */
     FairLogger*  fLogger;  //!
+
   public:
-    FairParSet(const char* name="",const char* title="",const char* context="");
+    FairParSet(const char* name="",const char* title="",const char* context="", Bool_t owner=kFALSE);
     virtual ~FairParSet() {}
+
+    virtual const char* GetName() const {return static_cast<const char*>(fName.Data());}
+    virtual const char* GetTitle() const {return static_cast<const char*>(fTitle.Data());}
+
     virtual Bool_t init();
-    virtual Bool_t init(FairParIo* io) { return kFALSE; }
+    virtual Bool_t init(FairParIo*) { return kFALSE; }
     virtual Int_t write();
     virtual Int_t write(FairParIo*) { return kFALSE; }
     virtual void clear() {}
     virtual void print();
+
     const char* getDetectorName() {return detName.Data();}
     void resetInputVersions();
 
@@ -38,8 +55,13 @@ class FairParSet : public TNamed
       if (i>=0 && i<3) { return versions[i]; }
       else { return 0; }
     }
+
     void setStatic(Bool_t flag=kTRUE) {status=flag;}
     Bool_t isStatic() {return status;}
+
+    void setOwnership(Bool_t flag=kTRUE) {owned=flag;}
+    Bool_t isOwned() {return owned;}
+
     void setChanged(Bool_t flag=kTRUE) {changed=flag;}
     Bool_t hasChanged() {return changed;}
 
@@ -56,12 +78,15 @@ class FairParSet : public TNamed
       description=r.getDescription();
     }
 
-  private:
+
+    virtual void fill(UInt_t) {};
+    virtual void store(UInt_t) {};
+    
 
     FairParSet& operator=(const FairParSet&);
     FairParSet(const FairParSet&);
 
-    ClassDef(FairParSet,1) // Base class for all parameter containers
+    ClassDef(FairParSet,2) // Base class for all parameter containers
 };
 
 #endif  /* !FAIRPARSET_H */
diff --git a/parbase/FairParamList.cxx b/parbase/FairParamList.cxx
index 7bfcad9..b771764 100644
--- a/parbase/FairParamList.cxx
+++ b/parbase/FairParamList.cxx
@@ -1,21 +1,30 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Last modified : 28/01/2009 by Ilse Koenig
 
 #include "FairParamList.h"
-#include "FairLogger.h"
 
-#include "TClass.h"
-#include "TStreamerInfo.h"
-#include "RVersion.h"
-#include "TBuffer.h"
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
 
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
-#include "TBufferFile.h"
-#endif
+#include "Riosfwd.h"                    // for ostream
+#include "TArrayD.h"                    // for TArrayD
+#include "TArrayF.h"                    // for TArrayF
+#include "TArrayI.h"                    // for TArrayI
+#include "TBuffer.h"                    // for TBuffer, etc
+#include "TBufferFile.h"                // for TBufferFile
+#include "TClass.h"                     // for TClass
+#include "TCollection.h"                // for TIter
+#include "TStreamerInfo.h"              // for TStreamerInfo
 
-#include <iostream>
-#include <iomanip>
-#include <stdlib.h>
+#include <stdlib.h>                     // for NULL
+#include <string.h>                     // for memcpy, strcmp, strlen
+#include <iostream>                     // for operator<<, ostream, cout, etc
 
 //_HADES_CLASS_DESCRIPTION
 /////////////////////////////////////////////////////////////////////////////////////////
@@ -114,6 +123,7 @@ FairParamObj::FairParamObj(FairParamObj& o)
   paramValue=new UChar_t[arraySize];
   memcpy(paramValue,o.getParamValue(),arraySize);
   if (streamerInfoSize>0) {
+    streamerInfo = new UChar_t[streamerInfoSize];
     memcpy(streamerInfo,o.getStreamerInfo(),streamerInfoSize);
   }
 }
@@ -134,6 +144,38 @@ FairParamObj::FairParamObj(const Text_t* name,Int_t value)
   memcpy(paramValue,&value,arraySize);
 }
 
+FairParamObj::FairParamObj(const Text_t* name,Bool_t value)
+  :TNamed(name,""),
+   paramValue(NULL),
+   arraySize(sizeof(Bool_t)),
+   paramType("Bool_t"),
+   basicType(kTRUE),
+   bytesPerValue(sizeof(Bool_t)),
+   classVersion(-1),
+   streamerInfo(NULL),
+   streamerInfoSize(0)
+{
+  // Constructor for a Int_t value
+  paramValue=new UChar_t[arraySize];
+  memcpy(paramValue,&value,arraySize);
+}
+
+FairParamObj::FairParamObj(const Text_t* name,UInt_t value)
+  :TNamed(name,""),
+   paramValue(NULL),
+   arraySize(sizeof(UInt_t)),
+   paramType("UInt_t"),
+   basicType(kTRUE),
+   bytesPerValue(sizeof(UInt_t)),
+   classVersion(-1),
+   streamerInfo(NULL),
+   streamerInfoSize(0)
+{
+  // Constructor for a Int_t value
+  paramValue=new UChar_t[arraySize];
+  memcpy(paramValue,&value,arraySize);
+}
+
 FairParamObj::FairParamObj(const Text_t* name,Float_t value)
   :TNamed(name,""),
    paramValue(NULL),
@@ -182,6 +224,22 @@ FairParamObj::FairParamObj(const Text_t* name,const Int_t* value,const Int_t nVa
   memcpy(paramValue,value,arraySize);
 }
 
+FairParamObj::FairParamObj(const Text_t* name,const UInt_t* value,const Int_t nValues)
+:TNamed(name,""),
+paramValue(NULL),
+arraySize(sizeof(UInt_t)*nValues),
+paramType("UInt_t"),
+basicType(kTRUE),
+bytesPerValue(sizeof(UInt_t)),
+classVersion(-1),
+streamerInfo(NULL),
+streamerInfoSize(0)
+{
+   // Constructor for an array with nValues elements of type UInt_t
+   paramValue=new UChar_t[arraySize];
+   memcpy(paramValue,value,arraySize);
+}
+
 
 FairParamObj::FairParamObj(const Text_t* name,const Float_t* value,const Int_t nValues)
   :TNamed(name,""),
@@ -227,7 +285,7 @@ FairParamObj::FairParamObj(const Text_t* name,const Text_t* value)
    streamerInfoSize(0)
 {
   // Constructor for a string value
-  paramValue=new UChar_t[arraySize];
+  paramValue=new UChar_t[arraySize+1];
   memcpy(paramValue,value,arraySize);
 }
 
@@ -374,7 +432,7 @@ void FairParamObj::print()
     std::cout<<"\n  Class Type:    "<<paramType.Data()<<"\n  Class Version: "
              <<classVersion<<std::endl;
   } else if (strcmp(paramType,"Text_t")==0) {
-    TString val((Char_t*)paramValue,arraySize);
+    TString val(reinterpret_cast<Char_t*>(paramValue),arraySize);
     val.ReplaceAll("\n","\n  ");
     std::cout<<paramType<<"\n  "<<val.Data()<<std::endl;
   } else {
@@ -385,16 +443,16 @@ void FairParamObj::print()
       std::cout<<paramType<<" array, nValues: "<<nParams<<"\n  ";
     }
     if (strcmp(paramType,"Char_t")==0) {
-      Char_t* val=(Char_t*)paramValue;
+      Char_t* val=reinterpret_cast<Char_t*>(paramValue);
       printData(val,nParams);
     } else if (strcmp(paramType,"Int_t")==0) {
-      Int_t* val=(Int_t*)paramValue;
+      Int_t* val=reinterpret_cast<Int_t*>(paramValue);
       printData(val,nParams);
     } else if (strcmp(paramType,"Float_t")==0) {
-      Float_t* val=(Float_t*)paramValue;
+      Float_t* val=reinterpret_cast<Float_t*>(paramValue);
       printData(val,nParams);
     } else if (strcmp(paramType,"Double_t")==0) {
-      Double_t* val=(Double_t*)paramValue;
+      Double_t* val=reinterpret_cast<Double_t*>(paramValue);
       printData(val,nParams);
     } else {
       std::cout<<"Type: "<<paramType<<"  Array  length: "<<arraySize<<std::endl;
@@ -462,6 +520,19 @@ void FairParamList::add(const Text_t* name,const Int_t value)
   paramList->Add(new FairParamObj(name,value));
 }
 
+void FairParamList::add(const Text_t* name,const Bool_t value)
+{
+  // Adds a parameter of type Int_t to the list
+  paramList->Add(new FairParamObj(name,value));
+}
+
+void FairParamList::add(const Text_t* name,const UInt_t value)
+{
+   // Adds a parameter of type UInt_t to the list
+   paramList->Add(new FairParamObj(name,value));
+}
+
+
 void FairParamList::add(const Text_t* name,const Float_t value)
 {
   // Adds a parameter of type Float_t to the list
@@ -535,11 +606,7 @@ void FairParamList::addObject(const Text_t* name,TObject* obj)
   gFile=paramFile;
   const Int_t bufsize=10000;
 
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
   TBufferFile* buffer=new TBufferFile(TBuffer::kWrite,bufsize);
-#else
-  TBuffer* buffer=new TBuffer(TBuffer::kWrite,bufsize);
-#endif
 
   buffer->SetParent(paramFile);
   buffer->MapObject(obj);
@@ -547,13 +614,13 @@ void FairParamList::addObject(const Text_t* name,TObject* obj)
   Int_t len=buffer->Length();
   Char_t* buf=new char[len];
   memcpy(buf,buffer->Buffer(),len);
-  o->setParamValue((UChar_t*)buf,len);
+  o->setParamValue(reinterpret_cast<UChar_t*>(buf),len);
   TArrayC* fClassIndex=paramFile->GetClassIndex();
   if (fClassIndex&&fClassIndex->fArray[0] != 0) {
     TIter next(gROOT->GetListOfStreamerInfo());
     TStreamerInfo* info;
     TList list;
-    while ((info=(TStreamerInfo*)next())) {
+    while ((info=static_cast<TStreamerInfo*>(next()))) {
       Int_t uid=info->GetNumber();
       if (fClassIndex->fArray[uid]) { list.Add(info); }
     }
@@ -561,18 +628,14 @@ void FairParamList::addObject(const Text_t* name,TObject* obj)
       list.Sort();
       fClassIndex->fArray[0]=2; //to prevent adding classes in TStreamerInfo::TagFile
 
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
       TBufferFile* infoBuffer=new TBufferFile(TBuffer::kWrite,bufsize);
-#else
-      TBuffer* infoBuffer=new TBuffer(TBuffer::kWrite,bufsize);
-#endif
 
       infoBuffer->MapObject(&list);
       list.Streamer(*infoBuffer);
       Int_t infolen=infoBuffer->Length();
       Char_t* infobuf=new char[infolen];
       memcpy(infobuf,infoBuffer->Buffer(),infolen);
-      o->setStreamerInfo((UChar_t*)infobuf,infolen);
+      o->setStreamerInfo(reinterpret_cast<UChar_t*>(infobuf),infolen);
       delete infoBuffer;
     } else {
       o->setStreamerInfo(0,0);
@@ -590,18 +653,18 @@ void FairParamList::print()
   // Prints the parameter list including values
   TIter next(paramList);
   FairParamObj* o;
-  while ((o=(FairParamObj*)next())!=0) { o->print(); }
+  while ((o=static_cast<FairParamObj*>(next()))!=0) { o->print(); }
 }
 
 Bool_t FairParamList::fill(const Text_t* name,Text_t* value,const Int_t length)
 {
   // Copies the data from the list object into the parameter value of type string
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (value==0) { return kFALSE; }
   if (o!=0 && strcmp(o->getParamType(),"Text_t")==0) {
     Int_t l=o->getLength();
     if (l<length-1) {
-      memcpy(value,(Char_t*)o->getParamValue(),l);
+      memcpy(value,reinterpret_cast<Char_t*>(o->getParamValue()),l);
       value[l]='\0';
       return kTRUE;
     } else {
@@ -620,7 +683,7 @@ Bool_t FairParamList::fill(const Text_t* name,UChar_t* values,const Int_t nValue
   // The function returns an error, if the array size of the list object is not equal
   // to nValues.
   if (values==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"UChar_t")==0) {
     Int_t n=o->getLength();
     if (n==nValues) {
@@ -643,7 +706,7 @@ Bool_t FairParamList::fill(const Text_t* name,Int_t* values,const Int_t nValues)
   // The function returns an error, if the array size of the list object is not equal
   // to nValues.
   if (values==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Int_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -661,13 +724,63 @@ Bool_t FairParamList::fill(const Text_t* name,Int_t* values,const Int_t nValues)
   return kFALSE;
 }
 
+Bool_t FairParamList::fill(const Text_t* name,Bool_t* values,const Int_t nValues)
+{
+  // Copies the data from the list object into the parameter array of type Int_t.
+  // The function returns an error, if the array size of the list object is not equal
+  // to nValues.
+  if (values==0) { return kFALSE; }
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
+  if (o!=0 && strcmp(o->getParamType(),"Bool_t")==0) {
+    Int_t l=o->getLength();
+    Int_t n=o->getNumParams();
+    if (n==nValues) {
+      memcpy(values,o->getParamValue(),l);
+      return kTRUE;
+    } else {
+      fLogger->Error(MESSAGE_ORIGIN,"Different array sizes for parameter %s",name);
+      //      Error("FairParamList::fill \nDifferent array sizes for parameter %s",name);
+      return kFALSE;
+    }
+  }
+  fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
+  //  Error("FairParamList::fill \nNot found: %s",name);
+  return kFALSE;
+}
+
+
+Bool_t FairParamList::fill(const Text_t* name,UInt_t* values,const Int_t nValues)
+{
+   // Copies the data from the list object into the parameter array of type UInt_t.
+   // The function returns an error, if the array size of the list object is not equal
+   // to nValues.
+   if (values==0) { return kFALSE; }
+   FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
+   if (o!=0 && strcmp(o->getParamType(),"Int_t")==0) {
+      Int_t l=o->getLength();
+      Int_t n=o->getNumParams();
+      if (n==nValues) {
+         memcpy(values,o->getParamValue(),l);
+         return kTRUE;
+      } else {
+         fLogger->Error(MESSAGE_ORIGIN,"Different array sizes for parameter %s",name);
+         //      Error("FairParamList::fill \nDifferent array sizes for parameter %s",name);
+         return kFALSE;
+      }
+   }
+   fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
+   //  Error("FairParamList::fill \nNot found: %s",name);
+   return kFALSE;
+}
+
+
 Bool_t FairParamList::fill(const Text_t* name,Float_t* values,const Int_t nValues)
 {
   // Copies the data from the list object into the parameter array of type Float_t.
   // The function returns an error, if the array size of the list object is not equal
   // to nValues.
   if (values==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Float_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -691,7 +804,7 @@ Bool_t FairParamList::fill(const Text_t* name,Double_t* values,const Int_t nValu
   // The function returns an error, if the array size of the list object is not equal
   // to nValues.
   if (values==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Double_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -714,7 +827,7 @@ Bool_t FairParamList::fill(const Text_t* name,TArrayI* value)
   // Copies the data from the list object into the parameter value of type TArrayI
   // The array is resized, if the number of data is different.
   if (value==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Int_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -732,7 +845,7 @@ Bool_t FairParamList::fill(const Text_t* name,TArrayC* value)
   // Copies the data from the list object into the parameter value of type TArrayC
   // The array is resized, if the number of data is different.
   if (value==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Char_t")==0) {
     Int_t l=o->getLength();
     if (value->GetSize()!=l) { value->Set(l); }
@@ -749,7 +862,7 @@ Bool_t FairParamList::fill(const Text_t* name,TArrayF* value)
   // Copies the data from the list object into the parameter value of type TArrayF
   // The array is resized, if the number of data is different.
   if (value==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Float_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -767,7 +880,7 @@ Bool_t FairParamList::fill(const Text_t* name,TArrayD* value)
   // Copies the data from the list object into the parameter value of type TArrayD
   // The array is resized, if the number of data is different.
   if (value==0) { return kFALSE; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),"Double_t")==0) {
     Int_t l=o->getLength();
     Int_t n=o->getNumParams();
@@ -780,84 +893,13 @@ Bool_t FairParamList::fill(const Text_t* name,TArrayD* value)
   return kFALSE;
 }
 
-Int_t FairParamList::replace(const Text_t* name,UChar_t* values)
-{
-  // Copies the data from the list object into the parameter array of type UChar_t.
-  // Recreates the array, if existing, and returns the number of array elements.
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
-  if (o!=0 && strcmp(o->getParamType(),"UChar_t")==0) {
-    Int_t l=o->getLength();
-    if (values) { delete values; }
-    values=new UChar_t[l];
-    memcpy(values,o->getParamValue(),l);
-    return l;
-  }
-  fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
-  //  Error("FairParamList::fill \nNot found: %s",name);
-  return 0;
-}
-
-Int_t FairParamList::replace(const Text_t* name,Int_t* values)
-{
-  // Copies the data from the list object into the parameter array of type Int_t.
-  // Recreates the array, if existing, and returns the number of array elements.
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
-  if (o!=0 && strcmp(o->getParamType(),"Int_t")==0) {
-    Int_t l=o->getLength();
-    Int_t n=o->getNumParams();
-    if (values) { delete values; }
-    values=new Int_t[n];
-    memcpy(values,o->getParamValue(),l);
-    return n;
-  }
-  fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
-  //  Error("FairParamList::fill \nNot found: %s",name);
-  return 0;
-}
-
-Int_t FairParamList::replace(const Text_t* name,Float_t* values)
-{
-  // Copies the data from the list object into the parameter array of type Float_t.
-  // Recreates the array, if existing, and returns the number of array elements.
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
-  if (o!=0 && strcmp(o->getParamType(),"Float_t")==0) {
-    Int_t l=o->getLength();
-    Int_t n=o->getNumParams();
-    if (values) { delete values; }
-    values=new Float_t[n];
-    memcpy(values,o->getParamValue(),l);
-    return n;
-  }
-  fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
-  //  Error("FairParamList::fill \nNot found: ",name);
-  return 0;
-}
-
-Int_t FairParamList::replace(const Text_t* name,Double_t* values)
-{
-  // Copies the data from the list object into the parameter array of type Double_t.
-  // Recreates the array, if existing, and returns the number of array elements.
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
-  if (o!=0 && strcmp(o->getParamType(),"Double_t")==0) {
-    Int_t l=o->getLength();
-    Int_t n=o->getNumParams();
-    if (values) { delete values; }
-    values=new Double_t[n];
-    memcpy(values,o->getParamValue(),l);
-    return n;
-  }
-  fLogger->Error(MESSAGE_ORIGIN,"Could not find parameter %s", name);
-  //  Error("FairParamList::fill \nNot found: %s",name);
-  return 0;
-}
-
 Bool_t FairParamList::fillObject(const Text_t* name,TObject* obj)
 {
   // Fills the object obj (must exist!) via the Streamer and returns the class version.
   // Prints a warning if the class version in the list objects differs from the actual
   // class version.
   if (!obj) { return 0; }
-  FairParamObj* o=(FairParamObj*)paramList->FindObject(name);
+  FairParamObj* o=static_cast<FairParamObj*>(paramList->FindObject(name));
   if (o!=0 && strcmp(o->getParamType(),obj->IsA()->GetName())==0) {
     if (o->getClassVersion()!=obj->IsA()->GetClassVersion()) {
       fLogger->Warning(MESSAGE_ORIGIN,"Read Class Version = %i does not match actual version = %i",o->getClassVersion(),obj->IsA()->GetClassVersion());
@@ -867,20 +909,12 @@ Bool_t FairParamList::fillObject(const Text_t* name,TObject* obj)
     //              o->getClassVersion(),obj->IsA()->GetClassVersion());
     TFile* filesave=gFile;
     gFile=0;
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
     TBufferFile* buf=0;
-#else
-    TBuffer* buf=0;
-#endif
 
     Int_t len=o->getStreamerInfoSize();
     if (len>0&&o->getStreamerInfo()!=0) {
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
       buf=new TBufferFile(TBuffer::kRead,len);
-#else
-      buf=new TBuffer(TBuffer::kRead,len);
-#endif
-      memcpy(buf->Buffer(),(Char_t*)o->getStreamerInfo(),len);
+      memcpy(buf->Buffer(),reinterpret_cast<Char_t*>(o->getStreamerInfo()),len);
       buf->SetBufferOffset(0);
       TList list;
       buf->MapObject(&list);
@@ -888,7 +922,7 @@ Bool_t FairParamList::fillObject(const Text_t* name,TObject* obj)
       delete buf;
       TStreamerInfo* info;
       TIter next(&list);
-      while ((info = (TStreamerInfo*)next())) {
+      while ((info = static_cast<TStreamerInfo*>(next()))) {
         if (info->IsA() != TStreamerInfo::Class()) {
           fLogger->Warning(MESSAGE_ORIGIN,"Not a TStreamerInfo object");
           //          Warning("FairParamList::fill","not a TStreamerInfo object");
@@ -899,12 +933,8 @@ Bool_t FairParamList::fillObject(const Text_t* name,TObject* obj)
       list.Clear();  //this will delete all TStreamerInfo objects with kCanDelete
     }
     len=o->getLength();
-#if ROOT_VERSION_CODE  > ROOT_VERSION(4,4,2)
     buf=new TBufferFile(TBuffer::kRead,len);
-#else
-    buf=new TBuffer(TBuffer::kRead,len);
-#endif
-    memcpy(buf->Buffer(),(Char_t*)o->getParamValue(),len);
+    memcpy(buf->Buffer(),reinterpret_cast<Char_t*>(o->getParamValue()),len);
     buf->SetBufferOffset(0);
     buf->MapObject(obj);
     obj->Streamer(*buf);
diff --git a/parbase/FairParamList.h b/parbase/FairParamList.h
index 477dc72..ea1b9c2 100644
--- a/parbase/FairParamList.h
+++ b/parbase/FairParamList.h
@@ -1,17 +1,28 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRPARAMLIST_H
 #define FAIRPARAMLIST_H
 
-#include "TNamed.h"
-#include "TString.h"
-#include "TArrayI.h"
-#include "TArrayC.h"
-#include "TArrayF.h"
-#include "TArrayD.h"
-#include "TList.h"
-#include "TFile.h"
-#include "TROOT.h"
+#include "TNamed.h"                     // for TNamed
+
+#include "Rtypes.h"                     // for Text_t, Int_t, Bool_t, etc
+#include "TArrayC.h"                    // for TArrayC
+#include "TFile.h"                      // for TFile
+#include "TList.h"                      // for TList
+#include "TObject.h"                    // for TObject
+#include "TROOT.h"                      // for TROOT, gROOT
+#include "TSeqCollection.h"             // for TSeqCollection
+#include "TString.h"                    // for TString
 
 class FairLogger;
+class TArrayD;
+class TArrayF;
+class TArrayI;
 
 class FairParamObj : public TNamed
 {
@@ -28,9 +39,12 @@ class FairParamObj : public TNamed
     FairParamObj(const Text_t* name="");
     FairParamObj(FairParamObj&);
     FairParamObj(const Text_t*,Int_t);
+    FairParamObj(const Text_t*,Bool_t);
+    FairParamObj(const Text_t*,UInt_t);
     FairParamObj(const Text_t*,Float_t);
     FairParamObj(const Text_t*,Double_t);
     FairParamObj(const Text_t*,const Int_t*,const Int_t);
+    FairParamObj(const Text_t*,const UInt_t*,const Int_t);
     FairParamObj(const Text_t*,const Float_t*,const Int_t);
     FairParamObj(const Text_t*,const Double_t*,const Int_t);
     FairParamObj(const Text_t*,const Text_t*);
@@ -88,6 +102,8 @@ class FairParamList : public TObject
     void add(FairParamObj&);
     void add(const Text_t*,const Text_t*);
     void add(const Text_t*,Int_t);
+    void add(const Text_t*,Bool_t);
+    void add(const Text_t*,UInt_t);
     void add(const Text_t*,Float_t);
     void add(const Text_t*,Double_t);
     void add(const Text_t*,TArrayI&);
@@ -101,6 +117,8 @@ class FairParamList : public TObject
     void addObject(const Text_t*,TObject*);
     Bool_t fill(const Text_t*,Text_t*,const Int_t);
     Bool_t fill(const Text_t*,Int_t*,const Int_t nValues=1);
+    Bool_t fill(const Text_t*,Bool_t*,const Int_t nValues=1);
+    Bool_t fill(const Text_t*,UInt_t*,const Int_t nValues=1);
     Bool_t fill(const Text_t*,Float_t*,const Int_t nValues=1);
     Bool_t fill(const Text_t*,Double_t*,const Int_t nValues=1);
     Bool_t fill(const Text_t*,UChar_t*,const Int_t nValues=1);
@@ -109,20 +127,16 @@ class FairParamList : public TObject
     Bool_t fill(const Text_t*,TArrayF*);
     Bool_t fill(const Text_t*,TArrayD*);
     Bool_t fillObject(const Text_t*,TObject*);
-    Int_t replace(const Text_t*,UChar_t*);
-    Int_t replace(const Text_t*,Int_t*);
-    Int_t replace(const Text_t*,Float_t*);
-    Int_t replace(const Text_t*,Double_t*);
     void print();
     FairParamObj* find(const Text_t* name) {
-      return (FairParamObj*)paramList->FindObject(name);
+      return static_cast<FairParamObj*>(paramList->FindObject(name));
     }
     TList* getList() { return paramList; }
   private:
     FairParamList(const FairParamList&);
     FairParamList& operator=(const FairParamList&);
 
-    ClassDef(FairParamList,2) // Class for lists of parameters (of type FairParamObj)
+    ClassDef(FairParamList,3) // Class for lists of parameters (of type FairParamObj)
 };
 
 #endif  /* !FAIRPARAMLIST_H */
diff --git a/parbase/FairRtdbRun.cxx b/parbase/FairRtdbRun.cxx
index 7407c4e..c6f3a02 100644
--- a/parbase/FairRtdbRun.cxx
+++ b/parbase/FairRtdbRun.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 20/10/2004
 
@@ -16,11 +23,13 @@
 //  The input versions are used during the initialisation
 //  used during the initialisation of the containers.
 ///////////////////////////////////////////////////////////////////
-
 #include "FairRtdbRun.h"
 
-#include <iostream>
-#include <iomanip>
+#include "TCollection.h"                // for TIter
+#include "TList.h"                      // for TList
+
+#include <iomanip>                      // for setw, operator<<
+#include <iostream>                     // for cout
 
 using std::cout;
 using std::ios;
@@ -69,7 +78,7 @@ FairRtdbRun::FairRtdbRun(FairRtdbRun& run)
   TList* lv=run.getParVersions();
   TIter next(lv);
   FairParVersion* pv;
-  while ((pv=(FairParVersion*)next())) {
+  while ((pv=static_cast<FairParVersion*>(next()))) {
     parVersions->Add(pv);
   }
 }
@@ -104,14 +113,14 @@ FairParVersion* FairRtdbRun::getParVersion(const Text_t* name)
 {
   // return a container version object called by the name of
   // the container
-  return (FairParVersion*)parVersions->FindObject(name);
+  return static_cast<FairParVersion*>(parVersions->FindObject(name));
 }
 
 void FairRtdbRun::resetInputVersions()
 {
   TIter next(parVersions);
   FairParVersion* v;
-  while ((v=(FairParVersion*)next())) {
+  while ((v=static_cast<FairParVersion*>(next()))) {
     v->resetInputVersions();
   }
 }
@@ -120,7 +129,7 @@ void FairRtdbRun::resetOutputVersions()
 {
   TIter next(parVersions);
   FairParVersion* v;
-  while ((v=(FairParVersion*)next())) {
+  while ((v=static_cast<FairParVersion*>(next()))) {
     v->setRootVersion(0);
   }
 }
@@ -131,7 +140,7 @@ void FairRtdbRun::print()
   cout<<"run: "<<GetName()<<'\n';
   FairParVersion* v;
   TIter next(parVersions);
-  while ((v=(FairParVersion*)next())) {
+  while ((v=static_cast<FairParVersion*>(next()))) {
     cout.setf(ios::left,ios::adjustfield);
     cout<<"  "<<setw(45)<<v->GetName();
     cout.setf(ios::right,ios::adjustfield);
@@ -141,13 +150,13 @@ void FairRtdbRun::print()
   }
 }
 
-void FairRtdbRun::write(fstream& fout)
+void FairRtdbRun::write(std::fstream& fout)
 {
   // writes the list of container versions for this run to fstream
   fout<<"run: "<<GetName()<<'\n';
   FairParVersion* v;
   TIter next(parVersions);
-  while ((v=(FairParVersion*)next())) {
+  while ((v=static_cast<FairParVersion*>(next()))) {
     fout.setf(ios::left,ios::adjustfield);
     fout<<"  "<<setw(45)<<v->GetName();
     fout.setf(ios::right,ios::adjustfield);
diff --git a/parbase/FairRtdbRun.h b/parbase/FairRtdbRun.h
index 3b663cc..757400c 100644
--- a/parbase/FairRtdbRun.h
+++ b/parbase/FairRtdbRun.h
@@ -1,13 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRRTDBRUN_H
 #define FAIRRTDBRUN_H
 
-#include "TNamed.h"
-#include "TList.h"
-#include "TString.h"
+#include "TNamed.h"                     // for TNamed
 
-//#include <iostream>
-//#include <iomanip>
-#include <fstream>
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for Int_t, Text_t, UInt_t, etc
+#include "TString.h"                    // for TString
+
+#include <stdio.h>                      // for sprintf, sscanf
+#include <fstream>                      // for fstream
+
+class TList;
+using std::fstream;
 
 class FairParVersion : public TNamed
 {
@@ -44,7 +55,7 @@ class FairRtdbRun : public TNamed
     FairRtdbRun(Int_t r,Int_t rr=-1);
     FairRtdbRun(FairRtdbRun& run);
     ~FairRtdbRun();
-    inline Int_t getRunId(void);
+    inline UInt_t getRunId(void);
     void addParVersion(FairParVersion* pv);
     FairParVersion* getParVersion(const Text_t* name);
     TList* getParVersions() {return parVersions;}
@@ -54,7 +65,7 @@ class FairRtdbRun : public TNamed
     void resetInputVersions();
     void resetOutputVersions();
     void print();
-    void write(fstream&);
+    void write(std::fstream&);
 
   private:
     FairRtdbRun& operator=(const FairRtdbRun&);
@@ -64,9 +75,9 @@ class FairRtdbRun : public TNamed
 
 // -------------------- inlines ---------------------------
 
-inline Int_t FairRtdbRun::getRunId(void)
+inline UInt_t FairRtdbRun::getRunId(void)
 {
-  Int_t r;
+  UInt_t r;
   sscanf(GetName(),"%i",&r);
   return r;
 }
diff --git a/parbase/FairRuntimeDb.cxx b/parbase/FairRuntimeDb.cxx
index 9e7da33..d7091a8 100644
--- a/parbase/FairRuntimeDb.cxx
+++ b/parbase/FairRuntimeDb.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 20/10/2004
 
@@ -6,30 +13,44 @@
 //
 //  Administration class for parameter input/output
 /////////////////////////////////////////////////////////////
-
 #include "FairRuntimeDb.h"
 
-#include "FairContFact.h"
-#include "FairParSet.h"
-#include "FairRtdbRun.h"
-#include "FairParIo.h"
-#include "FairParRootFileIo.h"
-#include "FairParAsciiFileIo.h"
-#include "FairGenericParRootFileIo.h"
-#include "FairGenericParAsciiFileIo.h"
-
-//#include "TKey.h"
-#include "TClass.h"
-
-
-#include <iostream>
-#include <iomanip>
+#include "FairContFact.h"               // for FairContFact
+#include "FairDetParAsciiFileIo.h"      // for FairDetParAsciiFileIo
+#include "FairDetParRootFileIo.h"       // for FairDetParRootFileIo
+//#include "FairDetParTSQLIo.h"           // for FairDetParTSQLIo
+#include "FairGenericParAsciiFileIo.h"  // for FairGenericParAsciiFileIo
+#include "FairGenericParRootFileIo.h"   // for FairGenericParRootFileIo
+//#include "FairGenericParTSQLIo.h"       // for FairGenericParTSQLIo
+#include "FairLogger.h"                 // for FairLogger, MESSAGE_ORIGIN
+#include "FairParAsciiFileIo.h"         // for FairParAsciiFileIo
+#include "FairParIo.h"                  // for FairParIo
+#include "FairParRootFileIo.h"          // for FairParRootFileIo
+#include "FairParSet.h"                 // for FairParSet
+#include "FairRtdbRun.h"                // for FairRtdbRun, FairParVersion
+
+#include "Riosfwd.h"                    // for ostream
+#include "TClass.h"                     // for TClass
+#include "TCollection.h"                // for TIter
+#include "TFile.h"                      // for TFile, gFile
+
+#include <stdio.h>                      // for sprintf
+#include <string.h>                     // for strcmp, NULL, strlen
+#include <iomanip>                      // for setw, operator<<
+#include <iostream>                     // for operator<<, basic_ostream, etc
+
+class FairDetParIo;
 
 using std::cout;
 using std::endl;
 using std::ios;
 using std::setw;
 
+/// DEBUG DEBUG Temporary define
+// 0 = use original code; 1 = use new code
+#define USE_DB_METHOD 1
+/////////////////////////////////
+
 ClassImp(FairRuntimeDb)
 
 FairRuntimeDb* FairRuntimeDb::gRtdb=0;
@@ -52,7 +73,8 @@ FairRuntimeDb::FairRuntimeDb(void)
    currentFileName(""),
    versionsChanged(kFALSE),
    isRootFileOutput(kFALSE),
-   fLogger(FairLogger::GetLogger())
+   fLogger(FairLogger::GetLogger()),
+   ioType(UNKNOWN_Type)
 {
   gRtdb=this;
 }
@@ -65,16 +87,12 @@ FairRuntimeDb::~FairRuntimeDb()
   closeSecondInput();
   closeOutput();
   if (containerList) {
-    /*
-        TIter next(containerList);
-        FairParSet* cont;
-        while ((cont=(FairParSet*)next())) {
-          Text_t* name=(char*)cont->GetName();
-          cout<<"Remove Container: "<<name<<endl;
-          removeContainer(name);
-        }
-    */
-    containerList->Delete();
+    TIter next(containerList);
+    FairParSet* cont;
+    while ((cont=static_cast<FairParSet*>(next()))) {
+      Text_t* name=const_cast<char*>(cont->GetName());
+      if (!cont->isOwned()) { removeContainer(name); }
+    }
     delete containerList;
   }
   if (runs) {
@@ -95,7 +113,7 @@ void FairRuntimeDb::addContFactory(FairContFact* fact)
 
 FairContFact* FairRuntimeDb::getContFactory(const Text_t* FactName)
 {
-  return ((FairContFact*)contFactories.FindObject(FactName));
+  return (static_cast<FairContFact*>(contFactories.FindObject(FactName)));
 }
 
 Bool_t FairRuntimeDb::addParamContext(const char* context)
@@ -105,7 +123,7 @@ Bool_t FairRuntimeDb::addParamContext(const char* context)
   Bool_t found=kFALSE;
   TIter next(&contFactories);
   FairContFact* fact;
-  while((fact=(FairContFact*)next())) {
+  while((fact=static_cast<FairContFact*>(next()))) {
     if (fact->addContext(context)) { found=kTRUE; }
   }
   Error("addParamContext(const char*)","Unknown context");
@@ -118,26 +136,36 @@ void FairRuntimeDb::printParamContexts()
   // the container factories
   TIter next(&contFactories);
   FairContFact* fact;
-  while((fact=(FairContFact*)next())) { fact->print(); }
+  while((fact=static_cast<FairContFact*>(next()))) { fact->print(); }
 }
 
 Bool_t FairRuntimeDb::addContainer(FairParSet* container)
 {
+
   // adds a container to the list of containers
-  Text_t* name=(char*)container->GetName();
+  //cout << "-I- name parset # " << container->GetName()<< endl;
+  Text_t* name=const_cast<char*>(container->GetName());
+
   if (!containerList->FindObject(name)) {
     containerList->Add(container);
     TIter next(runs);
     FairRtdbRun* run;
     FairParVersion* vers;
-    while ((run=(FairRtdbRun*)next())) {
+    while ((run=static_cast<FairRtdbRun*>(next()))) {
       if (!run->getParVersion(name)) {
         vers=new FairParVersion(name);
         run->addParVersion(vers);
       }
     }
+    //cout << "-I- RTDB entries in list# " <<  containerList->GetEntries() <<"\n" ;
+
+
     return kTRUE;
   }
+
+
+
+
   Warning("addContainer(FairParSet*)","Container %s already exists!",name);
   return kFALSE;
 }
@@ -154,7 +182,7 @@ FairParSet* FairRuntimeDb::getContainer(const Text_t* name)
   TIter next(&contFactories);
   FairContFact* fact;
   FairParSet* c=0;
-  while(!c && (fact=(FairContFact*)next())) {
+  while(!c && (fact=static_cast<FairContFact*>(next()))) {
     c=fact->getContainer(name);
   }
   if (!c) { Error("getContainer(Text_t*)","Container %s not created!",name); }
@@ -166,7 +194,7 @@ FairParSet* FairRuntimeDb::findContainer(const char* name)
   // returns a pointer to the container called by name
   // The name is the original name of the parameter container eventually concatinated with
   // a non-default context.
-  return (FairParSet*)(containerList->FindObject(name));
+  return static_cast<FairParSet*>((containerList->FindObject(name)));
 }
 
 void FairRuntimeDb::removeContainer(Text_t* name)
@@ -200,8 +228,8 @@ FairRtdbRun* FairRuntimeDb::addRun(Int_t runId,Int_t refId)
     TIter next(containerList);
     FairParSet* cont;
     FairParVersion* vers;
-    while ((cont=(FairParSet*)next())) {
-      vers=new FairParVersion(((char*)cont->GetName()));
+    while ((cont=static_cast<FairParSet*>(next()))) {
+      vers=new FairParVersion((const_cast<char*>(cont->GetName())));
       run->addParVersion(vers);
     }
     runs->Add(run);
@@ -215,13 +243,13 @@ FairRtdbRun* FairRuntimeDb::getRun(Int_t id)
   // returns a pointer to the run called by the run id
   char name[255];
   sprintf(name,"%i",id);
-  return (FairRtdbRun*)(runs->FindObject(name));
+  return static_cast<FairRtdbRun*>((runs->FindObject(name)));
 }
 
 FairRtdbRun* FairRuntimeDb::getRun(Text_t* name)
 {
   // returns a pointer to the run called by name
-  return (FairRtdbRun*)(runs->FindObject(name));
+  return static_cast<FairRtdbRun*>((runs->FindObject(name)));
 }
 
 void FairRuntimeDb::removeRun(Text_t* name)
@@ -246,7 +274,7 @@ void FairRuntimeDb::writeVersions()
   if (getOutput() && output->check()) {
     if (versionsChanged && isRootFileOutput) {
       output->cd();
-      if (gFile->IsWritable()) { runs->Write(); }
+      if (gFile->IsWritable()) { runs->Write();}
       versionsChanged=kFALSE;
     }
   }
@@ -264,9 +292,9 @@ Bool_t FairRuntimeDb::writeContainers()
   if (currentRun) {
     const char* refRunName=currentRun->getRefRun();
     if (strlen(refRunName)>0) {
-      refRun=(FairRtdbRun*)(runs->FindObject(refRunName));
+      refRun=static_cast<FairRtdbRun*>((runs->FindObject(refRunName)));
     }
-    while ((cont=(FairParSet*)next())) {
+    while ((cont=static_cast<FairParSet*>(next()))) {
       rc=writeContainer(cont,currentRun,refRun) && rc;
     }
   }
@@ -280,14 +308,14 @@ Int_t FairRuntimeDb::findOutputVersion(FairParSet* cont)
   Int_t in2=cont->getInputVersion(2);
   FairRtdbRun* run;
   FairParVersion* vers;
-  Text_t* name=(char*)cont->GetName();
+  const Text_t* name=cont->GetName();
   Int_t v=0;
   if (in1==-1 && in2==-1) {
     if (cont->hasChanged()) { return 0; }
     else {
       Int_t i=runs->IndexOf(currentRun); //FIXME: This can be optimized with a backwards iter.
       while (i>=0) {
-        run=(FairRtdbRun*)runs->At(i);
+        run=static_cast<FairRtdbRun*>(runs->At(i));
         vers=run->getParVersion(name);
         if (vers->getInputVersion(1)==in1 && vers->getInputVersion(2)==in2) {
           if ((v=vers->getRootVersion())!=0) { return v; }
@@ -299,8 +327,8 @@ Int_t FairRuntimeDb::findOutputVersion(FairParSet* cont)
   }
   if ((firstInput==output) && (in1>0 && in2==-1)) { return in1; }
   TIter next(runs);
-  v=0;
-  while ((run=(FairRtdbRun*)next())) {
+ // v=0;
+  while ((run=static_cast<FairRtdbRun*>(next()))) {
     vers=run->getParVersion(name);
     if (vers->getInputVersion(1)==in1 && vers->getInputVersion(2)==in2) {
       if ((v=vers->getRootVersion())!=0) { return v; }
@@ -309,17 +337,20 @@ Int_t FairRuntimeDb::findOutputVersion(FairParSet* cont)
   return 0;
 }
 
+//////// Original version ////////
+#if (USE_DB_METHOD == 0)
 Bool_t FairRuntimeDb::writeContainer(FairParSet* cont, FairRtdbRun* run, FairRtdbRun* refRun)
 {
   // writes a container to the output if the containers has changed
   // The output might be suppressed if the changes is due an initialisation from a
   //   ROOT file which serves also as output or if it was already written
-  Text_t* c=(char*)cont->GetName();
+  const Text_t* c=cont->GetName();
   fLogger->Debug( MESSAGE_ORIGIN,"RuntimeDb: write container : %s ", cont->GetName());
   FairParVersion* vers=run->getParVersion(c);
   Bool_t rc=kTRUE;
   Int_t cv=0;
   if (getOutput() && output->check() && output->isAutoWritable()) {
+    cout << " CHECK OUTPUT DONE " << endl;
     if (isRootFileOutput) {
       if (cont->hasChanged()) {
         cv=findOutputVersion(cont);
@@ -346,6 +377,85 @@ Bool_t FairRuntimeDb::writeContainer(FairParSet* cont, FairRtdbRun* run, FairRtd
         vers->setRootVersion(cv);
       }
     }
+
+  }
+  vers->setInputVersion(cont->getInputVersion(1),1);
+  vers->setInputVersion(cont->getInputVersion(2),2);
+  cont->setChanged(kFALSE);
+  if (refRun) {
+    FairParVersion* refVers=refRun->getParVersion(c);
+    if (refVers) {
+      refVers->setInputVersion(cont->getInputVersion(1),1);
+      refVers->setInputVersion(cont->getInputVersion(2),2);
+      refVers->setRootVersion(cv);
+    }
+  }
+  return rc;
+}
+#endif
+
+//////////// With DB modification (FIXME FIXME) //////
+#if (USE_DB_METHOD > 0)
+Bool_t FairRuntimeDb::writeContainer(FairParSet* cont, FairRtdbRun* run, FairRtdbRun* refRun)
+{
+  // std::cout << "\n -I FairRuntimeDB Using DB mode \n";
+  // writes a container to the output if the containers has changed
+  // The output might be suppressed if the changes is due an initialisation from a
+  //   ROOT file which serves also as output or if it was already written
+  const Text_t* c = cont->GetName();
+  fLogger->Debug( MESSAGE_ORIGIN,"RuntimeDb: write container : %s ", cont->GetName());
+  FairParVersion* vers = run->getParVersion(c);
+  Bool_t rc = kTRUE;
+  Int_t cv = 0;
+  if (getOutput() && output->check() && output->isAutoWritable()) {
+    switch (ioType) {
+    case RootFileOutput: // RootFile
+      if (cont->hasChanged()) {
+        cv = findOutputVersion(cont);
+        if (cv == 0) {
+          cv = cont->write(output);
+          if (cv>0) {
+            fLogger->Info(MESSAGE_ORIGIN,"***  %s written to ROOT file   version: %i ", c, cv);
+          } else if (cv==-1) {
+            return kFALSE;
+          }
+          // -1 indicates and error during write
+          // 0 is allowed for all containers which have no write function
+        }
+        vers->setRootVersion(cv);
+      } else {
+        if (vers->getRootVersion() == 0) {
+          cv = findOutputVersion(cont);
+          vers->setRootVersion(cv);
+        }
+      }
+      break;// End of rootfile IO
+    case RootTSQLOutput://TSQL
+      if (cont->hasChanged()) {
+        cv = findOutputVersion(cont);
+        if(cv == 0) {
+          //std::cout << "-I- FairRuntimeDB: SQL write() called 1 = "<< cont->GetName() << "\n";
+          cont->print();
+          /*Int_t test = */
+          cont->write(output);
+          //std::cout << "-I- FairRuntimeDB: SQL write() called 2 =  \n";
+        }
+      }
+      break;//End of TSQL IO
+    case AsciiFileOutput:// might be Ascii I/O
+      if(cont->hasChanged()) {
+        cv = cont->write(output);
+        if(cv <0) {
+          return kFALSE;
+        }
+        cout << "***  " << c << " written to output" << '\n';
+        vers->setRootVersion(cv);
+      }
+      break;// End of Ascii IO
+    default: // Unknown IO
+      Error("writeContainer()","Unknown output file type.");
+      break;
+    }
   }
   vers->setInputVersion(cont->getInputVersion(1),1);
   vers->setInputVersion(cont->getInputVersion(2),2);
@@ -360,6 +470,8 @@ Bool_t FairRuntimeDb::writeContainer(FairParSet* cont, FairRtdbRun* run, FairRtd
   }
   return rc;
 }
+#endif
+////////////////////////////////////////
 
 Bool_t FairRuntimeDb::initContainers(Int_t runId,Int_t refId,
                                      const Text_t* fileName)
@@ -392,7 +504,7 @@ Bool_t FairRuntimeDb::readAll()
   currentRun=0;
   Bool_t rc=kTRUE;
   TIter next(runs);
-  while ((currentRun=(FairRtdbRun*)next())!=0) {
+  while ((currentRun=static_cast<FairRtdbRun*>(next()))!=0) {
     rc=initContainers() && rc;
     writeContainers();
   }
@@ -404,7 +516,7 @@ Bool_t FairRuntimeDb::readAll()
 Bool_t FairRuntimeDb::initContainers(void)
 {
   // private function
-  Text_t* refRunName=(char*)currentRun->getRefRun();
+  Text_t* refRunName=const_cast<char*>(currentRun->getRefRun());
   Int_t len=strlen(refRunName);
   if (len<1) {
     if (firstInput) { firstInput->readVersions(currentRun); }
@@ -417,7 +529,7 @@ Bool_t FairRuntimeDb::initContainers(void)
   TIter next(containerList);
   FairParSet* cont;
   Bool_t rc=kTRUE;
-  cout<<'\n'<<"*************************************************************"<<'\n';
+  cout<<'\n'<<"************************************************************* "<<'\n';
   if (currentFileName.IsNull()) {
     cout<<"     initialisation for run id "<<currentRun->GetName();
   } else {
@@ -425,8 +537,9 @@ Bool_t FairRuntimeDb::initContainers(void)
     cout<<"     run id "<<currentRun->GetName();
   }
   if (len>0) { cout << " --> " << refRunName; }
-  cout<<'\n'<<"*************************************************************"<<'\n';
-  while ((cont=(FairParSet*)next())) {
+  cout<<'\n'<<"************************************************************* "<<'\n';
+  while ((cont=static_cast<FairParSet*>(next()))) {
+    cout << "-I- FairRunTimeDB::InitContainer() " << cont->GetName() << endl;
     if (!cont->isStatic()) { rc=cont->init() && rc; }
   }
   if (!rc) { Error("initContainers()","Error occured during initialization"); }
@@ -440,7 +553,7 @@ void FairRuntimeDb::setContainersStatic(Bool_t flag)
   // flag kFALSE sets all 'not static'
   TIter next(containerList);
   FairParSet* cont;
-  while ((cont=(FairParSet*)next())) {
+  while ((cont=static_cast<FairParSet*>(next()))) {
     cont->setStatic(flag);
   }
 }
@@ -489,7 +602,7 @@ void FairRuntimeDb::print()
   TIter nextCont(containerList);
   FairParSet* cont;
   cout.setf(ios::left,ios::adjustfield);
-  while((cont=(FairParSet*)nextCont())) {
+  while((cont=static_cast<FairParSet*>(nextCont()))) {
     cout<<setw(45)<<cont->GetName()<<"  "<<cont->GetTitle()<<'\n';
   }
   TIter next(runs);
@@ -501,7 +614,7 @@ void FairRuntimeDb::print()
   cout<<setw(11)<<"1st-inp"
       <<setw(11)<<" 2nd-inp"
       <<setw(11)<<" output\n";
-  while ((run=(FairRtdbRun*)next())) {
+  while ((run=static_cast<FairRtdbRun*>(next()))) {
     run->print();
   }
   cout<<"--------------  input/output  --------------------------------------------------\n";
@@ -525,12 +638,12 @@ void FairRuntimeDb::resetInputVersions()
   // is called each time a new input is set
   TIter nextRun(runs);
   FairRtdbRun* run;
-  while ((run=(FairRtdbRun*)nextRun())) {
+  while ((run=static_cast<FairRtdbRun*>(nextRun()))) {
     run->resetInputVersions();
   }
   TIter nextCont(containerList);
   FairParSet* cont;
-  while ((cont=(FairParSet*)nextCont())) {
+  while ((cont=static_cast<FairParSet*>(nextCont()))) {
     if (!cont->isStatic()) { cont->resetInputVersions(); }
   }
 }
@@ -542,7 +655,7 @@ void FairRuntimeDb::resetOutputVersions()
   // is called also each time a new input is set which is not identical with the output
   TIter next(runs);
   FairRtdbRun* run;
-  while ((run=(FairRtdbRun*)next())) {
+  while ((run=static_cast<FairRtdbRun*>(next()))) {
     run->resetOutputVersions();
   }
 }
@@ -580,7 +693,8 @@ Bool_t FairRuntimeDb::setSecondInput(FairParIo* inp2)
   } else { Error("setSecondInput(FairParIo*)","no connection to input"); }
   return kFALSE;
 }
-
+//////// Original version ////////
+#if (USE_DB_METHOD  == 0)
 Bool_t FairRuntimeDb::setOutput(FairParIo* op)
 {
   // sets the output pointer
@@ -594,7 +708,29 @@ Bool_t FairRuntimeDb::setOutput(FairParIo* op)
   } else { Error("setOutput(FairParIo*)","no connection to output"); }
   return kFALSE;
 }
-
+#endif
+////// With DB modifications (FIXME FIXME)/////
+#if (USE_DB_METHOD > 0)
+Bool_t FairRuntimeDb::setOutput(FairParIo* op)
+{
+  // sets the output pointer
+  output = op;
+  if (output->check() == kTRUE) {
+    resetOutputVersions();
+    if (strcmp(output->IsA()->GetName(), "FairParRootFileIo") == 0) {
+      ioType = RootFileOutput;
+      isRootFileOutput=kTRUE;
+    } else if (strcmp(output->IsA()->GetName(), "FairParTSQLIo") == 0) {
+      ioType = RootTSQLOutput;
+    } else { //ASCII
+      ioType = AsciiFileOutput;
+    }
+    return kTRUE;
+  } else { Error("setOutput(FairParIo*)","no connection to output"); }
+  return kFALSE;
+}
+#endif
+/////////////////////////////////
 FairParIo* FairRuntimeDb::getFirstInput()
 {
   // return a pointer to the first input
@@ -664,17 +800,22 @@ void FairRuntimeDb::activateParIo(FairParIo* io)
   if (!po) {
     if (strcmp(ioName,"FairParRootFileIo")==0) {
       FairDetParRootFileIo* pn=
-        new FairGenericParRootFileIo(((FairParRootFileIo*)io)->getParRootFile());
+        new FairGenericParRootFileIo((static_cast<FairParRootFileIo*>(io))->getParRootFile());
       io->setDetParIo(pn);
     } else if (strcmp(ioName,"FairParAsciiFileIo")==0) {
       FairDetParAsciiFileIo* pn=
-        new FairGenericParAsciiFileIo(((FairParAsciiFileIo*)io)->getFile());
+        new FairGenericParAsciiFileIo((static_cast<FairParAsciiFileIo*>(io))->getFile());
       io->setDetParIo(pn);
     }
+    // else if(strcmp(ioName,"FairParTSQLIo") == 0) {
+    //  std::cout << "\n\n\n\t TSQL versie is called en nu de rest \n\n";
+    //  FairDetParTSQLIo* pn = new FairGenericParTSQLIo();
+    //  io->setDetParIo(pn);
+    //}
   }
   TIter next(&contFactories);
   FairContFact* fact;
-  while((fact=(FairContFact*)next())) {
+  while((fact=static_cast<FairContFact*>(next()))) {
     fact->activateParIo(io);
   }
 }
diff --git a/parbase/FairRuntimeDb.h b/parbase/FairRuntimeDb.h
index e1172c5..9510293 100644
--- a/parbase/FairRuntimeDb.h
+++ b/parbase/FairRuntimeDb.h
@@ -1,13 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRRUNTIMEDB_H
 #define FAIRRUNTIMEDB_H
 
-#include "TObject.h"
-#include "TList.h"
-#include "FairLogger.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Bool_t, Int_t, Text_t, etc
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
+
+class FairContFact;
+class FairLogger;
 class FairParIo;
 class FairParSet;
 class FairRtdbRun;
-class FairContFact;
 
 static TList contFactories;    //! list of container factories
 
@@ -15,6 +26,7 @@ class FairRuntimeDb : public TObject
 {
   private:
     static FairRuntimeDb* gRtdb; //!
+
   protected:
     FairRuntimeDb(void);
     TList* containerList;    // list of parameter containers
@@ -28,6 +40,18 @@ class FairRuntimeDb : public TObject
     Bool_t isRootFileOutput; // flag indicating that the output is a ROOT file
     /** Fair Logger */
     FairLogger*  fLogger;  //!
+
+    /**
+     * Select which IO type to use.
+     */
+    typedef enum {
+      UNKNOWN_Type    = 0,
+      AsciiFileOutput = 1, // Ascii in-out-put
+      RootFileOutput  = 2, // Root Files
+      RootTSQLOutput  = 3  // Use a TSQL db
+    } ParamIOType;
+    ParamIOType ioType;//IO Type
+
   public:
     static FairRuntimeDb* instance(void);
     ~FairRuntimeDb(void);
diff --git a/parbase/ParBaseLinkDef.h b/parbase/ParBaseLinkDef.h
index dbc2fdc..1ffc3a5 100644
--- a/parbase/ParBaseLinkDef.h
+++ b/parbase/ParBaseLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // ParBaseLinkDef.h
 // V. Friese  20/02/06
 
@@ -23,7 +30,6 @@
 #pragma link C++ class FairParRootFileIo+;
 #pragma link C++ class FairParSet+;
 #pragma link C++ class FairParVersion+;
-//#pragma link C++ class FairParamBinObj+;
 #pragma link C++ class FairParamList+;
 #pragma link C++ class FairParamObj+;
 #pragma link C++ class FairRtdbRun+;
diff --git a/parbase/README.md b/parbase/README.md
new file mode 100644
index 0000000..743c815
--- /dev/null
+++ b/parbase/README.md
@@ -0,0 +1,8 @@
+parbase
+========
+
+The `FairRuntimeDb` provides interaction layer between the analysis run (`FairRun`) and the parameter database.
+
+Currently, in this folder, there are classes for storing and retrieving the parameters in the ROOT or ASCII files.
+
+The parameter reader/writer implemented by users should derive from `FairParGenericSet`.
\ No newline at end of file
diff --git a/passive/CMakeLists.txt b/passive/CMakeLists.txt
index 34e025e..f75fea7 100644
--- a/passive/CMakeLists.txt
+++ b/passive/CMakeLists.txt
@@ -1,40 +1,45 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libPassive" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/passive
+Set(INCLUDE_DIRECTORIES
+  ${BASE_INCLUDE_DIRECTORIES}
+  ${CMAKE_SOURCE_DIR}/passive
+  ${CMAKE_SOURCE_DIR}/base/sim
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Include_Directories( ${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
-set(SRCS
-FairCave.cxx            
-FairGeoCave.cxx        
-FairGeoMagnet.cxx      
-FairGeoPassivePar.cxx  
-FairGeoPipe.cxx        
-FairGeoTarget.cxx      
-FairMagnet.cxx         
-FairPassiveContFact.cxx
-FairPipe.cxx           
-FairTarget.cxx 
+Set(SRCS
+  FairCave.cxx            
+  FairGeoCave.cxx        
+  FairGeoMagnet.cxx      
+  FairGeoPassivePar.cxx  
+  FairGeoPipe.cxx        
+  FairGeoTarget.cxx      
+  FairMagnet.cxx         
+  FairPassiveContFact.cxx
+  FairPipe.cxx           
+  FairTarget.cxx 
 )
 
 Set(HEADERS )
 Set(LINKDEF PassiveLinkDef.h)
 Set(LIBRARY_NAME Passive)
-Set(DEPENDENCIES Base GeoBase ParBase Geom Cint Core)
+Set(DEPENDENCIES Base GeoBase ParBase Geom Core)
 
 GENERATE_LIBRARY()
diff --git a/passive/FairCave.cxx b/passive/FairCave.cxx
index 2de9493..885221f 100644
--- a/passive/FairCave.cxx
+++ b/passive/FairCave.cxx
@@ -1,25 +1,27 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /* Generated by Together */
-
-#include "FairMCApplication.h"
 #include "FairCave.h"
-#include "FairVolume.h"
-#include "FairVolumeList.h"
-#include "TGeoMCGeometry.h"
-#include "TGeoManager.h"
-#include "TGeoVolume.h"
-#include "TGeoMedium.h"
 
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
-#include "FairGeoCave.h"
-#include "FairGeoRootBuilder.h"
-#include "FairRuntimeDb.h"
-#include "FairGeoPassivePar.h"
-#include "TObjArray.h"
-#include "FairGeoVolume.h"
-#include "FairGeoNode.h"
-#include "FairRun.h"
+#include "FairGeoCave.h"                // for FairGeoCave
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoPassivePar.h"          // for FairGeoPassivePar
+#include "FairGeoVolume.h"              // for FairGeoVolume
+#include "FairRun.h"                    // for FairRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+
+#include "TList.h"                      // for TListIter, TList (ptr only)
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
 
+#include <stddef.h>                     // for NULL
 
 ClassImp(FairCave)
 void FairCave::ConstructGeometry()
@@ -36,7 +38,7 @@ void FairCave::ConstructGeometry()
   // store geo parameter
   FairRun* fRun = FairRun::Instance();
   FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
-  FairGeoPassivePar* par=(FairGeoPassivePar*)(rtdb->getContainer("FairGeoPassivePar"));
+  FairGeoPassivePar* par=static_cast<FairGeoPassivePar*>(rtdb->getContainer("FairGeoPassivePar"));
   TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
   TObjArray* fPassNodes = par->GetGeoPassiveNodes();
 
@@ -44,7 +46,7 @@ void FairCave::ConstructGeometry()
   FairGeoNode* node   = NULL;
   FairGeoVolume* aVol=NULL;
 
-  while( (node = (FairGeoNode*)iter.Next()) ) {
+  while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
     aVol = dynamic_cast<FairGeoVolume*> ( node );
     if ( node->isSensitive()  ) {
       fSensNodes->AddLast( aVol );
diff --git a/passive/FairCave.h b/passive/FairCave.h
index 047b25b..eecbe7b 100644
--- a/passive/FairCave.h
+++ b/passive/FairCave.h
@@ -1,9 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef Cave_H
 #define Cave_H
 
-#include "FairDetector.h"
-#include "FairModule.h"
+#include "FairModule.h"                 // for FairModule
 
+#include "Rtypes.h"                     // for FairCave::Class, ClassDef, etc
 
 class FairCave : public FairModule
 {
diff --git a/passive/FairGeoCave.cxx b/passive/FairGeoCave.cxx
index 58b45e9..0540893 100644
--- a/passive/FairGeoCave.cxx
+++ b/passive/FairGeoCave.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -9,10 +16,17 @@
 /////////////////////////////////////////////////////////////
 
 #include "FairGeoCave.h"
-#include "FairGeoNode.h"
-#include "FairGeoShapes.h"
-#include "FairGeoBasicShape.h"
-#include "FairGeoMedium.h"
+
+#include "FairGeoBasicShape.h"          // for FairGeoBasicShape
+#include "FairGeoMedia.h"               // for FairGeoMedia
+#include "FairGeoMedium.h"              // for FairGeoMedium
+#include "FairGeoNode.h"                // for FairGeoNode, etc
+#include "FairGeoShapes.h"              // for FairGeoShapes
+
+#include "TList.h"                      // for TList
+
+#include <string.h>                     // for strcmp
+#include <iostream>                     // for cout
 
 using namespace std;
 ClassImp(FairGeoCave)
@@ -27,7 +41,7 @@ FairGeoCave::FairGeoCave()
   maxModules=1;
 }
 
-Bool_t FairGeoCave::read(fstream& fin,FairGeoMedia* media)
+Bool_t FairGeoCave::read(std::fstream& fin,FairGeoMedia* media)
 {
   // Reads the geometry from file
   if (!media) { return kFALSE; }
@@ -80,10 +94,10 @@ void FairGeoCave::addRefNodes()
   if (volu) { masterNodes->Add(new FairGeoNode(*volu)); }
 }
 
-void FairGeoCave::write(fstream& fout)
+void FairGeoCave::write(std::fstream& fout)
 {
   // Writes the geometry to file
-  fout.setf(ios::fixed,ios::floatfield);
+  std::ios_base::fmtflags tmp = fout.setf(ios::fixed,ios::floatfield);
   FairGeoNode* volu=getVolume(name);
   if (volu) {
     FairGeoBasicShape* sh=volu->getShapePointer();
@@ -93,6 +107,7 @@ void FairGeoCave::write(fstream& fout)
       sh->writePoints(&fout,volu);
     }
   }
+  fout.setf(tmp);
 }
 
 void FairGeoCave::print()
diff --git a/passive/FairGeoCave.h b/passive/FairGeoCave.h
index 65268c9..f3331fc 100644
--- a/passive/FairGeoCave.h
+++ b/passive/FairGeoCave.h
@@ -1,10 +1,23 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDGEOCAVE_H
 #define PNDGEOCAVE_H
 
-#include "FairGeoSet.h"
-#include "TString.h"
-#include "FairGeoMedia.h"
-#include <fstream>
+#include "FairGeoSet.h"                 // for FairGeoSet
+
+#include "Riosfwd.h"                    // for fstream
+#include "Rtypes.h"                     // for FairGeoCave::Class, Bool_t, etc
+#include "TString.h"                    // for TString
+
+#include <fstream>                      // for fstream
+
+class FairGeoMedia;
+
 class  FairGeoCave : public FairGeoSet
 {
   protected:
@@ -13,9 +26,9 @@ class  FairGeoCave : public FairGeoSet
     FairGeoCave();
     ~FairGeoCave() {}
     const char* getModuleName(Int_t) {return name.Data();}
-    Bool_t read(fstream&,FairGeoMedia*);
+    Bool_t read(std::fstream&,FairGeoMedia*);
     void addRefNodes();
-    void write(fstream&);
+    void write(std::fstream&);
     void print();
     ClassDef(FairGeoCave,0) // Class for the geometry of CAVE
 };
diff --git a/passive/FairGeoMagnet.cxx b/passive/FairGeoMagnet.cxx
index 65e6cd4..3907b62 100644
--- a/passive/FairGeoMagnet.cxx
+++ b/passive/FairGeoMagnet.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -10,6 +17,10 @@
 
 #include "FairGeoMagnet.h"
 
+#include "TString.h"                    // for TString
+
+#include <string.h>                     // for strcpy
+
 ClassImp(FairGeoMagnet)
 
 FairGeoMagnet::FairGeoMagnet()
diff --git a/passive/FairGeoMagnet.h b/passive/FairGeoMagnet.h
index a0d4934..a49c8e3 100644
--- a/passive/FairGeoMagnet.h
+++ b/passive/FairGeoMagnet.h
@@ -1,8 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDGEOMAGNET_H
 #define PNDGEOMAGNET_H
 
-#include "FairGeoSet.h"
-#include "TString.h"
+#include "FairGeoSet.h"                 // for FairGeoSet
+
+#include "Rtypes.h"                     // for FairGeoMagnet::Class, Int_t, etc
 
 class  FairGeoMagnet : public FairGeoSet
 {
diff --git a/passive/FairGeoPassivePar.cxx b/passive/FairGeoPassivePar.cxx
index 6a782d3..8956dc0 100644
--- a/passive/FairGeoPassivePar.cxx
+++ b/passive/FairGeoPassivePar.cxx
@@ -1,12 +1,20 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Denis Bertini
 //*-- Created : 21/06/2005
 
-using namespace std;
 #include "FairGeoPassivePar.h"
-#include "FairParamList.h"
-#include <iostream>
-#include <iomanip>
-#include "TObjArray.h"
+
+#include "FairParamList.h"              // for FairParamList
+
+#include "TObjArray.h"                  // for TObjArray
+
+using namespace std;
 
 ClassImp(FairGeoPassivePar)
 
diff --git a/passive/FairGeoPassivePar.h b/passive/FairGeoPassivePar.h
index 7c53bb7..9740a3f 100644
--- a/passive/FairGeoPassivePar.h
+++ b/passive/FairGeoPassivePar.h
@@ -1,8 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDGEOPASSIVEPAR_H
 #define PNDGEOPASSIVEPAR_H
 
-#include "FairParGenericSet.h"
-#include "TH1F.h"
+#include "FairParGenericSet.h"          // for FairParGenericSet
+
+#include "Rtypes.h"                     // for FairGeoPassivePar::Class, etc
+
+class FairParamList;
+class TObjArray;
 
 class FairGeoPassivePar : public FairParGenericSet
 {
diff --git a/passive/FairGeoPipe.cxx b/passive/FairGeoPipe.cxx
index 06e3ac0..9a95b3d 100644
--- a/passive/FairGeoPipe.cxx
+++ b/passive/FairGeoPipe.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -7,10 +14,18 @@
 // Class for geometry of support structure
 //
 /////////////////////////////////////////////////////////////
-
 #include "FairGeoPipe.h"
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
+
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
+
+#include <string.h>                     // for strcpy
+
+class FairGeoBuilder;
+class TObject;
 
 ClassImp(FairGeoPipe)
 
@@ -31,7 +46,7 @@ Bool_t  FairGeoPipe::create ( FairGeoBuilder* build )
     FairGeoLoader* loader=FairGeoLoader::Instance();
     FairGeoInterface* GeoInterface =loader->getGeoInterface();
 
-    GeoInterface->getMasterNodes()->Add( (TObject*)  getVolume("pipeCentral") );
+    GeoInterface->getMasterNodes()->Add( static_cast<TObject*>( getVolume("pipeCentral") ) );
   }
   return rc;
 }
diff --git a/passive/FairGeoPipe.h b/passive/FairGeoPipe.h
index 00293ff..c2468f4 100644
--- a/passive/FairGeoPipe.h
+++ b/passive/FairGeoPipe.h
@@ -1,7 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDGEOPIPE_H
 #define PNDGEOPIPE_H
 
-#include "FairGeoSet.h"
+#include "FairGeoSet.h"                 // for FairGeoSet
+
+#include "Rtypes.h"                     // for FairGeoPipe::Class, Int_t, etc
+
+class FairGeoBuilder;
 
 class  FairGeoPipe : public FairGeoSet
 {
diff --git a/passive/FairGeoTarget.cxx b/passive/FairGeoTarget.cxx
index 8b0e636..8c2ce67 100644
--- a/passive/FairGeoTarget.cxx
+++ b/passive/FairGeoTarget.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Ilse Koenig
 //*-- Created : 10/11/2003
 
@@ -10,6 +17,10 @@
 
 #include "FairGeoTarget.h"
 
+#include "TString.h"                    // for TString
+
+#include <string.h>                     // for strcpy
+
 ClassImp(FairGeoTarget)
 
 FairGeoTarget::FairGeoTarget()
diff --git a/passive/FairGeoTarget.h b/passive/FairGeoTarget.h
index 96c31ab..9a98f87 100644
--- a/passive/FairGeoTarget.h
+++ b/passive/FairGeoTarget.h
@@ -1,7 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDGEOTARGET_H
 #define PNDGEOTARGET_H
 
-#include "FairGeoSet.h"
+#include "FairGeoSet.h"                 // for FairGeoSet
+
+#include "Rtypes.h"                     // for FairGeoTarget::Class, Int_t, etc
 
 class  FairGeoTarget : public FairGeoSet
 {
diff --git a/passive/FairMagnet.cxx b/passive/FairMagnet.cxx
index 5526f3a..c87da4c 100644
--- a/passive/FairMagnet.cxx
+++ b/passive/FairMagnet.cxx
@@ -1,16 +1,30 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /* Generated by Together */
 
 #include "FairMagnet.h"
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
-#include "FairGeoMagnet.h"
-#include "FairGeoRootBuilder.h"
-#include "FairRuntimeDb.h"
-#include "FairGeoPassivePar.h"
-#include "TObjArray.h"
-#include "FairRun.h"
-#include "FairGeoVolume.h"
-#include "FairGeoNode.h"
+
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoMagnet.h"              // for FairGeoMagnet
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoPassivePar.h"          // for FairGeoPassivePar
+#include "FairGeoVolume.h"              // for FairGeoVolume
+
+#include "FairRun.h"                    // for FairRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+#include "Riosfwd.h"                    // for ostream
+#include "TList.h"                      // for TListIter, TList (ptr only)
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+
+#include <stddef.h>                     // for NULL
+#include <iostream>                     // for operator<<, basic_ostream, etc
 
 FairMagnet::~FairMagnet()
 {
@@ -38,7 +52,7 @@ void FairMagnet::ConstructGeometry()
   }
 }
 
-Bool_t FairMagnet::CheckIfSensitive(std::string name)
+Bool_t FairMagnet::CheckIfSensitive(std::string /*name*/)
 {
   // just to get rid of the warrning during run, not need this is a passive element!
   return kFALSE;
@@ -58,7 +72,7 @@ void FairMagnet::ConstructASCIIGeometry()
   // store geo parameter
   FairRun* fRun = FairRun::Instance();
   FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
-  FairGeoPassivePar* par=(FairGeoPassivePar*)(rtdb->getContainer("FairGeoPassivePar"));
+  FairGeoPassivePar* par=static_cast<FairGeoPassivePar*>(rtdb->getContainer("FairGeoPassivePar"));
   TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
   TObjArray* fPassNodes = par->GetGeoPassiveNodes();
 
@@ -66,7 +80,7 @@ void FairMagnet::ConstructASCIIGeometry()
   FairGeoNode* node   = NULL;
   FairGeoVolume* aVol=NULL;
 
-  while( (node = (FairGeoNode*)iter.Next()) ) {
+  while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
     aVol = dynamic_cast<FairGeoVolume*> ( node );
     if ( node->isSensitive()  ) {
       fSensNodes->AddLast( aVol );
diff --git a/passive/FairMagnet.h b/passive/FairMagnet.h
index 9f0df39..61a3d87 100644
--- a/passive/FairMagnet.h
+++ b/passive/FairMagnet.h
@@ -1,12 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef MAGNET_H
 #define MAGNET_H
 
-#include "TNamed.h"
-#include "TArrayI.h"
-#include "TClonesArray.h"
-#include "FairDetector.h"
-#include "FairModule.h"
+#include "FairModule.h"                 // for FairModule
 
+#include "Rtypes.h"                     // for FairMagnet::Class, Bool_t, etc
+
+#include <string>                       // for string
 
 class FairMagnet : public FairModule
 {
@@ -17,7 +23,7 @@ class FairMagnet : public FairModule
     void ConstructGeometry();
     void ConstructASCIIGeometry();
     Bool_t CheckIfSensitive(std::string name);
-    ClassDef(FairMagnet,1) //PNDMagnet
+    ClassDef(FairMagnet,1)
 
 };
 
diff --git a/passive/FairPassiveContFact.cxx b/passive/FairPassiveContFact.cxx
index 96e1b34..570d2fb 100644
--- a/passive/FairPassiveContFact.cxx
+++ b/passive/FairPassiveContFact.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 //*-- AUTHOR : Denis Bertini
 //*-- Created : 21/06/2005
 
@@ -8,13 +15,19 @@
 //  Factory for the parameter containers in libPassive
 //
 /////////////////////////////////////////////////////////////
+#include "FairPassiveContFact.h"
+
+#include "FairGeoPassivePar.h"          // for FairGeoPassivePar
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+
+#include "TList.h"                      // for TList
+#include "TString.h"                    // for TString
+
+#include <string.h>                     // for strcmp, NULL
+
+class FairParSet;
 
 using namespace std;
-#include "FairPassiveContFact.h"
-#include "FairRuntimeDb.h"
-#include "FairGeoPassivePar.h"
-#include <iostream>
-#include <iomanip>
 
 ClassImp(FairPassiveContFact)
 
diff --git a/passive/FairPassiveContFact.h b/passive/FairPassiveContFact.h
index 6a1d36b..a5ad2c3 100644
--- a/passive/FairPassiveContFact.h
+++ b/passive/FairPassiveContFact.h
@@ -1,9 +1,18 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PNDPASSIVECONTFACT_H
 #define PNDPASSIVECONTFACT_H
 
-#include "FairContFact.h"
+#include "FairContFact.h"               // for FairContFact, etc
 
-class FairContainer;
+#include "Rtypes.h"                     // for FairPassiveContFact::Class, etc
+
+class FairParSet;
 
 class FairPassiveContFact : public FairContFact
 {
diff --git a/passive/FairPipe.h b/passive/FairPipe.h
index 868ca55..8359297 100644
--- a/passive/FairPipe.h
+++ b/passive/FairPipe.h
@@ -1,12 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef PIPE_H
 #define PIPE_H
 
-#include "TNamed.h"
-#include "TArrayI.h"
-#include "TClonesArray.h"
-#include "FairDetector.h"
-#include "FairModule.h"
+#include "FairModule.h"                 // for FairModule
 
+#include "Rtypes.h"                     // for FairPipe::Class, ClassDef, etc
 
 class FairPipe : public FairModule
 {
diff --git a/passive/FairTarget.cxx b/passive/FairTarget.cxx
index da11eb7..d979746 100644
--- a/passive/FairTarget.cxx
+++ b/passive/FairTarget.cxx
@@ -1,16 +1,27 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 /* Generated by Together */
-
 #include "FairTarget.h"
-#include "FairGeoLoader.h"
-#include "FairGeoInterface.h"
-#include "FairGeoTarget.h"
-#include "FairGeoRootBuilder.h"
-#include "FairRuntimeDb.h"
-#include "FairGeoPassivePar.h"
-#include "TObjArray.h"
-#include "FairRun.h"
-#include "FairGeoVolume.h"
-#include "FairGeoNode.h"
+
+#include "FairGeoInterface.h"           // for FairGeoInterface
+#include "FairGeoLoader.h"              // for FairGeoLoader
+#include "FairGeoNode.h"                // for FairGeoNode
+#include "FairGeoPassivePar.h"          // for FairGeoPassivePar
+#include "FairGeoTarget.h"              // for FairGeoTarget
+#include "FairGeoVolume.h"              // for FairGeoVolume
+#include "FairRun.h"                    // for FairRun
+#include "FairRuntimeDb.h"              // for FairRuntimeDb
+
+#include "TList.h"                      // for TListIter, TList (ptr only)
+#include "TObjArray.h"                  // for TObjArray
+#include "TString.h"                    // for TString
+
+#include <stddef.h>                     // for NULL
 
 FairTarget::~FairTarget()
 {
@@ -38,7 +49,7 @@ void FairTarget::ConstructGeometry()
   // store geo parameter
   FairRun* fRun = FairRun::Instance();
   FairRuntimeDb* rtdb= FairRun::Instance()->GetRuntimeDb();
-  FairGeoPassivePar* par=(FairGeoPassivePar*)(rtdb->getContainer("FairGeoPassivePar"));
+  FairGeoPassivePar* par=static_cast<FairGeoPassivePar*>(rtdb->getContainer("FairGeoPassivePar"));
   TObjArray* fSensNodes = par->GetGeoSensitiveNodes();
   TObjArray* fPassNodes = par->GetGeoPassiveNodes();
 
@@ -46,7 +57,7 @@ void FairTarget::ConstructGeometry()
   FairGeoNode* node   = NULL;
   FairGeoVolume* aVol=NULL;
 
-  while( (node = (FairGeoNode*)iter.Next()) ) {
+  while( (node = static_cast<FairGeoNode*>(iter.Next())) ) {
     aVol = dynamic_cast<FairGeoVolume*> ( node );
     if ( node->isSensitive()  ) {
       fSensNodes->AddLast( aVol );
diff --git a/passive/FairTarget.h b/passive/FairTarget.h
index a0d3b6b..9053bbf 100644
--- a/passive/FairTarget.h
+++ b/passive/FairTarget.h
@@ -1,8 +1,16 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef Target_H
 #define Target_H
 
-#include "FairDetector.h"
-#include "FairModule.h"
+#include "FairModule.h"                 // for FairModule
+
+#include "Rtypes.h"                     // for FairTarget::Class, ClassDef, etc
 
 class FairTarget : public FairModule
 {
diff --git a/passive/PassiveLinkDef.h b/passive/PassiveLinkDef.h
index 3b5396f..2595676 100644
--- a/passive/PassiveLinkDef.h
+++ b/passive/PassiveLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // $Id: PassiveLinkDef.h,v 1.1.1.1 2005/06/23 07:14:26 dbertini Exp $
 
 #ifdef __CINT__
diff --git a/physics/femto/CMakeLists.txt b/physics/femto/CMakeLists.txt
index b1ad043..d706d35 100644
--- a/physics/femto/CMakeLists.txt
+++ b/physics/femto/CMakeLists.txt
@@ -7,9 +7,10 @@ ${ROOT_INCLUDE_DIR}
 ${GSL_DIR}/include
 ${CLHEP_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field
+${CMAKE_SOURCE_DIR}/parbase
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mpdfield
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/passive
@@ -21,13 +22,13 @@ ${CMAKE_SOURCE_DIR}/physics/femto
 ${CMAKE_SOURCE_DIR}/mpddata
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(PHYS_FEMTO_SRCS
 MpdFemto.cxx
diff --git a/physics/femto/MpdFemtoSHCF.cxx b/physics/femto/MpdFemtoSHCF.cxx
index 4278387..3e57fe6 100644
--- a/physics/femto/MpdFemtoSHCF.cxx
+++ b/physics/femto/MpdFemtoSHCF.cxx
@@ -862,7 +862,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 		if (recalccov) {
 			for (int ilmzero = 0; ilmzero < GetMaxJM(); ilmzero++)
 				for (int ilmprim = 0; ilmprim < GetMaxJM(); ilmprim++) {
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! RR " << ilmzero << " " << ilmprim << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -871,7 +871,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! RI " << ilmzero << " " << ilmprim << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -880,7 +880,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! IR " << ilmzero << " " << ilmprim << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -889,7 +889,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! II " << ilmzero << " " << ilmprim << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -907,7 +907,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 					covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] /=
 							fNumReal[0]->GetEntries();
 
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! RR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -916,7 +916,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! RI" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -925,7 +925,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! IR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -934,7 +934,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! II" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -952,7 +952,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 					covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] -= imag(
 							tTq0[ilmzero]) * imag(tTq0[ilmprim]);
 
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! RR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -961,7 +961,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! RI" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -970,7 +970,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! IR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -979,7 +979,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! II" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -997,7 +997,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 					covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)] /=
 							(fNumReal[0]->GetEntries() - 1);
 
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! RR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -1006,7 +1006,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 0, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! RI" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -1015,7 +1015,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 0)])) {
 						// 	    std::cout << "NaN !!!! IR" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
@@ -1024,7 +1024,7 @@ void MpdFemtoSHCF::RecalculateCF() {
 						// 		 << imag(tTq0[ilmzero]) << " "
 						// 		 << imag(tTq0[ilmprim]) << " " << std::endl;
 					}
-					if (isnan(
+                    if (std::isnan(
 							covmnum[GetBin(ibin - 1, ilmzero, 1, ilmprim, 1)])) {
 						// 	    std::cout << "NaN !!!! II" << std::endl;
 						// 	    std::cout << fNumReal[0]->GetEntries() << " "
diff --git a/sft/CMakeLists.txt b/sft/CMakeLists.txt
index 7e9a4f0..f25f700 100644
--- a/sft/CMakeLists.txt
+++ b/sft/CMakeLists.txt
@@ -6,8 +6,7 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/sft
 ${CMAKE_SOURCE_DIR}/kalman
@@ -17,13 +16,13 @@ ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(SFT_SRCS
 MpdSftGeo.cxx 
diff --git a/shield_pack/MpdGeneralGenerator/CMakeLists.txt b/shield_pack/MpdGeneralGenerator/CMakeLists.txt
index dd4e8c1..60d4961 100644
--- a/shield_pack/MpdGeneralGenerator/CMakeLists.txt
+++ b/shield_pack/MpdGeneralGenerator/CMakeLists.txt
@@ -6,8 +6,7 @@ set(INCLUDE_DIRECTORIES
     ${PLUTO_INCLUDE_DIR}
     ${CMAKE_SOURCE_DIR}/fairtools
     ${CMAKE_SOURCE_DIR}/geobase
-    ${CMAKE_SOURCE_DIR}/field
-    ${CMAKE_SOURCE_DIR}/base
+    ${CMAKE_SOURCE_DIR}/base/sim
     ${CMAKE_SOURCE_DIR}/generators
     ${CMAKE_SOURCE_DIR}/gconfig
 )
diff --git a/strawECT/CMakeLists.txt b/strawECT/CMakeLists.txt
index 78ac7b2..12b2e99 100644
--- a/strawECT/CMakeLists.txt
+++ b/strawECT/CMakeLists.txt
@@ -4,10 +4,13 @@
 
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase
 ${CMAKE_SOURCE_DIR}/parbase
-${CMAKE_SOURCE_DIR}/base
-${CMAKE_SOURCE_DIR}/field
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/cbmbase
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
@@ -15,13 +18,13 @@ ${CMAKE_SOURCE_DIR}/strawECT
 
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
 
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(StrawECT_SRCS
 MpdStrawECTGeo.cxx
diff --git a/strawendcap/CMakeLists.txt b/strawendcap/CMakeLists.txt
index f021d81..f52f00d 100644
--- a/strawendcap/CMakeLists.txt
+++ b/strawendcap/CMakeLists.txt
@@ -3,11 +3,14 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/fairtools
@@ -15,13 +18,13 @@ ${CMAKE_SOURCE_DIR}/strawendcap
 
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(STRAWENDCAP_SRCS
 MpdStrawendcapGeo.cxx 
diff --git a/sts/CMakeLists.txt b/sts/CMakeLists.txt
index 65b7e96..4989495 100644
--- a/sts/CMakeLists.txt
+++ b/sts/CMakeLists.txt
@@ -3,23 +3,26 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/geobase 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
+${CMAKE_SOURCE_DIR}/geobase
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/sts
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(STS_SRCS
 MpdStsGeo.cxx 
diff --git a/stt/CMakeLists.txt b/stt/CMakeLists.txt
index 6f897ab..93684fd 100644
--- a/stt/CMakeLists.txt
+++ b/stt/CMakeLists.txt
@@ -7,19 +7,18 @@ ${ROOT_INCLUDE_DIR}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
 ${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/mcstack 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/stt
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(STT_SRCS
 CbmSttMatchTracks.cxx
diff --git a/tgem/CMakeLists.txt b/tgem/CMakeLists.txt
index eef2f70..16d1701 100644
--- a/tgem/CMakeLists.txt
+++ b/tgem/CMakeLists.txt
@@ -6,21 +6,20 @@ set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base
 ${CMAKE_SOURCE_DIR}/cbmbase 
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/tgem
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(Tgem_SRCS
 MpdTgemGeo.cxx 
diff --git a/tof/CMakeLists.txt b/tof/CMakeLists.txt
index 17a348c..29732f0 100644
--- a/tof/CMakeLists.txt
+++ b/tof/CMakeLists.txt
@@ -3,11 +3,15 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/fairtools
 ${CMAKE_SOURCE_DIR}/tof
@@ -16,13 +20,13 @@ ${CMAKE_SOURCE_DIR}/lhetrack
 ${CMAKE_SOURCE_DIR}/etof
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(TOF_SRCS
 MpdTofGeo.cxx 
diff --git a/tof/MpdTofHitProducer.cxx b/tof/MpdTofHitProducer.cxx
index 3814a49..5b69f63 100644
--- a/tof/MpdTofHitProducer.cxx
+++ b/tof/MpdTofHitProducer.cxx
@@ -11,8 +11,10 @@
 #include <TH2D.h>
 #include <TEfficiency.h>
 #include <TRandom2.h>
+#include <TClonesArray.h>
 
 #include "FairMCTrack.h"
+#include "FairLogger.h"
 
 #include "MpdTofUtils.h"
 #include "MpdTofPoint.h"
diff --git a/tof/MpdTofHitProducerIdeal.cxx b/tof/MpdTofHitProducerIdeal.cxx
index ddb1fa1..5d79c46 100644
--- a/tof/MpdTofHitProducerIdeal.cxx
+++ b/tof/MpdTofHitProducerIdeal.cxx
@@ -5,6 +5,7 @@
 #include "TClonesArray.h"
 
 #include "FairRootManager.h"
+#include "FairLogger.h"
 
 #include "MpdTofUtils.h"
 #include "MpdTofHit.h"
diff --git a/tpc/CMakeLists.txt b/tpc/CMakeLists.txt
index d73f575..db29b02 100644
--- a/tpc/CMakeLists.txt
+++ b/tpc/CMakeLists.txt
@@ -4,11 +4,15 @@
 
 set(INCLUDE_DIRECTORIES
 ${ROOT_INCLUDE_DIR} 
-${CLHEP_INCLUDE_DIR} 
+${CLHEP_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
+${CMAKE_SOURCE_DIR}/base/field
 ${CMAKE_SOURCE_DIR}/mpdfield
 ${CMAKE_SOURCE_DIR}/mcstack
 ${CMAKE_SOURCE_DIR}/passive
@@ -18,13 +22,13 @@ ${CMAKE_SOURCE_DIR}/lhetrack
 ${CMAKE_SOURCE_DIR}/kalman
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(TPC_SRCS
 TaskHelpers.cxx
diff --git a/trackbase/CMakeLists.txt b/trackbase/CMakeLists.txt
index 9e51b05..8450ae8 100644
--- a/trackbase/CMakeLists.txt
+++ b/trackbase/CMakeLists.txt
@@ -1,39 +1,51 @@
+ ################################################################################
+ #    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    #
+ #                                                                              #
+ #              This software is distributed under the terms of the             # 
+ #         GNU Lesser General Public Licence version 3 (LGPL) version 3,        #  
+ #                  copied verbatim in the file "LICENSE"                       #
+ ################################################################################
 # Create a library called "libBase" which includes the source files given in
 # the array .
 # The extension is already found.  Any number of sources could be listed here.
 
-set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
-${CLHEP_INCLUDE_DIR} 
-${CMAKE_SOURCE_DIR}/fairtools
-${CMAKE_SOURCE_DIR}/geobase 
-${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
-${CMAKE_SOURCE_DIR}/passive
-${CMAKE_SOURCE_DIR}/genfit
-${CMAKE_SOURCE_DIR}/trackbase
+Set(INCLUDE_DIRECTORIES
+  ${CMAKE_SOURCE_DIR}/fairtools
+  ${CMAKE_SOURCE_DIR}/geobase 
+  ${CMAKE_SOURCE_DIR}/parbase
+  ${CMAKE_SOURCE_DIR}/base/steer
+  ${CMAKE_SOURCE_DIR}/base/event
+  ${CMAKE_SOURCE_DIR}/base/field
+  ${CMAKE_SOURCE_DIR}/base/sim
+  ${CMAKE_SOURCE_DIR}/base/source
+  ${CMAKE_SOURCE_DIR}/passive
+  ${CMAKE_SOURCE_DIR}/trackbase
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+Set(SYSTEM_INCLUDE_DIRECTORIES
+  ${ROOT_INCLUDE_DIR} 
+)
+
+Include_Directories(${INCLUDE_DIRECTORIES})
+Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
 
-set(LINK_DIRECTORIES
-${ROOT_LIBRARY_DIR}
+Set(LINK_DIRECTORIES
+  ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+Link_Directories(${LINK_DIRECTORIES})
 
-set(SRCS
-FairTrackPar.cxx
-FairTrackParP.cxx
-FairTrackParH.cxx 
-FairGeaneUtil.cxx
+Set(SRCS
+  FairTrackPar.cxx
+  FairTrackParP.cxx
+  FairTrackParH.cxx 
+  FairGeaneUtil.cxx
 )
 
 Set(HEADERS )
 Set(LINKDEF TrackBaseLinkDef.h)
 Set(LIBRARY_NAME TrkBase)
-Set(DEPENDENCIES Base Physics Matrix Cint Core)
+Set(DEPENDENCIES Base)
+#Set(DEPENDENCIES Base Physics Matrix Core)
 
 GENERATE_LIBRARY()
-
diff --git a/trackbase/FairGeaneUtil.cxx b/trackbase/FairGeaneUtil.cxx
index c17c399..19768e9 100644
--- a/trackbase/FairGeaneUtil.cxx
+++ b/trackbase/FairGeaneUtil.cxx
@@ -1,12 +1,24 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // ------------------------------------------------------------------
 // Version of June 10th
 // modified to work properly in q/p variables  instead of 1/p
 // ------------------------------------------------------------------
-
-#include <iostream>
 #include "FairGeaneUtil.h"
-#include "TGeoTorus.h"
-#include "TMath.h"
+
+#include "TMath.h"                      // for Sqrt, Cos, Sin, Power, sqrt, etc
+#include "TMathBase.h"                  // for Abs, Sign
+#include "TMatrixT.h"                   // for TMatrixT, etc
+#include "TMatrixTBase.h"               // for TMatrixTBase
+#include "TMatrixTUtils.h"              // for TMatrixTRow
+
+#include <string.h>                     // for memset
+#include <cmath>                        // for pow
 
 using namespace std;
 
@@ -87,7 +99,7 @@ void FairGeaneUtil::FromPtToSC(Double_t PC[3], Double_t RC[15],
 }
 
 void FairGeaneUtil::FromPtToSD(Double_t PD[3], Double_t RD[15], Double_t H[3], Int_t CH,
-                               Double_t SPU, Double_t DJ[2], Double_t DK[2],
+                               Double_t SPU, Double_t DJ[3], Double_t DK[3],
                                // output
                                Int_t& IERR, Double_t* PC, Double_t* RC)
 {
@@ -111,8 +123,8 @@ void FairGeaneUtil::FromPtToSD(Double_t PD[3], Double_t RD[15], Double_t H[3], I
 //                AND RD FOR FIXED U
 //      SPU       SIGN OF U-COMPONENT OF PARTICLE MOMENTUM
 //                spu = sign[p·(DJ x DK)]
-//      DJ[2]     UNIT VECTOR IN V-DIRECTION
-//      DK[2]     UNIT VECTOR IN W-DIRECTION    OF DETECTOR SYSTEM
+//      DJ[3]     UNIT VECTOR IN V-DIRECTION
+//      DK[3]     UNIT VECTOR IN W-DIRECTION    OF DETECTOR SYSTEM
 //
 //                         output
 //      PC[3]   (q/Pt, Lambda, Phi, Yt, Zt)
@@ -440,10 +452,10 @@ void FairGeaneUtil::FromSCToSD(Double_t PC[3], Double_t RC[15], Double_t H[3], I
 }
 
 
-void FairGeaneUtil::FromSD1ToSD2(Double_t PD1[2], Double_t RD1[15],Double_t H[2],
+void FairGeaneUtil::FromSD1ToSD2(Double_t PD1[3], Double_t RD1[15],Double_t H[3],
                                  Int_t CH, Double_t SP1,
-                                 Double_t DJ1[2], Double_t DK1[2],
-                                 Double_t DJ2[2], Double_t DK2[2],
+                                 Double_t DJ1[3], Double_t DK1[3],
+                                 Double_t DJ2[3], Double_t DK2[3],
                                  //           output
                                  Int_t& IERR, Double_t& SP2,
                                  Double_t* PD2, Double_t* RD2)
@@ -460,8 +472,8 @@ void FairGeaneUtil::FromSD1ToSD2(Double_t PD1[2], Double_t RD1[15],Double_t H[2]
 //
 //
 //                                      INPUT
-//      PD1[2]    q/P,V1',W1'
-//      H[2]      MAGNETIC FIELD
+//      PD1[3]    q/P,V1',W1'
+//      H[3]      MAGNETIC FIELD
 //      RD1(15)   ERROR MATRIX IN 1/P,V1',W1',V1,W1   (Triangular)
 //      CH        CHARGE OF PARTICLE
 //                CHARGE AND MAGNETIC FIELD ARE NEEDED
@@ -470,10 +482,10 @@ void FairGeaneUtil::FromSD1ToSD2(Double_t PD1[2], Double_t RD1[15],Double_t H[2]
 //                TO BE THE ERROR MATRIX FOR FIXED U1
 //                AND RD2 FOR FIXED U2
 //      SP1       SIGN OF U1-COMPONENT OF PARTICLE MOMENTUM     INPUT
-//      DJ1[2]    UNIT VECTOR IN V1-DIRECTION
-//      DK1[2]    UNIT VECTOR IN W1-DIRECTION    OF SYSTEM 1
-//      DJ2[2]    UNIT VECTOR IN V2-DIRECTION
-//      DK2[2]    UNIT VECTOR IN W2-DIRECTION    OF SYSTEM 2
+//      DJ1[3]    UNIT VECTOR IN V1-DIRECTION
+//      DK1[3]    UNIT VECTOR IN W1-DIRECTION    OF SYSTEM 1
+//      DJ2[3]    UNIT VECTOR IN V2-DIRECTION
+//      DK2[3]    UNIT VECTOR IN W2-DIRECTION    OF SYSTEM 2
 //
 //
 //                                 OUTPUT
@@ -1154,7 +1166,7 @@ void FairGeaneUtil::FromSCToMars(Double_t PC[3], Double_t RC[15], Double_t H[3],
 }
 
 void FairGeaneUtil::FromMarsToSD(Double_t PD[3], Double_t RD[6][6],
-                                 Double_t H[3], Int_t CH,
+                                 Double_t[3] /*H[3]*/, Int_t CH,
                                  Double_t DJ1[3], Double_t DK1[3],
                                  //  output
                                  Int_t& IERR, Double_t& SP1,
@@ -1403,7 +1415,7 @@ void FairGeaneUtil::FromMarsToSD(Double_t PD[3], Double_t RD[6][6],
 
 
 void FairGeaneUtil::FromSDToMars(Double_t PC[3], Double_t RC[15],
-                                 Double_t H[3], Int_t CH,
+                                 Double_t[3] /*H[3]*/, Int_t CH,
                                  Double_t SP1, Double_t DJ1[3], Double_t DK1[3],
                                  //  output
                                  Double_t* PD, sixMat& RD)
@@ -1469,6 +1481,7 @@ void FairGeaneUtil::FromSDToMars(Double_t PC[3], Double_t RC[15],
       Rmat[I][K] = 0.;
       Rtra[I][K] = 0.;
       AJJ[I][K] = 0.;
+      if (K < 5) RCM[I][K]=0.;
     }
   }
   for(Int_t I=0; I<6; I++) {
@@ -1478,7 +1491,7 @@ void FairGeaneUtil::FromSDToMars(Double_t PC[3], Double_t RC[15],
     Rtra[5][I] = 0.;
     AJJ[5][I]  = 0.;
   }
-
+  
   SPU = SP1;
 
   // jacobian from SD to local cartesian
diff --git a/trackbase/FairGeaneUtil.h b/trackbase/FairGeaneUtil.h
index f9722d8..1a9681e 100644
--- a/trackbase/FairGeaneUtil.h
+++ b/trackbase/FairGeaneUtil.h
@@ -1,9 +1,17 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRGEANEUTIL_H
 #define FAIRGEANEUTIL_H
 
-#include "FairTrackPar.h"
-#include "TVector3.h"
+#include "TObject.h"                    // for TObject
 
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairGeaneUtil : public TObject
 {
@@ -17,7 +25,7 @@ class FairGeaneUtil : public TObject
                     Double_t* PD, Double_t* RD, Int_t& IERR);
 
     void FromPtToSD(Double_t PD[3], Double_t RD[15], Double_t H[3],Int_t CH,
-                    Double_t SPU, Double_t DJ[2], Double_t DK[2],
+                    Double_t SPU, Double_t DJ[3], Double_t DK[3],
                     Int_t& IERR, Double_t* PC, Double_t* RC);
 
     void FromSCToPt(Double_t PC[3], Double_t RC[15],
@@ -28,10 +36,10 @@ class FairGeaneUtil : public TObject
                     Int_t& IERR, Double_t& SPU,
                     Double_t* PD, Double_t* RD);
 
-    void FromSD1ToSD2(Double_t PD1[2], Double_t RD1[15],Double_t H[2],
+    void FromSD1ToSD2(Double_t PD1[3], Double_t RD1[15],Double_t H[3],
                       Int_t CH, Double_t SP1,
-                      Double_t DJ1[2], Double_t DK1[2],
-                      Double_t DJ2[2], Double_t DK2[2],
+                      Double_t DJ1[3], Double_t DK1[3],
+                      Double_t DJ2[3], Double_t DK2[3],
                       Int_t& IERR, Double_t& SP2,
                       Double_t* PD2, Double_t* RD2);
 
diff --git a/trackbase/FairTrackPar.cxx b/trackbase/FairTrackPar.cxx
index 8e67d5c..fd847ea 100644
--- a/trackbase/FairTrackPar.cxx
+++ b/trackbase/FairTrackPar.cxx
@@ -1,12 +1,19 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // -------------------------------------------------------------------------
 //      Created by M. Al-Turany  06.02.2007
 // -------------------------------------------------------------------------
 
-
-
-#include <iostream>
 #include "FairTrackPar.h"
 #include "TMath.h"
+#include "FairLogger.h"
+#include "FairRunAna.h"					// for GetFieldValue
+#include "FairField.h"
 
 using namespace std;
 
@@ -68,13 +75,22 @@ FairTrackPar::~FairTrackPar() {}
 // -------------------------------------------------------------------------
 
 // -----   Public method Print   -------------------------------------------
-void FairTrackPar::Print(Option_t* option) const
+void FairTrackPar::Print(Option_t* /*option*/) const
+{
+  gLogger->Info(MESSAGE_ORIGIN,"Position :(%f,%f,%f)",fX,fY,fZ);
+  gLogger->Info(MESSAGE_ORIGIN,"Momentum :(%f,%f,%f)",fPx,fPy,fPz);
+}
+
+void FairTrackPar::GetFieldValue(const Double_t point[3], Double_t* bField)
 {
-  cout << "Position : (";
-  cout.precision(2);
-  cout << fX << ", " << fY << ", " << fZ << ")" << endl;
-  cout << "Momentum : (";
-  cout << "Px = " << fPx << ", Py = " << fPy << " Pz = " << fPz << endl;
+	FairRunAna* fRun = FairRunAna::Instance();
+	if (fRun->GetField() != 0)
+		fRun->GetField()->GetFieldValue(point, bField);
+	else {
+		bField[0] = .0;
+		bField[1] = .0;
+		bField[2] = .0;
+	}
 }
 
 ClassImp(FairTrackPar)
diff --git a/trackbase/FairTrackPar.h b/trackbase/FairTrackPar.h
index 1dae5c3..2962261 100644
--- a/trackbase/FairTrackPar.h
+++ b/trackbase/FairTrackPar.h
@@ -1,8 +1,17 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifndef FAIRSTSTRACKPAR
 #define FAIRSTSTRACKPAR 1
 
-#include "TObject.h"
-#include "TVector3.h"
+#include "TObject.h"                    // for TObject
+
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairTrackPar : public TObject
 {
@@ -22,48 +31,109 @@ class FairTrackPar : public TObject
     /** Output to screen **/
     virtual void  Print(Option_t* option = "") const;
     /** Accessors **/
-    virtual TVector3 GetPosition() const {return TVector3(fX, fY, fZ); };
-
-    virtual Double_t GetX()   { return fX; };
-    virtual Double_t GetY()   { return fY; };
-    virtual Double_t GetZ()   { return fZ; };
-    Int_t   GetQ()  const { return fq; };
-
-    virtual Double_t GetDX()  const { return fDX; };
-    virtual Double_t GetDY()  const { return fDY; };
-    virtual Double_t GetDZ()  const { return fDZ; };
-
-    virtual TVector3 GetMomentum() const {return TVector3(fPx, fPy, fPz); };
-
-    virtual Double_t GetPx() const { return fPx; };
-    virtual Double_t GetPy() const { return fPy; };
-    virtual Double_t GetPz() const { return fPz; };
-    virtual Double_t GetQp() const { return fQp; };
-
-    virtual Double_t GetDPx() const { return fDPx; };
-    virtual Double_t GetDPy() const { return fDPy; };
-    virtual Double_t GetDPz() const { return fDPz; };
-    virtual Double_t GetDQp() const { return fDQp; };
-
-
-
-    virtual void SetX(Double_t x)   { fX  = x;  };
-    virtual void SetY(Double_t y)   { fY  = y;  };
-    virtual void SetZ(Double_t z)   { fZ  = z;  };
-
-    virtual void SetDX(Double_t dx)   { fDX  = dx;  };
-    virtual void SetDY(Double_t dy)   { fDY  = dy;  };
-    virtual void SetDZ(Double_t dz)   { fDZ  = dz;  };
-
-    virtual void SetPx(Double_t px) { fPx = px; };
-    virtual void SetPy(Double_t py) { fPy = py; };
-    virtual void SetPz(Double_t pz) { fPz = pz; };
-
-    virtual void SetDPx(Double_t dpx) { fDPx = dpx; };
-    virtual void SetDPy(Double_t dpy) { fDPy = dpy; };
-    virtual void SetDPz(Double_t dpz) { fDPz = dpz; };
-
-    void SetQp(Double_t qp) { fQp = qp; };
+    virtual TVector3 GetPosition() const {
+      return TVector3(fX, fY, fZ);
+    };
+
+    virtual Double_t GetX()   {
+      return fX;
+    };
+    virtual Double_t GetY()   {
+      return fY;
+    };
+    virtual Double_t GetZ()   {
+      return fZ;
+    };
+    Int_t   GetQ()  const {
+      return fq;
+    };
+
+    virtual Double_t GetDX()  const {
+      return fDX;
+    };
+    virtual Double_t GetDY()  const {
+      return fDY;
+    };
+    virtual Double_t GetDZ()  const {
+      return fDZ;
+    };
+
+    virtual TVector3 GetMomentum() const {
+      return TVector3(fPx, fPy, fPz);
+    };
+
+    virtual Double_t GetPx() const {
+      return fPx;
+    };
+    virtual Double_t GetPy() const {
+      return fPy;
+    };
+    virtual Double_t GetPz() const {
+      return fPz;
+    };
+    virtual Double_t GetQp() const {
+      return fQp;
+    };
+
+    virtual Double_t GetDPx() const {
+      return fDPx;
+    };
+    virtual Double_t GetDPy() const {
+      return fDPy;
+    };
+    virtual Double_t GetDPz() const {
+      return fDPz;
+    };
+    virtual Double_t GetDQp() const {
+      return fDQp;
+    };
+
+    virtual void GetFieldValue(const Double_t point[3], Double_t* bField);
+
+
+    virtual void SetX(Double_t x)   {
+      fX  = x;
+    };
+    virtual void SetY(Double_t y)   {
+      fY  = y;
+    };
+    virtual void SetZ(Double_t z)   {
+      fZ  = z;
+    };
+
+    virtual void SetDX(Double_t dx)   {
+      fDX  = dx;
+    };
+    virtual void SetDY(Double_t dy)   {
+      fDY  = dy;
+    };
+    virtual void SetDZ(Double_t dz)   {
+      fDZ  = dz;
+    };
+
+    virtual void SetPx(Double_t px) {
+      fPx = px;
+    };
+    virtual void SetPy(Double_t py) {
+      fPy = py;
+    };
+    virtual void SetPz(Double_t pz) {
+      fPz = pz;
+    };
+
+    virtual void SetDPx(Double_t dpx) {
+      fDPx = dpx;
+    };
+    virtual void SetDPy(Double_t dpy) {
+      fDPy = dpy;
+    };
+    virtual void SetDPz(Double_t dpz) {
+      fDPz = dpz;
+    };
+
+    void SetQp(Double_t qp) {
+      fQp = qp;
+    };
 
 
   protected:
@@ -89,7 +159,7 @@ class FairTrackPar : public TObject
     /** charge*/
     Int_t fq;
 
-    ClassDef(FairTrackPar,1);
+    ClassDef(FairTrackPar,2);
 
 };
 #endif
diff --git a/trackbase/FairTrackParH.cxx b/trackbase/FairTrackParH.cxx
index cf1d95b..e61c1c9 100644
--- a/trackbase/FairTrackParH.cxx
+++ b/trackbase/FairTrackParH.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the representation of a track as helix (SC system)
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
@@ -7,16 +14,19 @@
 // The Helix can be constructed using the Helix parameter (1/p, lambda, phi,y_perp,z_perp) in SC reference
 // and the covariance matrix. Or using position and momentum in LAB referance.
 
-
 #include "FairTrackParH.h"
-
-#include "FairGeaneUtil.h"
-#include "FairRunAna.h"
-#include "FairField.h"
-
-#include "TMath.h"
-#include <cmath>
-#include <iostream>
+#include "FairField.h"                  // for FairField
+#include "FairGeaneUtil.h"              // for FairGeaneUtil
+#include "FairRunAna.h"                 // for FairRunAna
+#include "FairTrackParP.h"              // for FairTrackParP
+#include "Riosfwd.h"                    // for ostream
+#include "TMath.h"                      // for pow, Sqrt, sqrt, Sin, Cos, etc
+#include "TMathBase.h"                  // for Abs, Sign
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <iomanip>
+#include <cmath>                        // IWYU pragma: keep for fabs
+// IWYU pragma: no_include <architecture/i386/math.h>
 
 using std::cout;
 using std::endl;
@@ -75,7 +85,7 @@ FairTrackParH::FairTrackParH(Double_t x, Double_t y, Double_t z,
   fQp = qp;
   Double_t P  = TMath::Abs(1/fQp);
   //fq= int (P * fQp);
-  fq = (int)TMath::Sign(1.0, fQp);
+  fq = static_cast<int>(TMath::Sign(1.0, fQp));
   for(Int_t i=0; i<15; i++)  {
     fCovMatrix[i]=CovMatrix[i];
   }
@@ -122,8 +132,9 @@ FairTrackParH::FairTrackParH(Double_t x, Double_t y, Double_t z,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   FairGeaneUtil util;
@@ -216,8 +227,9 @@ FairTrackParH::FairTrackParH(TVector3 pos, TVector3 Mom, TVector3 posErr, TVecto
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   FairGeaneUtil util;
@@ -264,8 +276,10 @@ FairTrackParH::FairTrackParH(FairTrackParP* parab, Int_t& ierr)
   pnt[0] = xyz.X();
   pnt[1] = xyz.Y();
   pnt[2] = xyz.Z();
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
+
   Int_t CH  = parab->GetQ();
 
   Double_t DJ[3] = {parab->GetJVer().X(), parab->GetJVer().Y(), parab->GetJVer().Z()};
@@ -350,8 +364,9 @@ void FairTrackParH::SetTrackPar(Double_t X,  Double_t Y,  Double_t Z,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   FairGeaneUtil util;
@@ -377,7 +392,7 @@ void  FairTrackParH::SetTrackPar(Double_t x,  Double_t y,  Double_t z,
   fQp = qp;
   Double_t P  = TMath::Abs(1/fQp);
 // fq= int (P * fQp);
-  fq = (int)TMath::Sign(1.0, fQp);
+  fq = static_cast<int>(TMath::Sign(1.0, fQp));
   for(Int_t i=0; i<15; i++)  {
     fCovMatrix[i]=CovMatrix[i];
 
@@ -427,8 +442,9 @@ void  FairTrackParH::SetTrackPar(Double_t x,  Double_t y,  Double_t z,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   FairGeaneUtil util;
@@ -585,8 +601,9 @@ FairTrackParH::FairTrackParH(FairTrackPar& Trkbase)
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   FairGeaneUtil fUtil;
@@ -606,16 +623,15 @@ FairTrackParH::~FairTrackParH()
 {
 
 }
-void  FairTrackParH::Print(Option_t* option) const
+void  FairTrackParH::Print(Option_t* /*option*/) const
 {
   cout << this<< endl;
-  cout << "Position : (";
-  cout.precision(2);
-  cout << fX << ", " << fY << ", " << fZ << ")" << endl;
-  cout << "Angles : Lambda = " << fLm << ", Phi = " << fPhi << endl;
+  cout << "Position : "
+       << std::setprecision(2) << fX << ", " << fY << ", " << fZ << ")" << endl;
+  cout << std::setprecision(2) << "Angles : Lambda = " << fLm << ", Phi = " << fPhi << endl;
   cout << "q/p = " << fQp << endl;
   for(Int_t i=0; i<15; i++) {
-    cout << "fCovMatrix[" << i << "] = " <<  this << " " << fCovMatrix[i] << endl;
+    cout << std::setprecision(2) << "fCovMatrix[" << i << "] = " <<  this << " " << fCovMatrix[i] << endl;
   }
 
 }
diff --git a/trackbase/FairTrackParH.h b/trackbase/FairTrackParH.h
index 88dc360..1d306e9 100644
--- a/trackbase/FairTrackParH.h
+++ b/trackbase/FairTrackParH.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the representation of a track as helix (SC system)
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
@@ -10,10 +17,10 @@
 #ifndef FAIRSTSTRACKPARH
 #define FAIRSTSTRACKPARH 1
 
-#include "FairTrackPar.h"
-#include "FairTrackParP.h"
+#include "FairTrackPar.h"               // for FairTrackPar
 
-#include "TVector3.h"
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairTrackParP;
 
diff --git a/trackbase/FairTrackParP.cxx b/trackbase/FairTrackParP.cxx
index ba8a36e..814b128 100644
--- a/trackbase/FairTrackParP.cxx
+++ b/trackbase/FairTrackParP.cxx
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the representation of a track as parabola (SD system)
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
@@ -8,13 +15,21 @@
 // and the covariance matrix. Or using position and momentum in LAB referance.
 
 #include "FairTrackParP.h"
-#include "FairGeaneUtil.h"
-#include "FairRunAna.h"
-#include "FairField.h"
-#include <cmath>
-#include "TMath.h"
 
-#include <iostream>
+#include "FairField.h"                  // for FairField
+#include "FairGeaneUtil.h"              // for FairGeaneUtil
+#include "FairRunAna.h"                 // for FairRunAna
+#include "FairTrackParH.h"              // for FairTrackParH
+
+#include "Riosfwd.h"                    // for ostream
+#include "TMath.h"                      // for Sqrt
+#include "TMathBase.h"                  // for Abs, Sign
+
+#include <iostream>                     // for operator<<, basic_ostream, etc
+#include <iomanip>
+#include <cmath>                        // IWYU pragma: keep for fabs
+
+// IWYU pragma: no_include <architecture/i386/math.h>
 
 using std::cout;
 using std::endl;
@@ -88,7 +103,7 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
 
   Double_t P  = TMath::Abs(1/fQp);
   //fq= int (P * fQp);
-  fq = (int)TMath::Sign(1.0, fQp);
+  fq = static_cast<int>(TMath::Sign(1.0, fQp));
   for(Int_t i=0; i<15; i++)  {
     fCovMatrix[i]=CovMatrix[i];
   }
@@ -124,13 +139,21 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
     RC[i]=fCovMatrix[i];
   }
 
+  // initialize RD
+  for(Int_t i=0; i<6; i++) {
+    for(Int_t k=0; k<6; k++) {
+      RD[i][k] = 0;
+    }
+  }
+
   // retrieve field
   Double_t pnt[3];
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
 
@@ -192,14 +215,13 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
   Double_t P=0;
   if(0!=fQp) {
     P = TMath::Abs(1/fQp);
-    fq = (int)TMath::Sign(1.0, fQp);
+    fq = static_cast<int>(TMath::Sign(1.0, fQp));
     //fq= int (P * fQp);
   } else { fq=1; }
   for(Int_t i=0; i<15; i++)  {
     fCovMatrix[i]=CovMatrix[i];
   }
 
-
   fPx_sd = fSPU*TMath::Sqrt( P*P / ( fTV*fTV + fTW*fTW + 1 ) );
   fPy_sd = fTV * fPx_sd;
   fPz_sd = fTW * fPx_sd;
@@ -224,7 +246,14 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
   PC[0]   = fQp;
   PC[1]   = fTV;
   PC[2]   = fTW;
-
+  
+  // initialize RD
+  for(Int_t i=0; i<6; i++) {
+    for(Int_t k=0; k<6; k++) {
+      RD[i][k] = 0;
+    }
+  }
+  
   for(Int_t i=0; i<15; i++)  {
     RC[i]=fCovMatrix[i];
   }
@@ -234,8 +263,9 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
 
@@ -245,6 +275,9 @@ FairTrackParP::FairTrackParP(Double_t v, Double_t w, Double_t Tv,
 
   util.FromSDToMars(PC, RC, H, CH, SP1, fDJ, fDK, PD, RD);
 
+  
+  
+  
   fPx = PD[0];
   fPy = PD[1];
   fPz = PD[2];
@@ -337,8 +370,9 @@ FairTrackParP::FairTrackParP(TVector3 pos, TVector3 Mom, TVector3 posErr, TVecto
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
 
@@ -430,8 +464,9 @@ FairTrackParP::FairTrackParP(TVector3 pos, TVector3 Mom,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
 
@@ -494,8 +529,10 @@ FairTrackParP::FairTrackParP(FairTrackParH* helix, TVector3 dj, TVector3 dk, Int
   pnt[0] = xyz.X();
   pnt[1] = xyz.Y();
   pnt[2] = xyz.Z();
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
+
   Int_t CH  = helix->GetQ();
 
   Double_t DJ[3] = {dj.X(), dj.Y(), dj.Z()};
@@ -529,7 +566,7 @@ FairTrackParP::FairTrackParP(FairTrackParH* helix, TVector3 dj, TVector3 dk, Int
 void FairTrackParP::SetTrackPar(Double_t X,  Double_t Y,  Double_t Z,
                                 Double_t Px, Double_t Py, Double_t Pz, Int_t Q,
                                 Double_t  CovMatrix[15],
-                                TVector3 o, TVector3 di, TVector3 dj, TVector3 dk)
+                                TVector3 o, TVector3 /*di*/, TVector3 dj, TVector3 dk)
 {
 
 
@@ -576,8 +613,9 @@ void FairTrackParP::SetTrackPar(Double_t X,  Double_t Y,  Double_t Z,
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
   util.FromMarsToSD(PD, RD, H, CH, fDJ, fDK, IERR, SP1, PC, RC);
@@ -615,7 +653,7 @@ void FairTrackParP::SetTrackPar(Double_t X,  Double_t Y,  Double_t Z,
 void  FairTrackParP::SetTrackPar(Double_t v, Double_t w, Double_t Tv,
                                  Double_t Tw, Double_t qp,
                                  Double_t CovMatrix[15],
-                                 TVector3 o, TVector3 di, TVector3 dj, TVector3 dk, Double_t spu)
+                                 TVector3 o, TVector3 /*di*/, TVector3 dj, TVector3 dk, Double_t spu)
 {
   Reset();
   SetPlane(o, dj, dk);
@@ -629,7 +667,7 @@ void  FairTrackParP::SetTrackPar(Double_t v, Double_t w, Double_t Tv,
 
   Double_t P  = TMath::Abs(1/fQp);
   //fq= int (P * fQp);
-  fq = (int)TMath::Sign(1.0, fQp);
+  fq = static_cast<int>(TMath::Sign(1.0, fQp));
   for(Int_t i=0; i<15; i++)  {
     fCovMatrix[i]=CovMatrix[i];
   }
@@ -662,13 +700,21 @@ void  FairTrackParP::SetTrackPar(Double_t v, Double_t w, Double_t Tv,
     RC[i]=fCovMatrix[i];
   }
 
+  // initialize RD
+  for(Int_t i=0; i<6; i++) {
+    for(Int_t k=0; k<6; k++) {
+      RD[i][k] = 0;
+    }
+  }
+  
   // retrieve field
   Double_t pnt[3];
   pnt[0] = fX;
   pnt[1] = fY;
   pnt[2] = fZ;
-  FairRunAna* fRun = FairRunAna::Instance();
-  fRun->GetField()->GetFieldValue(pnt, H);
+
+  GetFieldValue(pnt, H);
+
 
   CH=fq;
 
@@ -705,13 +751,12 @@ FairTrackParP::~FairTrackParP() {}
 // -------------------------------------------------------------------------
 
 // -----   Public method Print   -------------------------------------------
-void FairTrackParP::Print(Option_t* option) const
+void FairTrackParP::Print(Option_t* /*option*/) const
 {
   cout << "Position : (";
-  cout.precision(2);
-  cout << fX << ", " << fY << ", " << fZ << ")" << endl;
-  cout << "Slopes : dx/dz = " << fTV << ", dy/dz = " << fTW << endl;
-  cout << "q/p = " << fQp << endl;
+  cout << std::setprecision(2) << fX << ", " << fY << ", " << fZ << ")" << endl;
+  cout << std::setprecision(2) << "Slopes : dx/dz = " << fTV << ", dy/dz = " << fTW << endl;
+  cout << std::setprecision(2)  << "q/p = " << fQp << endl;
 }
 // -------------------------------------------------------------------------
 /*Double_t FairTrackParP::GetDX()
diff --git a/trackbase/FairTrackParP.h b/trackbase/FairTrackParP.h
index b5968c5..5461de1 100644
--- a/trackbase/FairTrackParP.h
+++ b/trackbase/FairTrackParP.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 // Class for the representation of a track as parabola (SD system)
 //
 // Authors: M. Al-Turany, A. Fontana, L. Lavezzi and A. Rotondi
@@ -9,9 +16,11 @@
 
 #ifndef FAIRSTSTRACKPARP
 #define FAIRSTSTRACKPARP 1
-#include "TVector3.h"
-#include "FairTrackPar.h"
-#include "FairTrackParH.h"
+
+#include "FairTrackPar.h"               // for FairTrackPar
+
+#include "Rtypes.h"                     // for Double_t, Int_t, etc
+#include "TVector3.h"                   // for TVector3
 
 class FairTrackParH;
 
diff --git a/trackbase/README.md b/trackbase/README.md
new file mode 100644
index 0000000..e61d18e
--- /dev/null
+++ b/trackbase/README.md
@@ -0,0 +1,8 @@
+trackbase
+========
+
+Track parameter containers.
+
+- `FairTrackPar` - the mother class for storing trajectory parameters
+  - `FairTrackParP` - parabolic track representation
+  - `FairTrackParH` - helix track representation
diff --git a/trackbase/TrackBaseLinkDef.h b/trackbase/TrackBaseLinkDef.h
index b92981d..a1e94bb 100644
--- a/trackbase/TrackBaseLinkDef.h
+++ b/trackbase/TrackBaseLinkDef.h
@@ -1,3 +1,10 @@
+/********************************************************************************
+ *    Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH    *
+ *                                                                              *
+ *              This software is distributed under the terms of the             * 
+ *         GNU Lesser General Public Licence version 3 (LGPL) version 3,        *  
+ *                  copied verbatim in the file "LICENSE"                       *
+ ********************************************************************************/
 #ifdef __CINT__
 
 #pragma link off all globals;
diff --git a/zdc/CMakeLists.txt b/zdc/CMakeLists.txt
index 27d7d92..8cf0f2f 100644
--- a/zdc/CMakeLists.txt
+++ b/zdc/CMakeLists.txt
@@ -3,24 +3,27 @@
 # The extension is already found.  Any number of sources could be listed here.
 
 set(INCLUDE_DIRECTORIES
-${ROOT_INCLUDE_DIR} 
+${ROOT_INCLUDE_DIR}
+${Boost_INCLUDE_DIRS}
 ${CMAKE_SOURCE_DIR}/geobase 
 ${CMAKE_SOURCE_DIR}/parbase 
-${CMAKE_SOURCE_DIR}/base 
-${CMAKE_SOURCE_DIR}/field 
+${CMAKE_SOURCE_DIR}/base/sim
+${CMAKE_SOURCE_DIR}/base/source
+${CMAKE_SOURCE_DIR}/base/steer
+${CMAKE_SOURCE_DIR}/base/event
 ${CMAKE_SOURCE_DIR}/mcstack 
 ${CMAKE_SOURCE_DIR}/tpc
 ${CMAKE_SOURCE_DIR}/zdc
 ${CMAKE_SOURCE_DIR}/fairtools
 )
 
-include_directories( ${INCLUDE_DIRECTORIES})
+include_directories(${INCLUDE_DIRECTORIES})
 
 set(LINK_DIRECTORIES
 ${ROOT_LIBRARY_DIR}
 )
  
-link_directories( ${LINK_DIRECTORIES})
+link_directories(${LINK_DIRECTORIES})
 
 set(ZDC_SRCS
 MpdZdcGeo.cxx 
diff --git a/zdc/MpdZdcDigi.h b/zdc/MpdZdcDigi.h
index a280849..512b6f5 100644
--- a/zdc/MpdZdcDigi.h
+++ b/zdc/MpdZdcDigi.h
@@ -30,6 +30,7 @@ class MpdZdcDigi: public TObject
 
 
   inline Int_t  GetDetectorID() { return fDetectorID; } 
+  inline Int_t  GetModuleID()  { return fModuleID; } 
   inline Int_t  GetChannelID()  { return fChannelID; } 
   inline Int_t  GetADCBits()    { return fADCBits; } 
   inline UInt_t GetELossDigi()  { return fELossDigi; } 
-- 
GitLab