Index: fact/tools/marsmacros/mc2csv/MonteCarlo.C
===================================================================
--- fact/tools/marsmacros/mc2csv/MonteCarlo.C	(revision 14625)
+++ fact/tools/marsmacros/mc2csv/MonteCarlo.C	(revision 14657)
@@ -600,5 +600,4 @@
 }
 
-
 void
 MonteCarlo::WriteMc2Csv(TString filename)
@@ -616,9 +615,13 @@
     OpenCsvFile(mCsvFileName);
 
-    WriteFileHeader2Csv();
-    WriteRunHeaderNames2Csv();
+    WriteFileInfo2Csv();
+    WriteRunHeaderInfo2Csv();
     WriteRunHeader2Csv();
-    WriteEventHeaderNames2Csv();
-    WriteEventDataNames2Csv();
+
+    WritePedestalInfo2Csv();
+    WritePedestal2Csv();
+
+    WriteEventHeaderInfo2Csv();
+    WriteEventDataInfo2Csv();
 
 //    for (int evt = 0; evt < mNumberOfEvents; evt++)
@@ -636,55 +639,92 @@
 }
 
-
-void
-MonteCarlo::WritePixelData2Csv(int pixelID)
-{
-    if (mVerbosityLvl > 3) cout << "...writing pixel data to csv" << endl;
-    mCsv << mEventNumber << mSeparator;
-    mCsv << mpPixel[pixelID].SoftId << mSeparator;
-    mCsv << mpPixel[pixelID].pedestal << mSeparator;
-
-    for (int i = 0; i < mNumberOfSamples; i++)
-    {
-         mCsv << mpPixel[pixelID].rawData[i] << mSeparator;
-    }
-    mCsv << endl;
-
-    return;
-}
-
-void
-MonteCarlo::WriteEventData2Csv()
-{
-    if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
-
-    for (int i = 0; i < mNumberOfPixels; i++)
-    {
-        WritePixelData2Csv(i);
-    }
-
-    return;
-}
-
-void
-MonteCarlo::WriteEventDataNames2Csv()
-{
-    if (mVerbosityLvl > 0) cout << "...writing event categories to csv" << endl;
-
-    mCsv << "### [RawData]" << endl;
-    mCsv << "# mEventNumber" << mSeparator;
-    mCsv << "pixelID" << mSeparator;
-     mCsv << "pixelPedestal" << mSeparator;
-    for (int i = 0; i < mNumberOfSamples; i++)
-    {
-        mCsv << "Raw_" << i << mSeparator;
-    }
-    mCsv << endl;
-
-    return;
-}
-
-void
-MonteCarlo::WriteEventHeaderNames2Csv()
+void
+MonteCarlo::WriteFileInfo2Csv()
+{
+    if (mVerbosityLvl > 0) cout << "...writing file header to csv" << endl;
+
+    mCsv << "### ==========================================================="
+            << endl;
+    mCsv << "### =             FACT Monte Carlo                            ="
+            << endl;
+    mCsv << "### ==========================================================="
+            << endl;
+    mCsv << "### = FileInfo:                                               "
+            << endl;
+    mCsv << "### =                                                         "
+            << endl;
+    mCsv << "### = Source Name:       " << mSourceName << endl;
+    mCsv << "### = Number of Entries: " << mNumberOfEntries << endl;
+    mCsv << "### = Run Number:        " << mRunNumber << endl;
+    mCsv << "### = Run Type  :        " << mRunType << endl;
+    mCsv << "### = File Number:       " << mFileNumber << endl;
+    mCsv << "### ==========================================================="
+         << endl ;
+    mCsv << "###"
+         << endl ;
+
+    return;
+}
+
+void
+MonteCarlo::WriteRunHeaderInfo2Csv()
+{
+    if (mVerbosityLvl > 0) cout << "...writing run header names to csv" << endl;
+
+    mCsv << "### [RunHeader]" << endl;
+
+    mCsv << "# mNumberOfEntries" << mSeparator;
+    mCsv << "mIntendedPulsePos" << mSeparator;
+//    Csv << "mPedestalOffset" << mSeparator;
+    mCsv << "mNumSimulatedShowers" << mSeparator;
+    mCsv << "mNumberOfPixels" << mSeparator;
+    mCsv << "mNumberOfSamples" << mSeparator;
+//    mCsv << "mSampleSize" << mSeparator;
+    mCsv << "mCamDist" << mSeparator;
+    mCsv << "mSourceName" << mSeparator;
+    mCsv << "mSlopeSpectrum" << mSeparator;
+    mCsv << "mEnergyMin" << mSeparator;
+    mCsv << "mEnergyMax" << mSeparator;
+    mCsv << "mZdMin" << mSeparator;
+    mCsv << "mZdMax" << mSeparator;
+    mCsv << "mAzMin" << mSeparator;
+    mCsv << "mAzMax" << mSeparator;
+    mCsv << "mFileNumber" << mSeparator;
+    mCsv << "mRunnumber" << mSeparator;
+    mCsv << "mRunType" << endl;
+
+    return;
+}
+
+void
+MonteCarlo::WriteRunHeader2Csv()
+{
+    if (mVerbosityLvl > 0) cout << "...writing run header to csv" << endl;
+
+    mCsv << mNumberOfEntries << mSeparator;
+    mCsv << mIntendedPulsePos << mSeparator;
+//    mCsv << mPedestalOffset << mSeparator;
+    mCsv << mNumSimulatedShowers << mSeparator;
+    mCsv << mNumberOfPixels << mSeparator;
+    mCsv << mNumberOfSamples << mSeparator;
+//    mCsv << mSampleSize << mSeparator;
+    mCsv << mCamDist << mSeparator;
+    mCsv << mSourceName << mSeparator;
+    mCsv << mSlopeSpectrum << mSeparator;
+    mCsv << mEnergyMin << mSeparator;
+    mCsv << mEnergyMax << mSeparator;
+    mCsv << mZdMin << mSeparator;
+    mCsv << mZdMax << mSeparator;
+    mCsv << mAzMin << mSeparator;
+    mCsv << mAzMax << mSeparator;
+    mCsv << mFileNumber << mSeparator;
+    mCsv << mRunNumber << mSeparator;
+    mCsv << mRunType << endl;
+
+    return;
+}
+
+void
+MonteCarlo::WriteEventHeaderInfo2Csv()
 {
     if (mVerbosityLvl > 0) cout << "...writing event header names to csv" << endl;
@@ -720,5 +760,4 @@
 }
 
