Changeset 10899 for trunk/FACT++


Ignore:
Timestamp:
06/01/11 15:27:21 (13 years ago)
Author:
lyard
Message:
various changes, improved path handling, removed run-logs
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/dataLogger.cc

    r10898 r10899  
    9696///Run number record. Used to keep track of which run numbers are still active
    9797struct RunNumberType {
     98#ifdef RUN_LOGS
    9899    ///the run number log file
    99     ofstream* logFile;
     100    shared_ptr<ofstream> logFile;
     101#endif
    100102    ///the run number report file
    101     ofstream* reportFile;
     103    shared_ptr<ofstream> reportFile;
    102104#ifdef HAVE_FITS
    103105    ///the run number group fits file
    104     CCfits::FITS* runFitsFile;
    105 #endif
     106    shared_ptr<CCfits::FITS> runFitsFile;
     107#endif
     108#ifdef RUN_LOGS
    106109    ///the log filename
    107110    string logName;
     111#endif
    108112    ///the report filename
    109113    string reportName;
     
    112116    ///the time at which the run number was received
    113117    Time time;
    114     ///internal counter used for smart referencing
    115     int* numCopies;
    116118    ///list of opened fits used to create the fits grouping when the run ends
    117119    map<string, vector<string> > openedFits;
     
    119121    RunNumberType()
    120122    {
    121         logFile = new ofstream();
    122         reportFile = new ofstream();
     123#ifdef RUN_LOGS
     124        logFile = shared_ptr<ofstream>(new ofstream());
     125#endif
     126        reportFile = shared_ptr<ofstream>(new ofstream());
    123127#ifdef HAVE_FITS
    124         runFitsFile = NULL;
     128        runFitsFile = shared_ptr<CCfits::FITS>();
    125129#endif
    126130        runNumber = 0;
    127131        //give it a meaningless, 0 time to distinguish with actual, valid times
    128132        time = Time(0,0);
    129         numCopies = new int(1);
    130133    }
    131134    ///default destructor
    132135    ~RunNumberType()
    133136    {
    134         if (numCopies)
    135         {
    136             (*numCopies)--;
    137             if (*numCopies < 1)
    138             {
    139                 if (logFile)
    140                 {
    141                     if (logFile->is_open())
    142                         logFile->close();
    143                     delete logFile;
    144                     logFile = NULL;
    145                 }
    146                 if (reportFile)
    147                 {
    148                     if (reportFile->is_open())
    149                         reportFile->close();
    150                     delete reportFile;
    151                     reportFile = NULL;
    152                 }
    153 #ifdef HAVE_FITS
    154                 if (runFitsFile)
    155                 {
    156                     delete runFitsFile;
    157                     runFitsFile = NULL;
    158                 }
    159 #endif
    160                 delete numCopies;
    161                 numCopies = NULL;
    162             }
    163         }
     137
    164138    }
    165139    ///copy operator
    166140    void operator = (const RunNumberType& other)
    167141    {
     142#ifdef RUN_LOGS
    168143        logFile = other.logFile;
     144        logName = other.logName;
     145#endif
    169146        reportFile = other.reportFile;
    170         logName = other.logName;
    171147        reportName = other.reportName;
    172148        runNumber = other.runNumber;
    173149        time = other.time;
    174         numCopies = other.numCopies;
    175150#ifdef HAVE_FITS
    176151        runFitsFile = other.runFitsFile;
    177152#endif
    178         (*numCopies)++;
    179153    }
    180154    ///copy constructor
    181155    RunNumberType(const RunNumberType& other)
    182156    {
     157#ifdef RUN_LOGS
    183158        logFile = other.logFile;
     159        logName = other.logName;
     160#endif
    184161        reportFile = other.reportFile;
    185         logName = other.logName;
    186162        reportName = other.reportName;
    187163        runNumber = other.runNumber;
    188164        time = other.time;
    189         numCopies = other.numCopies;
    190165#ifdef HAVE_FITS
    191166        runFitsFile = other.runFitsFile;
    192167#endif
    193         (*numCopies)++;
    194168    }
    195169
     
    220194#endif
    221195    ///the actual dimInfo pointer
    222     DimStampedInfo* dimInfo;
     196    shared_ptr<DimStampedInfo> dimInfo;
    223197    ///the server
    224198    string server;
     
    226200    string service;
    227201    ///the converter for outputting the data according to the format
    228     Converter* fConv;
    229     ///internal counter used for smart referencing
    230     int* numCopies;
     202    shared_ptr<Converter> fConv;
    231203    ///the current run number used by this subscription
    232204    uint32_t runNumber;
     
    241213        server = other.server;
    242214        service = other.service;
    243         numCopies = other.numCopies;
    244215        fConv = other.fConv;
    245216        runNumber = other.runNumber;
    246         (*numCopies)++;
    247217    }
    248218    ///copy constructor
     
    256226        server = other.server;
    257227        service = other.service;
    258         numCopies = other.numCopies;
    259228        fConv = other.fConv;
    260229        runNumber = other.runNumber;
    261         (*numCopies)++;
    262230    }
    263231    ///Dim info constructor
    264232    SubscriptionType(DimStampedInfo* info)
    265233    {
    266         dimInfo = info;
    267         fConv = NULL;
     234        dimInfo = shared_ptr<DimStampedInfo>(info);
     235        fConv = shared_ptr<Converter>();
    268236        runNumber = 0;
    269         numCopies = new int(1);
    270237    }
    271238    ///default constructor
    272239    SubscriptionType()
    273240    {
    274         dimInfo = NULL;
    275         fConv = NULL;
     241        dimInfo = shared_ptr<DimStampedInfo>();
     242        fConv = shared_ptr<Converter>();
    276243        runNumber = 0;
    277         numCopies = new int(1);
    278244    }
    279245    ///default destructor
    280246    ~SubscriptionType()
    281247    {
    282         if (numCopies)
    283             (*numCopies)--;
    284         if (numCopies)
    285         if (*numCopies < 1)
    286         {
    287             if (dimInfo)
    288             delete dimInfo;
    289 #ifdef HAVE_FITS
    290             if (nightlyFile.IsOpen())
    291                 nightlyFile.Close();
    292             if (runFile.IsOpen())
    293                 runFile.Close();
    294 #endif
    295             if (numCopies)
    296             delete numCopies;
    297             delete fConv;
    298             fConv = NULL;
    299             dimInfo = NULL;
    300             numCopies = NULL;
    301         }
    302248    }
    303249};
     
    473419    ///retrieves the size of a file
    474420    off_t GetFileSize(string&);
     421    ///Get the digits of year, month and day for filenames and paths
     422    void GetYearMonthDayForFiles(unsigned short& year, unsigned short& month, unsigned short& day);
     423    ///Appends the relevant year month day to a given path
     424    void AppendYearMonthDaytoPath(string& path);
     425    ///Form the base nightly path
     426    void FormBaseNightlyPath(string& path);
     427    ///Form the base run path
     428    void FormBaseRunPath(string& path, const int runNumber);
    475429    ///Form the base (without extension) name of the nightly text files (logs and reports)
    476430    void FormBaseNightlyTextFileName(string& name);
     
    501455    ///Checks if the input osftream is in error state, and if so close it.
    502456    void CheckForOfstreamError(ofstream& out);
     457    ///Checks if a given path exist
     458    bool DoesPathExist(string path);
     459    ///Create a given directory
     460    bool CreateDirectory(string path);
    503461    /***************************************************
    504462    * INHERITED FROM DIMSERVICEINFOLIST
     
    514472// --------------------------------------------------------------------------
    515473//
     474//! Check if a given path exists
     475//! @param path the path to be checked
     476//! @return whether or not the creation has been successfull
     477//
     478bool DataLogger::CreateDirectory(string path)
     479{
     480    mode_t rightsMask = S_IRWXU | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH; //everybody read, owner writes
     481
     482    int returnValue = mkdir(path.c_str(), rightsMask);
     483
     484    if (returnValue != 0)
     485    {
     486        ostringstream str;
     487        str << "Could not create directory " << path << " mkdir error code: " << errno;
     488        Error(str.str());
     489        return false;
     490    }
     491
     492    return true;
     493}
     494// --------------------------------------------------------------------------
     495//
     496//! Check if a given path exists
     497//! @param path the path to be checked
     498//! @return whether or not the given path exists
     499//
     500bool DataLogger::DoesPathExist(string path)
     501{
     502    struct stat st;
     503    if(stat(path.c_str(),&st) == 0)
     504        return true;
     505
     506    return false;
     507}
     508// --------------------------------------------------------------------------
     509//
    516510//! Add a new service subscription
    517511//! @param server the server for which the subscription should be created
    518512//! @param service the service for which the subscription should be created
    519513//! @param isCmd whether this is a Dim Command or not. Commands are not logged
    520 //TODO maybe commands should indeed be logged ?
    521514//
    522515void DataLogger::AddService(const string& server, const string& service, const string&, bool isCmd)
     
    525518    if (!ShouldSubscribe(server, service))
    526519        return;
    527     //dataLogger does not subscribe to commands
     520
     521         //dataLogger does not subscribe to commands
    528522    if (isCmd)
    529523        return;
    530     //do we already have an entry for that server ?
    531     SubscriptionsListType::iterator cSubs = fServiceSubscriptions.find(server);
    532     if (cSubs != fServiceSubscriptions.end())
    533     {//server already here. check its services
    534         if (cSubs->second.find(service) == cSubs->second.end())
    535         {//service not found. Add it
    536             cSubs->second[service].dimInfo = SubscribeToPlease(server, service);
    537             cSubs->second[service].server = server;
    538             cSubs->second[service].service = service;
    539         }
    540         else
    541         {
    542             MessageImp::Error("Service " + server + "/" + service + " is already in the dataLogger's list. ignoring its update.");
    543             return;
    544         }
    545     }
    546     else
    547     {//server not yet in our list. add it
    548         fServiceSubscriptions[server] = map<string, SubscriptionType>();
    549         map<string, SubscriptionType>& liste = fServiceSubscriptions[server];
    550         liste[service].dimInfo = SubscribeToPlease(server, service);
    551         liste[service].server = server;
    552         liste[service].service = service;
    553     }
     524
     525    map<string, SubscriptionType> &list = fServiceSubscriptions[server];
     526
     527    if (list.find(service) != list.end())
     528    {
     529        Error("Service " + server + "/" + service + " is already in the dataLogger's list. ignoring its update.");
     530        return;
     531    }
     532
     533    list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
     534    list[service].server  = server;
     535    list[service].service = service;
     536
    554537    if (fDebugIsOn)
    555     {
    556538        Debug("Added subscription to " + server + "/" + service);
    557     }
    558539}
    559540// --------------------------------------------------------------------------
     
    630611string DataLogger::CheckIfDirIsDot(const string& dir)
    631612{
     613    errno = 0;
    632614    if (dir == ".")
    633615    {
     
    657639void DataLogger::OpenTextFilePlease(ofstream& stream, const string& name)
    658640{
     641    errno = 0;
    659642    stream.open(name.c_str(), ios_base::out | ios_base::app);
    660643    if (errno != 0)
     
    714697    sRun << runNumber;
    715698    fileName = sRun.str() + "_group.fits";
    716     fileNameWithPath = fRunFilePath + '/' + fileName;
     699    string path;
     700    FormBaseRunPath(path, runNumber);
     701    fileNameWithPath = path + '/' + fileName;
    717702}
    718703
     
    727712{
    728713    ostringstream groupName;
     714    string path;
    729715    if (runNumber != 0)
    730716    {
    731         groupName << fRunFilePath << '/' << runNumber << ".fits";
     717        FormBaseRunPath(path, runNumber);
     718        groupName << path << '/' << runNumber << ".fits";
    732719    }
    733720    else
    734721    {
    735         Time time;
    736722        ostringstream sTime;
    737         sTime << time.Y() << "_" << time.M() << "_" << time.D();
    738         groupName << fNightlyFilePath << '/' << sTime.str() << ".fits";
     723        unsigned short year, month, day;
     724        GetYearMonthDayForFiles(year, month, day);
     725        sTime << year << "_" << month << "_" << day;
     726        FormBaseNightlyPath(path);
     727
     728        groupName << path << '/' << sTime.str() << ".fits";
    739729    }
    740730    fileNameWithPath = groupName.str();
     
    750740void DataLogger::FormNightlyFitsFileName(string& fileName, string& fileNameWithPath, const string& serviceName)
    751741{
    752     Time time;
    753742    ostringstream sTime;
    754     sTime << time.Y() << "_" << time.M() << "_" << time.D();
     743    unsigned short year, month, day;
     744    GetYearMonthDayForFiles(year, month, day);
     745    sTime << year << "_" << month << "_" << day;
    755746    fileName = sTime.str() + '_' + serviceName + ".fits";
    756     fileNameWithPath = fNightlyFilePath + '/' + fileName;
     747    string path;
     748    FormBaseNightlyPath(path);
     749    fileNameWithPath = path + '/' + fileName;
    757750}
    758751// --------------------------------------------------------------------------
     
    769762    sRun << runNumber;
    770763    fileName = sRun.str() + '_' + serviceName + ".fits";
    771     fileNameWithPath = fRunFilePath + '/' + fileName;
     764    string path;
     765    FormBaseRunPath(path, runNumber);
     766    fileNameWithPath = path + '/' + fileName;
    772767}
    773768// --------------------------------------------------------------------------
     
    781776    ostringstream sRun;
    782777    sRun << runNumber;
    783 
    784     name = CheckIfDirIsDot(fRunFilePath) + '/' + sRun.str();
     778    string path;
     779    FormBaseRunPath(path, runNumber);
     780    name = path + '/' + sRun.str();
    785781}
    786782// --------------------------------------------------------------------------
     
    807803void DataLogger::FormBaseNightlyTextFileName(string& name)
    808804{
    809     Time time;
    810805    ostringstream sTime;
    811     sTime << time.Y() << "_" << time.M() << "_" << time.D();
    812 
    813     name = CheckIfDirIsDot(fNightlyFilePath) + '/' + sTime.str();
     806    unsigned short year, month, day;
     807    GetYearMonthDayForFiles(year, month, day);
     808    sTime << year << "_" << month << "_" << day;
     809
     810    FormBaseNightlyPath(name);
     811
     812    name += '/' + sTime.str();
    814813}
    815814// --------------------------------------------------------------------------
     
    830829// --------------------------------------------------------------------------
    831830//
     831//!Fills in the correct values for naming files based on current date.
     832//! It fills in the same values throughout a whole night for consistency
     833//! @param year the year to be used for file names
     834//! @param month the month to be used for file names
     835//! @param day the day to be used for file names
     836//
     837void DataLogger::GetYearMonthDayForFiles(unsigned short& year, unsigned short& month, unsigned short& day)
     838{
     839    Time time;
     840    year = time.Y();
     841    month = time.M();
     842    day = time.D();
     843    bool shouldGoBackOneDay = false;
     844    if (time.h() < 12) //we are currently before noon. go back one day
     845        shouldGoBackOneDay = true;
     846
     847    if (shouldGoBackOneDay && (month == 1) && (day == 1))
     848        year--;
     849
     850    if (shouldGoBackOneDay && (day == 1))
     851    {
     852        if (month != 1)
     853            month--;
     854        else
     855            month = 12;
     856    }
     857
     858    if (shouldGoBackOneDay)
     859    {
     860        if (day != 1)
     861            day--;
     862        else
     863            switch (month)
     864            {
     865                case 1:
     866                case 3:
     867                case 5:
     868                case 7:
     869                case 8:
     870                case 10:
     871                case 12:
     872                    day = 31;
     873                break;
     874                case 4:
     875                case 6:
     876                case 9:
     877                case 11:
     878                    day = 30;
     879                break;
     880                case 2:
     881                    if (year == 2012 || year == 2016 || year == 2020 || year == 2024 || year == 2028 || year == 2032 || year == 2036 || year == 2040)
     882                        day = 29;
     883                    else
     884                        day = 28;
     885                break;
     886            };
     887    }
     888
     889
     890}
     891// --------------------------------------------------------------------------
     892//
     893//! Appends the appropriate year, month and day to a given path.
     894//! creates the required directories if they do not already exist
     895//! @param path the path to be augmented
     896//
     897void DataLogger::AppendYearMonthDaytoPath(string& path)
     898{
     899    ostringstream basePath;
     900    unsigned short year, month, day;
     901    GetYearMonthDayForFiles(year, month, day);
     902
     903    basePath << CheckIfDirIsDot(path) << '/' << year;
     904    if (!DoesPathExist(basePath.str()))
     905         CreateDirectory(basePath.str());
     906
     907     basePath << '/' << month;
     908     if (!DoesPathExist(basePath.str()))
     909         CreateDirectory(basePath.str());
     910
     911     basePath << '/' << day;
     912     if (!DoesPathExist(basePath.str()))
     913         CreateDirectory(basePath.str());
     914
     915     path = basePath.str();
     916}
     917// --------------------------------------------------------------------------
     918//
     919//! Forms the base path for putting nightly files in it
     920//! @param the variable that should receive the path
     921//
     922void DataLogger::FormBaseNightlyPath(string& path)
     923{
     924    path = fNightlyFilePath;
     925    AppendYearMonthDaytoPath(path);
     926}
     927// --------------------------------------------------------------------------
     928//
     929//! Forms the base path for putting run files in it
     930//! @param the variable that should receive the path
     931//! @runNumber the run number for which to create the path
     932//
     933void DataLogger::FormBaseRunPath(string& path, const int runNumber)
     934{
     935    path = fRunFilePath;
     936    AppendYearMonthDaytoPath(path);
     937
     938    ostringstream basePath;
     939    basePath << path << '/' << runNumber;
     940    if (!DoesPathExist(basePath.str()))
     941        CreateDirectory(basePath.str());
     942
     943    path = basePath.str();
     944}
     945// --------------------------------------------------------------------------
     946//
    832947//!retrieves the size on disk of a file
    833948//! @param fileName the full file name for which the size on disk should be retrieved
     
    836951off_t DataLogger::GetFileSize(string& fileName)
    837952{
     953    errno = 0;
    838954    struct stat st;
    839955    if (!stat(fileName.c_str(), &st))
     
    9351051        if (it->reportFile->is_open())
    9361052            fFileSizesMap[it->reportName] = GetFileSize(it->reportName);
     1053#ifdef RUN_LOGS
    9371054        if (it->logFile->is_open())
    9381055            fFileSizesMap[it->logName] = GetFileSize(it->logName);
     1056#endif
    9391057    }
    9401058    struct statvfs vfs;
     
    12221340    {//find current service is subscriptions
    12231341        for (y=x->second.begin(); y!=x->second.end();y++)
    1224             if (y->second.dimInfo == I)
     1342            if ((y->second.dimInfo).get() == I)
    12251343            {
    12261344                found = true;   
     
    12561374int DataLogger::OpenRunFile(RunNumberType& run)
    12571375{
     1376#ifdef RUN_LOGS
    12581377    if (run.logFile->is_open())
    12591378    {
     
    12641383    }
    12651384    FormRunTextFileName(run.logName, false, run.runNumber);
     1385    errno = 0;
    12661386    run.logFile->open(run.logName.c_str(), ios_base::out | ios_base::app);
    12671387    if (errno != 0)
     
    12711391        Error(str);
    12721392    }
     1393#endif
    12731394    //open report file
    12741395    FormRunTextFileName(run.reportName, true, run.runNumber);
     
    12801401        return -1;
    12811402    }
     1403    errno = 0;
    12821404    run.reportFile->open(run.reportName.c_str(), ios_base::out | ios_base::app);
    12831405    if (errno != 0)
     
    12881410    }
    12891411
     1412#ifdef RUN_LOGS
    12901413    if (!run.logFile->is_open() || !run.reportFile->is_open())
     1414#else
     1415    if (!run.reportFile->is_open())
     1416#endif
    12911417    {
    12921418        ostringstream str;
    1293         str << "Something went wrong while openning nightly files " << run.logName << " and " << run.reportName;
     1419        str << "Something went wrong while openning files ";
     1420#ifdef RUN_LOGS
     1421        str << run.logName << " and ";
     1422#endif
     1423        str << run.reportName;
    12941424        Error(str);
    12951425        return -1;
    12961426    }
    12971427    //get the size of the newly opened file.
     1428#ifdef RUN_LOGS
    12981429    RememberFileOrigSizePlease(run.logName, false);
     1430#endif
    12991431    RememberFileOrigSizePlease(run.reportName, false);
    13001432
     
    13821514        if (fakeFormat[fakeFormat.size()-1] == 'C')
    13831515            fakeFormat = fakeFormat.substr(0, fakeFormat.size()-1);
    1384         sub.fConv = new Converter(Out(), I->getFormat());   
     1516        sub.fConv = shared_ptr<Converter>(new Converter(Out(), I->getFormat()));
    13851517        if (!sub.fConv)
    13861518        {
     
    14101542                cRunNumber = &(*rit);
    14111543                sub.runNumber = rit->runNumber;
    1412                 targetRunFile = isItaReport ? rit->reportFile : rit->logFile;
     1544#ifdef RUN_LOGS
     1545                targetRunFile = isItaReport ? (rit->reportFile).get() : (rit->logFile).get();
     1546#else
     1547                targetRunFile = isItaReport ? (rit->reportFile).get() : NULL;
     1548#endif
    14131549                break;
    14141550            }
     
    15361672    if (fNightlyLogFile.is_open())
    15371673        Message("Nightly log-file: "/*+filename+*/" (OPEN)");
    1538     else
    1539         Message("Nightly log-file: "/*filename+*/" (CLOSED)");
     1674
    15401675    if (fNightlyReportFile.is_open())
    15411676        Message("Nightly report-file: "/*filename+*/" (OPEN)");
    1542     else
    1543         Message("Nightly report-file: "/*filename+*/" (CLOSED)");
     1677
    15441678    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it!=fRunNumber.end(); it++)
    15451679    {
     1680#ifdef RUN_LOGS
    15461681        if (it->logFile->is_open())
    15471682            Message("Run log-file: " + it->logName + " (OPEN)");
    1548         else
    1549             Message("Run log-file: " + it->logName + " (CLOSED)");
     1683#endif
    15501684        if (it->reportFile->is_open())
    15511685            Message("Run report-file: " + it->reportName + " (OPEN)");
    1552         else
    1553             Message("Run report-file: " + it->reportName + " (CLOSED)");
    15541686    }
    15551687
     
    17281860    if (evt.GetText() != NULL)
    17291861    {
    1730         fNightlyFilePath = string(evt.GetText());
     1862        string givenPath = string(evt.GetText());
     1863        if (!DoesPathExist(givenPath))
     1864        {
     1865            Error("Given Nightly folder \"" + givenPath + "\" does not exist. Please specify a valid path");
     1866            return GetCurrentState();
     1867        }
     1868        fNightlyFilePath = givenPath;
    17311869        Message("New Nightly folder specified: " + fNightlyFilePath);
    17321870    }
     
    17471885    if (evt.GetText() != NULL)
    17481886    {
    1749         fRunFilePath = string(evt.GetText());
     1887        string givenPath = string(evt.GetText());
     1888        if (!DoesPathExist(givenPath))
     1889        {
     1890            Error("Given Run folder \"" + givenPath + "\" does not exist. Please specify a valid path");
     1891            return GetCurrentState();
     1892        }
     1893        fRunFilePath = givenPath;
    17501894        Message("New Run folder specified: " + fRunFilePath);
    17511895    }
     
    19332077            try
    19342078            {
    1935                 cRunNumber->runFitsFile = new CCfits::FITS(partialName, CCfits::RWmode::Write);
     2079                cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>(new CCfits::FITS(partialName, CCfits::RWmode::Write));
    19362080                (fNumSubAndFitsData.numOpenFits)++;
    19372081            }   
     
    19412085                str << "Could not open FITS Run file " << partialName << " reason: " << e.message();
    19422086                Error(str);
    1943                 cRunNumber->runFitsFile = NULL;
     2087                cRunNumber->runFitsFile = shared_ptr<CCfits::FITS>();//NULL;
    19442088            }
    19452089
     
    19482092        NotifyOpenedFile(baseFileName, 7, fOpenedRunFiles);// + '_' + serviceName, 4);
    19492093        if (hasGrouping)
    1950             sub.runFile.Open(partialName, serviceName, cRunNumber->runFitsFile, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber);//Out());
     2094            sub.runFile.Open(partialName, serviceName, (cRunNumber->runFitsFile).get(), &fNumSubAndFitsData.numOpenFits, this, sub.runNumber);//Out());
    19512095        else
    19522096            sub.runFile.Open(partialName, serviceName, NULL, &fNumSubAndFitsData.numOpenFits, this, sub.runNumber);//Out());
     
    20512195        if (sub.nightlyFile.IsOpen())
    20522196        {
    2053             sub.nightlyFile.Write(sub.fConv);
     2197            sub.nightlyFile.Write(sub.fConv.get());
    20542198            if (fDebugIsOn)
    20552199            {
     
    20592203        if (sub.runFile.IsOpen())
    20602204        {
    2061             sub.runFile.Write(sub.fConv);
     2205            sub.runFile.Write(sub.fConv.get());
    20622206            if (fDebugIsOn)
    20632207            {
     
    21632307    const unsigned int n = 8 + 3 + 2*maxCharLength + 1; //+1 for trailling character
    21642308
    2165     unsigned char* fitsBuffer = new unsigned char[n];
     2309    vector<unsigned char> realBuffer;
     2310    realBuffer.resize(n);
     2311    unsigned char* fitsBuffer = &realBuffer[0];
    21662312    memset(fitsBuffer, 0, n);
    21672313
     
    22182364    for (list<RunNumberType>::iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
    22192365    {
     2366#ifdef RUN_LOGS
    22202367        if (!it->logFile->is_open() || !it->reportFile->is_open())
     2368#else
     2369        if (!it->reportFile->is_open())
     2370#endif
    22212371            return kSM_FatalError;
     2372#ifdef RUN_LOGS
    22222373        it->logFile->close();
     2374#endif
    22232375        it->reportFile->close();
    22242376    }
Note: See TracChangeset for help on using the changeset viewer.