diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2548c7a419aead0c24f79f52174c951b4bdb57c0..eab1a55a01adfaf3f6ee7eab0baccb9768c0a503 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -27,12 +27,12 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Xml_EXECUTABLE_COMPILE_FLAGS} ${Qt5
 
 
 #sudo apt-get install libpappsomspp-dev
-FIND_PACKAGE( Pappsomspp REQUIRED )
-# SET (PAPPSOMSPP_DIR  "/home/olivier/eclipse/git/pappsomspp")
+#FIND_PACKAGE( Pappsomspp REQUIRED )
+ SET (PAPPSOMSPP_DIR  "/home/olivier/eclipse/git/pappsomspp")
 # SET (PAPPSOMSPP_DIR  "/home/langella/developpement/git/pappsomspp")
-# SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src")
-# SET (PAPPSOMSPP_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt5.so")
-# SET (PAPPSOMSPP_WIDGET_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/pappsomspp/widget/libpappsomspp-widget-qt5.so")
+ SET (PAPPSOMSPP_INCLUDE_DIR "${PAPPSOMSPP_DIR}/src")
+ SET (PAPPSOMSPP_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt5.so")
+ SET (PAPPSOMSPP_WIDGET_QT5_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/pappsomspp/widget/libpappsomspp-widget-qt5.so")
 # SET (PAPPSOMSPP_QT4_LIBRARY "${PAPPSOMSPP_DIR}/cbuild/src/libpappsomspp-qt4.so")
 IF (PAPPSOMSPP_QT5_FOUND)
 ELSE (PAPPSOMSPP_QT5_FOUND)
@@ -158,6 +158,7 @@ SET(XTPCPP_SRCS
   ./gui/ptm_peptide_list_view/ptmsequencedelegate.cpp
   ./gui/tandem_run_dialog/tandemrundialog.cpp
   ./gui/waiting_message_dialog/waitingmessagedialog.cpp
+  ./gui/xic_view/xicwindow.cpp
   ./gui/workerthread.cpp
   ./utils/workmonitor.cpp
 )
@@ -182,6 +183,7 @@ SET (GUI_UIS
   ./gui/ptm_peptide_list_view/ptm_peptide_list_view.ui
   ./gui/tandem_run_dialog/tandem_run_dialog.ui
   ./gui/waiting_message_dialog/waiting_message_dialog.ui
+  ./gui/xic_view/xic_window.ui
 )
 
 SET(XTPCPP_MOC_HDRS
@@ -213,6 +215,7 @@ SET(XTPCPP_MOC_HDRS
   ./gui/ptm_peptide_list_view/ptmsequencedelegate.h
   ./gui/tandem_run_dialog/tandemrundialog.h
   ./gui/waiting_message_dialog/waitingmessagedialog.h
+  ./gui/xic_view/xicwindow.h
   ./gui/workerthread.h
   ./utils/workmonitor.h
 )
diff --git a/src/core/identification_sources/identificationdatasource.cpp b/src/core/identification_sources/identificationdatasource.cpp
index 0cf8bcc2c4c1bf25f6f4caafab7d9927841f437b..d368fd091b946ad3790633b934c133c39a62101b 100644
--- a/src/core/identification_sources/identificationdatasource.cpp
+++ b/src/core/identification_sources/identificationdatasource.cpp
@@ -144,7 +144,7 @@ pappso::SpectrumSp IdentificationDataSource::getSpectrumSp(unsigned int scan_num
     if (_ms_run_sp.get()->getMzFormat() == MzFormat::MGF) {
         scan_number = scan_number-1;
     }
-    pappso::SpectrumSp spectrum_sp = SpectrumStore::getSpectrumSpFromMsRunSp(_ms_run_sp, scan_number);
+    pappso::SpectrumSp spectrum_sp = SpectrumStore::getSpectrumSpFromMsRunSp(_ms_run_sp.get(), scan_number);
     return spectrum_sp;
 }
 
diff --git a/src/gui/peptide_detail_view/peptide_detail_view.ui b/src/gui/peptide_detail_view/peptide_detail_view.ui
index dfa3b2df184f39fd84ec78da7c8227be45703de5..73c43a1b9dbb0293cb4b9570855d76cd91301d23 100644
--- a/src/gui/peptide_detail_view/peptide_detail_view.ui
+++ b/src/gui/peptide_detail_view/peptide_detail_view.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>826</width>
-    <height>430</height>
+    <height>443</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -114,11 +114,25 @@
          </layout>
         </item>
         <item>
-         <widget class="QPushButton" name="pushButton">
-          <property name="text">
-           <string>Open in peptide viewer</string>
-          </property>
-         </widget>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
+          <item>
+           <widget class="QPushButton" name="pushButton">
+            <property name="text">
+             <string>Open in peptide viewer</string>
+            </property>
+           </widget>
+          </item>
+          <item>
+           <widget class="QPushButton" name="xic_button">
+            <property name="enabled">
+             <bool>false</bool>
+            </property>
+            <property name="text">
+             <string>XIC</string>
+            </property>
+           </widget>
+          </item>
+         </layout>
         </item>
        </layout>
       </item>
@@ -397,8 +411,8 @@
    <slot>chooseDefaultMzDataDir()</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>373</x>
-     <y>117</y>
+     <x>462</x>
+     <y>145</y>
     </hint>
     <hint type="destinationlabel">
      <x>977</x>
@@ -413,8 +427,8 @@
    <slot>doMsmsPrecisionChanged(pappso::PrecisionP)</slot>
    <hints>
     <hint type="sourcelabel">
-     <x>373</x>
-     <y>117</y>
+     <x>801</x>
+     <y>346</y>
     </hint>
     <hint type="destinationlabel">
      <x>977</x>
@@ -422,11 +436,28 @@
     </hint>
    </hints>
   </connection>
+  <connection>
+   <sender>xic_button</sender>
+   <signal>clicked()</signal>
+   <receiver>PeptideDetailView</receiver>
+   <slot>openInXicViewer()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>685</x>
+     <y>86</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>924</x>
+     <y>119</y>
+    </hint>
+   </hints>
+  </connection>
  </connections>
  <slots>
   <slot>chooseDefaultMzDataDir()</slot>
   <slot>openInPeptideViewer()</slot>
   <slot>doSaveSvg()</slot>
   <slot>doMsmsPrecisionChanged(pappso::PrecisionP)</slot>
+  <slot>openInXicViewer()</slot>
  </slots>
 </ui>
diff --git a/src/gui/peptide_detail_view/peptidewindow.cpp b/src/gui/peptide_detail_view/peptidewindow.cpp
index 07b41feeeb2cbb980d2e4e957628ba3815d2b4ae..01bd32985ee7a7cc26305c140dc57e421fadd07b 100644
--- a/src/gui/peptide_detail_view/peptidewindow.cpp
+++ b/src/gui/peptide_detail_view/peptidewindow.cpp
@@ -23,6 +23,7 @@
 
 #include "peptidewindow.h"
 #include "../project_view/projectwindow.h"
+#include "../../utils/readspectrum.h"
 #include "../../config.h"
 #include "ui_peptide_detail_view.h"
 #include <pappsomspp/exception/exceptionnotfound.h>
@@ -77,7 +78,7 @@ PeptideWindow::PeptideWindow(ProjectWindow *parent):
 
     QSettings settings;
     QString precision_str = settings.value("peptideview/precision", "0.2 dalton").toString();
-    
+
     _p_precision = pappso::Precision::fromString(precision_str);
 
     ui->file_not_found->setVisible(false);
@@ -199,6 +200,7 @@ void PeptideWindow::chooseDefaultMzDataDir() {
 
     qDebug() << "PeptideWindow::chooseDefaultMzDataDir begin";
     ui->file_not_found->setVisible(false);
+        ui->xic_button->setEnabled(true);
     ui->spectrum_widget->setVisible(true);
     emit loadSpectrumSp(_p_peptide_evidence);
     ui->statusbar->showMessage(tr("loading spectrum"));
@@ -216,12 +218,18 @@ void PeptideWindow::openInPeptideViewer() {
     myProcess->start(program, arguments);
 }
 
+
+void PeptideWindow::openInXicViewer() {
+    _p_project_window->openInXicViewer(_p_peptide_evidence);
+}
+
 void PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString error, QString fatal_error) {
     qDebug() << "PeptideWindow::doSpectrumSpReady begin error=" << error << " fatal_error=" << fatal_error;
     if ((error.isEmpty()) && (fatal_error.isEmpty())) {
         ui->statusbar->showMessage(tr(""));
         ui->file_not_found->setVisible(false);
         ui->spectrum_widget->setVisible(true);
+        ui->xic_button->setEnabled(true);
 
         ui->spectrum_widget->setMsLevel(2);
         ui->spectrum_widget->setSpectrumSp(spectrum_sp);
@@ -230,6 +238,17 @@ void PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString er
         qDebug() << "PeptideWindow::doSpectrumSpReady rescale";
         ui->spectrum_widget->rescale();
         _spectrum_is_ready = true;
+
+
+        try {
+            pappso::MassRange mass_range(_p_peptide_evidence->getPeptideXtpSp().get()->getMz(_p_peptide_evidence->getCharge()), pappso::Precision::getPpmInstance(10));
+
+            pappso::XicSp xic_sp = SpectrumStore::getXicSpFromMsRunSp(_p_peptide_evidence->getMsRunP(), mass_range, XixExtactMethod::max);
+        }
+        catch (pappso::PappsoException & error) {
+            QMessageBox::warning(this,
+                                 tr("Error trying to save spectrum to SVG file :"), error.qwhat());
+        }
     }
     if (!error.isEmpty()) {
         //not found
@@ -242,6 +261,7 @@ void PeptideWindow::doSpectrumSpReady(pappso::SpectrumSp spectrum_sp, QString er
 
         ui->file_not_found->setVisible(true);
         ui->spectrum_widget->setVisible(false);
+        ui->xic_button->setEnabled(false);
         _spectrum_is_ready = false;
     }
     if (!fatal_error.isEmpty()) {
diff --git a/src/gui/peptide_detail_view/peptidewindow.h b/src/gui/peptide_detail_view/peptidewindow.h
index 6c1709138c43a6fe241b4bd729bea4d5377f71b7..c165f164957649720ae2e4a072626d3073cd3fa1 100644
--- a/src/gui/peptide_detail_view/peptidewindow.h
+++ b/src/gui/peptide_detail_view/peptidewindow.h
@@ -83,6 +83,7 @@ protected slots:
     void doSaveSvg();
     void chooseDefaultMzDataDir();
     void openInPeptideViewer();
+    void openInXicViewer();
 protected :
     void updateDisplay();
 
diff --git a/src/gui/project_view/projectwindow.cpp b/src/gui/project_view/projectwindow.cpp
index 5a9189483abc28b6ce16a3b91d94bda09eaca2de..134f16d82fd06998dd6ce212df0ad2a8c04d39e4 100644
--- a/src/gui/project_view/projectwindow.cpp
+++ b/src/gui/project_view/projectwindow.cpp
@@ -762,3 +762,13 @@ void ProjectWindow::doAcceptedLabelingMethod() {
 
 }
 
+
+void ProjectWindow::openInXicViewer(const PeptideEvidence * p_peptide_evidence) {
+    qDebug() << "ProjectWindow::openInXicViewer begin";
+    if (_p_xic_window == nullptr) {
+        _p_xic_window = new XicWindow(this);
+    }
+    
+    _p_xic_window->show();
+    qDebug() << "ProjectWindow::openInXicViewer end";
+}
diff --git a/src/gui/project_view/projectwindow.h b/src/gui/project_view/projectwindow.h
index 727708b8bc859ca48476aff76376b1930eed1de0..a9439ef4ff0caca3774f290b3e305885aef53fe9 100644
--- a/src/gui/project_view/projectwindow.h
+++ b/src/gui/project_view/projectwindow.h
@@ -37,6 +37,7 @@
 #include "../peptide_detail_view/peptidewindow.h"
 #include "gui/project_view/automatic_filter_widget/automaticfilterwidget.h"
 #include "../waiting_message_dialog/waitingmessagedialog.h"
+#include "../xic_view/xicwindow.h"
 #include <qcustomplot.h>
 
 class MainWindow;
@@ -58,6 +59,7 @@ public:
     void setProjectSp(ProjectSp project_sp);
     void editModifications();
     void editLabelingMethods();
+    void openInXicViewer(const PeptideEvidence * p_peptide_evidence);
     ~ProjectWindow();
 
 public slots:
@@ -127,6 +129,7 @@ private:
     
     EditModifications * _p_edit_modifications = nullptr;
     EditLabelMethods * _p_edit_label_methods = nullptr;
+    XicWindow * _p_xic_window = nullptr;
     
     ProjectSp _project_sp;
     
diff --git a/src/gui/xic_view/xic_window.ui b/src/gui/xic_view/xic_window.ui
new file mode 100644
index 0000000000000000000000000000000000000000..fa9b6cb8584b39e55123a0b9b3fcff5bdf941062
--- /dev/null
+++ b/src/gui/xic_view/xic_window.ui
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>XicWindow</class>
+ <widget class="QMainWindow" name="XicWindow">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>800</width>
+    <height>600</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>XIC viewer</string>
+  </property>
+  <widget class="QWidget" name="centralwidget">
+   <layout class="QVBoxLayout" name="verticalLayout_2">
+    <item>
+     <layout class="QVBoxLayout" name="xic_vertical_layout"/>
+    </item>
+   </layout>
+  </widget>
+  <widget class="QMenuBar" name="menubar">
+   <property name="geometry">
+    <rect>
+     <x>0</x>
+     <y>0</y>
+     <width>800</width>
+     <height>25</height>
+    </rect>
+   </property>
+  </widget>
+  <widget class="QStatusBar" name="statusbar"/>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/gui/xic_view/xicwindow.cpp b/src/gui/xic_view/xicwindow.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c5f13f2e9fa4b1095ad66d775c2d6e650340ee5
--- /dev/null
+++ b/src/gui/xic_view/xicwindow.cpp
@@ -0,0 +1,60 @@
+/**
+ * \file src/gui/xic_view/xicwindow.cpp
+ * \date 11/1/2018
+ * \author Olivier Langella
+ * \brief XIC window
+ */
+
+/*******************************************************************************
+* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
+*
+* This file is part of XTPcpp.
+*
+*     XTPcpp 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 3 of the License, or
+*     (at your option) any later version.
+*
+*     XTPcpp 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.
+*
+*     You should have received a copy of the GNU General Public License
+*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+*
+* Contributors:
+*     Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
+******************************************************************************/
+
+#include "xicwindow.h"
+#include "ui_xic_window.h"
+#include "../project_view/projectwindow.h"
+
+
+XicWindow::XicWindow(ProjectWindow *parent):
+    QMainWindow(parent),
+    ui(new Ui::XicWindow)
+{
+    _project_window = parent;
+
+    ui->setupUi(this);
+    XicWorkerThread * p_worker = new XicWorkerThread();
+    p_worker->moveToThread(&_xic_thread);
+    _xic_thread.start();
+
+
+#if QT_VERSION >= 0x050000
+    // Qt5 code
+
+#else
+// Qt4 code
+#endif
+
+
+}
+
+XicWindow::~XicWindow()
+{
+    qDebug() << "XicWindow::~XicWindow";
+}
diff --git a/src/gui/xic_view/xicwindow.h b/src/gui/xic_view/xicwindow.h
new file mode 100644
index 0000000000000000000000000000000000000000..6cfe806be89ea5cd261ea667f92a901a1c4cd866
--- /dev/null
+++ b/src/gui/xic_view/xicwindow.h
@@ -0,0 +1,69 @@
+/**
+ * \file src/gui/xic_view/xicwindow.h
+ * \date 11/1/2018
+ * \author Olivier Langella
+ * \brief XIC window
+ */
+/*******************************************************************************
+* Copyright (c) 2018 Olivier Langella <olivier.langella@u-psud.fr>.
+*
+* This file is part of XTPcpp.
+*
+*     XTPcpp 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 3 of the License, or
+*     (at your option) any later version.
+*
+*     XTPcpp 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.
+*
+*     You should have received a copy of the GNU General Public License
+*     along with XTPcpp.  If not, see <http://www.gnu.org/licenses/>.
+*
+* Contributors:
+*     Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
+******************************************************************************/
+
+#ifndef XICWINDOW_H
+#define XICWINDOW_H
+
+#include <QThread>
+#include <QMainWindow>
+
+class ProjectWindow;
+
+
+class XicWorkerThread : public QObject
+{
+    Q_OBJECT
+public:
+
+
+protected:
+
+    void closeEvent(QCloseEvent *event);
+
+};
+
+
+namespace Ui {
+class XicWindow;
+}
+
+class XicWindow: public QMainWindow {
+    Q_OBJECT
+
+public:
+
+    explicit XicWindow(ProjectWindow * parent = 0);
+    ~XicWindow();
+
+
+private:
+    ProjectWindow * _project_window;
+    QThread _xic_thread;
+    Ui::XicWindow *ui;
+};
+#endif // XICWINDOW_H
diff --git a/src/output/ods/samplesheet.cpp b/src/output/ods/samplesheet.cpp
index a435cd3596971e549534e16713203bed078b71b2..e7b647de2de22ac6c956a9c5666d3c1d19df0607 100644
--- a/src/output/ods/samplesheet.cpp
+++ b/src/output/ods/samplesheet.cpp
@@ -105,7 +105,7 @@ void SampleSheet::writeIdentificationDataSource(IdentificationDataSource * p_ide
     _p_writer->writeLine();
     MsRunSp msrun_sp = p_ident_data_source->getMsRunSp();
     if (_msrun_statistics) {
-        SpectrumStore::checkMsRunStatistics(msrun_sp);
+        SpectrumStore::checkMsRunStatistics(msrun_sp.get());
     }
 
     _p_writer->writeCell(msrun_sp.get()->getXmlId());
diff --git a/src/utils/readspectrum.cpp b/src/utils/readspectrum.cpp
index d889642a16ca2e0bb105b4e8e65d8bd942721ee2..bb9d4082f1542710e31a657d12d2b4efdd23d1d3 100644
--- a/src/utils/readspectrum.cpp
+++ b/src/utils/readspectrum.cpp
@@ -90,9 +90,9 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso:
     const pwiz::msdata::SpectrumList * p_spectrum_list = p_ms_data_file->run.spectrumListPtr.get();
     std::size_t spectrum_list_size = p_spectrum_list->size();
     pwiz::msdata::SpectrumPtr spectrum;
-    
+
     XicElement peak;
-    
+
     for (std::size_t i=0; i < spectrum_list_size; i++) {
         spectrum = p_spectrum_list->spectrum(i, false);
         unsigned int ms_level(QString(spectrum->cvParam(pwiz::msdata::MS_ms_level).value.c_str()).toUInt());
@@ -101,7 +101,7 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso:
             spectrum = p_spectrum_list->spectrum(i, true);
             peak.rt = QString(spectrum->scanList.scans[0].cvParam(pwiz::msdata::MS_scan_start_time).value.c_str()).toDouble();
             peak.intensity = 0;
-            
+
             vector<pwiz::msdata::MZIntensityPair> pairs;
             spectrum->getMZIntensityPairs(pairs);
 
@@ -109,7 +109,7 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso:
             for (vector<pwiz::msdata::MZIntensityPair>::const_iterator it=pairs.begin(), end=pairs.end(); it!=end; ++it)
             {
                 //qDebug() << "it->mz " << it->mz << " it->intensity" << it->intensity;
-                if (mass_range.contains(it->mz)){
+                if (mass_range.contains(it->mz)) {
                     if (method == XixExtactMethod::max) {
                         if (peak.intensity < it->intensity) {
                             peak.intensity = it->intensity;
@@ -120,7 +120,7 @@ void getXicFromPwizMSDataFile(pwiz::msdata::MSDataFile * p_ms_data_file, pappso:
                     }
                 }
             }
-            
+
             p_xic->push_back(peak);
         }
 
@@ -259,13 +259,13 @@ pappso::QualifiedSpectrum getQualifiedSpectrumFromPwizMSDataFile(pwiz::msdata::M
     return qspectrum;
 }
 
-std::map<MsRunSp, pwiz::msdata::MSDataFile *> create_map()
+std::map<const MsRun *, pwiz::msdata::MSDataFile *> create_map()
 {
-    std::map<MsRunSp, pwiz::msdata::MSDataFile *> m;
+    std::map<const MsRun *, pwiz::msdata::MSDataFile *> m;
     return m;
 }
 
-std::map<MsRunSp, pwiz::msdata::MSDataFile *> SpectrumStore::_map_msrun_msdatafile = create_map();
+std::map<const MsRun *, pwiz::msdata::MSDataFile *> SpectrumStore::_map_msrun_msdatafile = create_map();
 
 
 const QString SpectrumStore::findMzFile(const QString &filename) {
@@ -300,14 +300,14 @@ const QString SpectrumStore::findMzFile(const QString &filename) {
     return QString();
 }
 
-void SpectrumStore::checkMsRunStatistics(MsRunSp msrun) {
-    QVariant msrun_var = msrun.get()->getMsRunStatistics(MsRunStatistics::total_spectra);
+void SpectrumStore::checkMsRunStatistics(MsRun * msrun) {
+    QVariant msrun_var = msrun->getMsRunStatistics(MsRunStatistics::total_spectra);
     if (msrun_var.isNull()) {
         try {
             pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(msrun);
             const pwiz::msdata::SpectrumList * p_spectrum_list = p_msdatafile->run.spectrumListPtr.get();
             std::size_t spectrum_list_size = p_spectrum_list->size();
-            msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size);
+            msrun->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size);
 
             unsigned int count_mslevel[50] = {0};
             for (std::size_t i=0; i < spectrum_list_size; i++) {
@@ -316,10 +316,10 @@ void SpectrumStore::checkMsRunStatistics(MsRunSp msrun) {
                 count_mslevel[msLevel]++;
             }
 
-            msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size);
-            msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms1, (unsigned int) count_mslevel[1]);
-            msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms2, (unsigned int) count_mslevel[2]);
-            msrun.get()->setMsRunStatistics(MsRunStatistics::total_spectra_ms3, (unsigned int) count_mslevel[3]);
+            msrun->setMsRunStatistics(MsRunStatistics::total_spectra, (unsigned int) spectrum_list_size);
+            msrun->setMsRunStatistics(MsRunStatistics::total_spectra_ms1, (unsigned int) count_mslevel[1]);
+            msrun->setMsRunStatistics(MsRunStatistics::total_spectra_ms2, (unsigned int) count_mslevel[2]);
+            msrun->setMsRunStatistics(MsRunStatistics::total_spectra_ms3, (unsigned int) count_mslevel[3]);
         }
         catch (pappso::ExceptionNotFound& error) {
             //no file found, no statistics
@@ -327,22 +327,35 @@ void SpectrumStore::checkMsRunStatistics(MsRunSp msrun) {
     }
 }
 
-pwiz::msdata::MSDataFile * SpectrumStore::findPwizMSDataFile(MsRunSp msrun) {
+pwiz::msdata::MSDataFile * SpectrumStore::findPwizMSDataFile(const MsRun * p_msrun) {
+    pwiz::msdata::MSDataFile * p_msdatafile = nullptr;
+    std::map<const MsRun *, pwiz::msdata::MSDataFile *>::iterator it_msdata = _map_msrun_msdatafile.find(p_msrun);
+    if (it_msdata == _map_msrun_msdatafile.end()) {
+        //not found
+        throw pappso::ExceptionNotFound(QObject::tr("mz data \"%1\" file not found").arg(p_msrun->getFilename()));
+    }
+    else {
+        p_msdatafile =it_msdata->second;
+    }
+    return p_msdatafile;
+}
+
+pwiz::msdata::MSDataFile * SpectrumStore::findPwizMSDataFile(MsRun * p_msrun) {
     pwiz::msdata::MSDataFile * p_msdatafile = nullptr;
-    std::map<MsRunSp, pwiz::msdata::MSDataFile *>::iterator it_msdata = _map_msrun_msdatafile.find(msrun);
+    std::map<const MsRun *, pwiz::msdata::MSDataFile *>::iterator it_msdata = _map_msrun_msdatafile.find(p_msrun);
     if (it_msdata == _map_msrun_msdatafile.end()) {
         //not found
 
-        QString mz_file = findMzFile(msrun.get()->getFilename());
+        QString mz_file = findMzFile(p_msrun->getFilename());
         if (mz_file.isEmpty()) {
-            qDebug() << "SpectrumStore::getSpectrumSpFromMsRunIdSp ERROR file not found " << msrun.get()->getFilename();
-            throw pappso::ExceptionNotFound(QObject::tr("mz data \"%1\" file not found").arg(msrun.get()->getFilename()));
+            qDebug() << "SpectrumStore::getSpectrumSpFromMsRunIdSp ERROR file not found " << p_msrun->getFilename();
+            throw pappso::ExceptionNotFound(QObject::tr("mz data \"%1\" file not found").arg(p_msrun->getFilename()));
             //return spectrum;
         }
-        msrun.get()->setFilename(mz_file);
+        p_msrun->setFilename(mz_file);
         p_msdatafile = getPwizMSDataFile(mz_file);
         //msrun.get()->setMzFormat(getPwizMSDataFileFormat(p_msdatafile));
-        _map_msrun_msdatafile.insert(std::pair<MsRunSp, pwiz::msdata::MSDataFile *>(msrun, p_msdatafile));
+        _map_msrun_msdatafile.insert(std::pair<const MsRun *, pwiz::msdata::MSDataFile *>(p_msrun, p_msdatafile));
     }
     else {
         p_msdatafile =it_msdata->second;
@@ -350,7 +363,7 @@ pwiz::msdata::MSDataFile * SpectrumStore::findPwizMSDataFile(MsRunSp msrun) {
     return p_msdatafile;
 }
 
-pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRunSp msrun, unsigned int scan_num) {
+pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRun * msrun, unsigned int scan_num) {
     pappso::QualifiedSpectrum spectrum;
     pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(msrun);
 
@@ -358,7 +371,7 @@ pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRunSp msrun, unsign
         return spectrum.getOriginalSpectrumSp();
     }
     spectrum = getQualifiedSpectrumFromPwizMSDataFile(p_msdatafile, scan_num);
-    if (msrun.get()->getMzFormat() == MzFormat::MGF) {
+    if (msrun->getMzFormat() == MzFormat::MGF) {
         if (spectrum.getRtInSeconds() == 0) {
             spectrum = getQualifiedSpectrumFromPwizMSDataFile(p_msdatafile, scan_num-1);
         }
@@ -367,14 +380,16 @@ pappso::SpectrumSp SpectrumStore::getSpectrumSpFromMsRunSp(MsRunSp msrun, unsign
 
 }
 
-pappso::XicSp SpectrumStore::getXicSpFromMsRunSp(MsRunSp msrun, const pappso::MassRange & mass_range, XixExtactMethod method) {
-    pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(msrun);
+pappso::XicSp SpectrumStore::getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XixExtactMethod method) {
+    qDebug() << "SpectrumStore::getXicSpFromMsRunSp begin" ;
+    pwiz::msdata::MSDataFile * p_msdatafile = findPwizMSDataFile(p_msrun);
 
     XicSp xic_sp;
-    if (p_msdatafile == nullptr) {
-        Xix xic;
+    if (p_msdatafile != nullptr) {
+        Xic xic;
         getXicFromPwizMSDataFile(p_msdatafile, &xic, mass_range, method);
         xic_sp = xic.makeXicSp();
+        qDebug() << "SpectrumStore::getXicSpFromMsRunSp end"  << xic_sp.get()->size();
     }
     return (xic_sp);
 }
diff --git a/src/utils/readspectrum.h b/src/utils/readspectrum.h
index 507bb2fd524f2a10c9f628c7236be97de82a473d..c8eef8cc1f1e9e04c51159d1ff41f4563db6b13e 100644
--- a/src/utils/readspectrum.h
+++ b/src/utils/readspectrum.h
@@ -42,15 +42,16 @@ class MSDataFile;
 
 class SpectrumStore {
 public:
-    static pappso::SpectrumSp getSpectrumSpFromMsRunSp(MsRunSp msrun, unsigned int scan_num);
-    static pappso::XicSp getXicSpFromMsRunSp(MsRunSp msrun, const pappso::MassRange & mass_range, XixExtactMethod method);
+    static pappso::SpectrumSp getSpectrumSpFromMsRunSp(MsRun * p_msrun, unsigned int scan_num);
+    static pappso::XicSp getXicSpFromMsRunSp(const MsRun * p_msrun, const pappso::MassRange & mass_range, XixExtactMethod method);
     /** @brief try to find MS run statistics
      */
-    static void checkMsRunStatistics(MsRunSp msrun);
+    static void checkMsRunStatistics(MsRun *);
 private:
     static const QString findMzFile(const QString &filename);
-    static pwiz::msdata::MSDataFile * findPwizMSDataFile(MsRunSp msrun) ;
+    static pwiz::msdata::MSDataFile * findPwizMSDataFile(MsRun * p_msrun) ;
+    static pwiz::msdata::MSDataFile * findPwizMSDataFile(const MsRun * p_msrun) ;
 private:
-    static std::map<MsRunSp, pwiz::msdata::MSDataFile *> _map_msrun_msdatafile;
+    static std::map<const MsRun *, pwiz::msdata::MSDataFile *> _map_msrun_msdatafile;
 };
 #endif // READSPECTRUM_H