-
 void
 MonteCarlo::WriteEventHeader2Csv()
@@ -755,90 +794,76 @@
 
 void
-MonteCarlo::WriteRunHeaderNames2Csv()
-{
-    if (mVerbosityLvl > 0) cout << "...writing run header names to csv" << endl;
-
-    mCsv << "### [RunHeader]" << endl;
-
-    mCsv << "# mNumberOfEntries" << mSeparator;
-    mCsv << "mIntendedPulsePos" << mSeparator;
-//    Csv << "mPedestalOffset" << mSeparator;
-    mCsv << "mNumSimulatedShowers" << mSeparator;
-    mCsv << "mNumberOfPixels" << mSeparator;
-    mCsv << "mNumberOfSamples" << mSeparator;
-//    mCsv << "mSampleSize" << mSeparator;
-    mCsv << "mCamDist" << mSeparator;
-    mCsv << "mSourceName" << mSeparator;
-    mCsv << "mSlopeSpectrum" << mSeparator;
-    mCsv << "mEnergyMin" << mSeparator;
-    mCsv << "mEnergyMax" << mSeparator;
-    mCsv << "mZdMin" << mSeparator;
-    mCsv << "mZdMax" << mSeparator;
-    mCsv << "mAzMin" << mSeparator;
-    mCsv << "mAzMax" << mSeparator;
-    mCsv << "mFileNumber" << mSeparator;
-    mCsv << "mRunnumber" << mSeparator;
-    mCsv << "mRunType" << endl;
-
-    return;
-}
-
-
-void
-MonteCarlo::WriteRunHeader2Csv()
-{
-    if (mVerbosityLvl > 0) cout << "...writing run header to csv" << endl;
-
-    mCsv << mNumberOfEntries << mSeparator;
-    mCsv << mIntendedPulsePos << mSeparator;
-//    mCsv << mPedestalOffset << mSeparator;
-    mCsv << mNumSimulatedShowers << mSeparator;
-    mCsv << mNumberOfPixels << mSeparator;
-    mCsv << mNumberOfSamples << mSeparator;
-//    mCsv << mSampleSize << mSeparator;
-    mCsv << mCamDist << mSeparator;
-    mCsv << mSourceName << mSeparator;
-    mCsv << mSlopeSpectrum << mSeparator;
-    mCsv << mEnergyMin << mSeparator;
-    mCsv << mEnergyMax << mSeparator;
-    mCsv << mZdMin << mSeparator;
-    mCsv << mZdMax << mSeparator;
-    mCsv << mAzMin << mSeparator;
-    mCsv << mAzMax << mSeparator;
-    mCsv << mFileNumber << mSeparator;
-    mCsv << mRunNumber << mSeparator;
-    mCsv << mRunType << endl;
-
-    return;
-}
-
-void
-MonteCarlo::WriteFileHeader2Csv()
-{
-    if (mVerbosityLvl > 0) cout << "...writing file header to csv" << endl;
-
-    mCsv << "### ==========================================================="
-            << endl;
-    mCsv << "### =             FACT Monte Carlo                            ="
-            << endl;
-    mCsv << "### ==========================================================="
-            << endl;
-    mCsv << "### = FileInfo:                                               "
-            << endl;
-    mCsv << "### =                                                         "
-            << endl;
-    mCsv << "### = Source Name:       " << mSourceName << endl;
-    mCsv << "### = Number of Entries: " << mNumberOfEntries << endl;
-    mCsv << "### = Run Number:        " << mRunNumber << endl;
-    mCsv << "### = Run Type  :        " << mRunType << endl;
-    mCsv << "### = File Number:       " << mFileNumber << endl;
-    mCsv << "### ==========================================================="
-         << endl ;
-    mCsv << "###"
-         << endl ;
-
-    return;
-}
-
+MonteCarlo::WriteEventDataInfo2Csv()
+{
+    if (mVerbosityLvl > 0) cout << "...writing event categories to csv" << endl;
+
+    mCsv << "### [RawData]" << endl;
+    mCsv << "# mEventNumber" << mSeparator;
+    mCsv << "pixelID" << mSeparator;
+//     mCsv << "pixelPedestal" << mSeparator;
+    for (int i = 0; i < mNumberOfSamples; i++)
+    {
+        mCsv << "Raw_" << i << mSeparator;
+    }
+    mCsv << endl;
+
+    return;
+}
+
+void
+MonteCarlo::WriteEventData2Csv()
+{
+    if (mVerbosityLvl > 0) cout << "...writing event data to csv" << endl;
+
+    for (int i = 0; i < mNumberOfPixels; i++)
+    {
+        WritePixelData2Csv(i);
+    }
+
+    return;
+}
+
+void
+MonteCarlo::WritePixelData2Csv(int pixelID)
+{
+    if (mVerbosityLvl > 3) cout << "...writing pixel data to csv" << endl;
+    mCsv << mEventNumber << mSeparator;
+    mCsv << mpPixel[pixelID].SoftId << mSeparator;
+//    mCsv << mpPixel[pixelID].pedestal << mSeparator;
+
+    for (int i = 0; i < mNumberOfSamples; i++)
+    {
+         mCsv << mpPixel[pixelID].rawData[i] << mSeparator;
+    }
+    mCsv << endl;
+
+    return;
+}
+
+void
+MonteCarlo::WritePedestalInfo2Csv()
+{
+    mCsv << "### [Pedestal info]" << endl;
+    mCsv << "# SoftID" ;
+    mCsv << mSeparator ;
+    mCsv << "Pedestal" << endl;
+}
+
+void
+MonteCarlo::WritePedestal2Csv()
+{
+    if (mVerbosityLvl > 3) cout << "...writing pedestal info to csv" << endl;
+
+    for (int pixelID = 0; pixelID < mNumberOfPixels; pixelID++)
+    {
+        mCsv << mpPixel[pixelID].SoftId;
+        mCsv << mSeparator;
+        mCsv << mpPixel[pixelID].pedestal;
+        mCsv << endl;
+    }
+    mCsv << endl;
+
+    return;
+}
 
 
@@ -847,6 +872,4 @@
 //
 //
-
-
 //  FADC samples (hi gain) of all pixels
 //  This is an array of Byte_t variables. The value of a FADC sample has a
@@ -859,77 +882,4 @@
 
 
-/*
-int extractMC()
-{
-
-    TTree *tree = (TTree*)f.Get("Events");
-
-//    MArrayB *array = NULL;
-
-    const float dconv = 2000/4096;
-
-    unsigned short *short_array;
-    TH1F histo("histo", "histo", 150, 0, 150);
-
-    TCanvas *canvas = new TCanvas("canvas", "canvas", 0, 0, 400, 400 );
-    canvas->cd();
-    tree->SetBranchAddress("MRawEvtData.", &branch1);
-
-    tree->GetEntry(22);
-
-    cout << "Branch1 " << branch1 << endl;
-
-    array = branch1->GetSamples();
-
-
-    for(int i = 0; i < 150; i++){
-        cout << "i_" << i << "\t 1. " << short_array[i] ;
-        short_array[i] = le16toh(short_array[i]);
-
-//        uint16_t htobe16(uint16_t host_16bits);
-//        uint16_t htole16(uint16_t host_16bits);
-//        uint16_t be16toh(uint16_t big_endian_16bits);
-
-
-        cout << "\t 2. " << short_array[i] ;
-        cout << "\t arr. " << (int)array[2*i] << " " << (int)array[2*i+1] << endl;
-
-        histo.SetBinContent(i, short_array[i]-1000);
-    }
-    histo.DrawCopy();
-    canvas->Modified();
-    canvas->Update();
-
-//    int m = branch1->GetNumHiGainSamples();
-//    int n = branch1->GetNumBytesPerSample();
-
-    cout << "GetNumHiGainSamples " << branch1->GetNumHiGainSamples()
-         << " GetNumBytesPerSample " << branch1->GetNumBytesPerSample() << endl;
-
-//    tree->GetEntry(2);
-
-//    array = branch1->GetSamples();
-
-//    cout << "Branch2 " << branch1 << endl;
-
-////    for(int i = 1439; i < 1441; i++){
-////        cout << "Pixel: " << i << endl;
-
-//        for(int j = 431950; j < 432020; j++){
-//            cout << "Sl: " << j << "\t" ;
-//            cout << (unsigned short) array[j] << "\t";
-//            if ( j%5 == 0 ) cout <<endl;
-
-//        }
-//        cout << endl;
-////    }
-
-////    tree->SetBranchAddress("MRawEvtData.fHiGainFadcSamples.fArray", array);
-
-}
-
-*/
-
-
-
-
+
+
