Changeset 14791 for trunk/FACT++/gui


Ignore:
Timestamp:
Jan 28, 2013, 10:21:39 AM (6 years ago)
Author:
lyard
Message:
Added Monte-Carlo data support. Disable 3D viewer.
Location:
trunk/FACT++/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/gui/Q3DCameraWidget.cc

    r14304 r14791  
    163163    void Q3DCameraWidget::setData(float* ddata)
    164164    {
    165         for (int i=0;i<1440;i++)
     165        cout << "Info : 3D plotter disabled. requires more work so that less than 300 slices per pixel can be loaded" << endl;
     166        cout << "Contact Etienne (etienne.lyard@unige.ch) for more information." << endl;
     167        //disabled for now as I am working with 150 slices only
     168/*        for (int i=0;i<1440;i++)
    166169            for (int j=0;j<300;j++)
    167170            _data[i*300+j] = (short)(ddata[i*300 + j]);
     
    169172        if (isVisible())
    170173            updateGL();
    171 
     174*/
    172175    }
    173176    void Q3DCameraWidget::setData(short* ddata)
    174177    {
    175         for (int i=0;i<1440;i++)
     178        cout << "Info : 3D plotter disabled. requires more work so that less than 300 slices per pixel can be loaded" << endl;
     179        cout << "Contact Etienne (etienne.lyard@unige.ch) for more information." << endl;
     180/*        for (int i=0;i<1440;i++)
    176181            for (int j=0;j<300;j++)
    177182                _data[i*300+j] = ddata[i* 300 + j];
     
    179184        if (isVisible())
    180185            updateGL();
    181 
     186*/
    182187    }
    183188    void Q3DCameraWidget::drawCameraBody()
  • trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.cc

    r14250 r14791  
    189189        else
    190190
    191         color = float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
     191//        if (_softwareOrdering)
     192//            color = float(eventData[nRoi*i + whichSlice] + (VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
     193//        else
     194            color = float(eventData[nRoi*hardwareMapping[i] + whichSlice]+(VALUES_SPAN/2))/(float)(VALUES_SPAN-1);
    192195        if (logScale)
    193196        {
     
    291294        }*/
    292295
    293     const int hw = hardwareMapping[selectedPixel];
     296//    int mapping = _softwareOrdering ? selectedPixel : hardwareMapping[selectedPixel];
     297    int mapping = hardwareMapping[selectedPixel];
     298    const int hw = mapping;
    294299    const PixelMapEntry& mapEntry = fPixelMap.index(selectedPixel);
    295300    const int pixelIdInPatch = mapEntry.pixel();
     
    385390            patchesColor[i][j] = color[j];
    386391    }
     392    fZeroArray = NULL;
     393
     394    _softwareOrdering = false;
    387395
    388396}
     
    402410        delete[] waveLetArray;
    403411    }
    404 }
    405 
     412    if (fZeroArray != NULL)
     413        delete[] fZeroArray;
     414}
     415void RawDataViewer::allocateZeroArray()
     416{
     417    if (fZeroArray == NULL)
     418    {
     419        fZeroArray = new char[8192];
     420    }
     421}
    406422/************************************************************
    407423 * PAINT GL. main drawing function.
     
    572588        }
    573589    }
     590
    574591    nRows =          inputFile->HasKey("NAXIS2") ? inputFile->GetInt("NAXIS2") : 0;
    575592    nRoi =           inputFile->HasKey("NROI") ?  inputFile->GetInt("NROI") : 0;
     
    584601    nBoards =        inputFile->HasKey("NBOARD") ? inputFile->GetInt("NBOARD") : 0;
    585602    nPixels =        inputFile->HasKey("NPIX") ?  inputFile->GetInt("NPIX") : 0;
    586     timeSystem =     inputFile->HasKey("TIMESYS") ? inputFile->GetStr("TIMESYS") : 0;
    587     creationDate =   inputFile->HasKey("DATE") ? inputFile->GetStr("DATE") : 0;
     603    timeSystem =     inputFile->HasKey("TIMESYS") ? inputFile->GetStr("TIMESYS") : "";
     604    creationDate =   inputFile->HasKey("DATE") ? inputFile->GetStr("DATE") : "";
    588605    nightInt =       inputFile->HasKey("NIGHT") ? inputFile->GetInt("NIGHT") : 0;
    589     camera =         inputFile->HasKey("CAMERA") ? inputFile->GetStr("CAMERA") : 0;
    590     daq =            inputFile->HasKey("DAQ") ? inputFile->GetStr("DAQ") : 0;
     606    camera =         inputFile->HasKey("CAMERA") ? inputFile->GetStr("CAMERA") : "";
     607    daq =            inputFile->HasKey("DAQ") ? inputFile->GetStr("DAQ") : "";
    591608    adcCount =       inputFile->HasKey("ADCRANGE") ? inputFile->GetFloat("ADCRANGE") : 2000;
     609    if (nPixels == 0)
     610    {
     611        cout << "could not read num pixels from fits header. Assuming 1440 (FACT)." << endl;
     612        nPixels = 1440;
     613    }
     614    if (nRoi == 0 && !inputFile->HasKey("NROI"))
     615    {//let's try to figure out the roi from the column's format
     616        const fits::Table::Columns& cols = inputFile->GetColumns();
     617        if (cols.find("Data") == cols.end())
     618        {
     619            cout << "ERROR: Column \"Data\" could not be found. abortin load." << endl;
     620            return;
     621        }
     622        const fits::Table::Columns::const_iterator col = cols.find("Data");
     623        if (col->second.type != 'I')
     624        {
     625            cout << "ERROR: Data Column has type " << col->second.type << " while viewer expects I" << endl;
     626            return;
     627        }
     628        if (col->second.num % nPixels != 0)
     629        {
     630            cout << "ERROR: Num pixels (" << nPixels << ") does not match Data length (" << col->second.num << "). Aborting" << endl;
     631            return;
     632        }
     633        nRoi = col->second.num/nPixels;
     634        cout << "Estimate num samples per pixels to be " << nRoi;
     635        _softwareOrdering = true;
     636    }
     637    else
     638        _softwareOrdering = false;
    592639
    593640    if (inputFile->HasKey("OFFSET"))
     
    598645    nbBad = 0;//inputFile->GetInt("NBEVTBAD");
    599646
    600     eventNum = 0;
     647    eventNum = 1;
    601648
    602649    if (eventData != NULL) {
     
    612659    {
    613660        inputFile->SetPtrAddress("Data", rawEventData);
    614         inputFile->SetPtrAddress("EventNum", &eventNum);
    615         inputFile->SetPtrAddress("TriggerType", &triggerType);
    616         inputFile->SetPtrAddress("SoftTrig", &softTrig);
    617         inputFile->SetPtrAddress("BoardTime", boardTime);
    618         inputFile->SetPtrAddress("StartCellData", startPix);
    619         inputFile->SetPtrAddress("StartCellTimeMarker", startTM);
    620         inputFile->SetPtrAddress("TimeMarker", &rawEventData[1440*nRoi]);
     661        if (inputFile->HasColumn("EventNum"))
     662            inputFile->SetPtrAddress("EventNum", &eventNum);
     663        else
     664            cout << "Warning: could not find column \"EventNum\"" << endl;
     665        if (inputFile->HasColumn("TriggerType"))
     666            inputFile->SetPtrAddress("TriggerType", &triggerType);
     667        else
     668            cout << "Warning: could not find column \"TriggerType\"" << endl;
     669        if (inputFile->HasColumn("SoftTrig"))
     670            inputFile->SetPtrAddress("SoftTrig", &softTrig);
     671        else
     672            cout << "Warning: could not find column \"SoftTrig\"" << endl;
     673        if (inputFile->HasColumn("BoardTime"))
     674            inputFile->SetPtrAddress("BoardTime", boardTime);
     675        else
     676            cout << "Warning: could not find column \"BoardTime\"" << endl;
     677        if (inputFile->HasColumn("StartCellData"))
     678            inputFile->SetPtrAddress("StartCellData", startPix);
     679        else
     680            cout << "Warning: could not find column \"StartCellData\"" << endl;
     681        if (inputFile->HasColumn("StartCellTimeMarker"))
     682            inputFile->SetPtrAddress("StartCellTimeMarker", startTM);
     683        else
     684            cout << "Warning: could not find column \"StartCellTimeMarker\"" << endl;
     685        if (inputFile->HasColumn("TimeMarker"))
     686            inputFile->SetPtrAddress("TimeMarker", &rawEventData[1440*nRoi]);
     687        else
     688            cout << "Warning: could not find column \"TimeMarker\"" << endl;
    621689    }
    622690    catch (const runtime_error &e)
     
    633701    {
    634702        pcTime[0] = pcTime[1] = 0;
    635         inputFile->SetPtrAddress("UnixTimeUTC", pcTime);
     703        if (inputFile->HasColumn("UnixTimeUTC"))
     704            inputFile->SetPtrAddress("UnixTimeUTC", pcTime);
    636705    }
    637706    catch (const runtime_error&)
     
    639708            try
    640709        {
    641             inputFile->SetPtrAddress("PCTime", pcTime);
     710            if (inputFile->HasColumn("PCTime"))
     711                inputFile->SetPtrAddress("PCTime", pcTime);
     712            else
     713                cout << "Warning: could not find column \"UnixTimeUTC\" nor \"PCTime\"" << endl;
     714
    642715        }
    643716        catch (const runtime_error&)
     
    824897        return;
    825898    inputFile->GetRow(rowNum);
     899    if (_softwareOrdering)
     900    {//remap pixels data according to hardware id
     901        if (nRoiTM != 0)
     902            cout << "Warning: did not expect Time Markers data from Monte-Carlo simulations. These will not be mapped properly." << endl;
     903        //first copy the data
     904        int16_t* tempData = new int16_t[1440*nRoi];
     905        for (int i=0;i<1440*nRoi;i++)
     906            tempData[i] = rawEventData[i];
     907        //copy back the data and re-map it on the fly
     908        for (int i=0;i<1440;i++)
     909            for (int j=0;j<nRoi;j++)
     910                rawEventData[i*nRoi + j] = tempData[softwareMapping[i]*nRoi + j];
     911
     912        delete[] tempData;
     913    }
    826914//    cout << "Getting row " << rowNum << endl;
    827915
     
    12731361        return;
    12741362    }
    1275     const int idx =
    1276         GLWindow->nRoi*GLWindow->hardwareMapping[GLWindow->selectedPixel]
    1277         + GLWindow->whichSlice;
     1363//    int mapping = GLWindow->_softwareOrdering ? GLWindow->selectedPixel : GLWindow->hardwareMapping[GLWindow->selectedPixel];
     1364    int mapping = GLWindow->hardwareMapping[GLWindow->selectedPixel];
     1365    const int idx = GLWindow->nRoi*mapping + GLWindow->whichSlice;
    12781366
    12791367    ostringstream str;
     
    18741962        return;
    18751963    int softwarePix = pixel;
    1876     pixel = GLWindow->hardwareMapping[pixel];
     1964//    if (!GLWindow->_softwareOrdering)
     1965        pixel = GLWindow->hardwareMapping[pixel];
    18771966
    18781967    HwIDBox->setValue(pixel);
     
    19972086        return;
    19982087
    1999     HwIDBox->setValue(GLWindow->hardwareMapping[swid]);
     2088//    if (GLWindow->_softwareOrdering)
     2089//        HwIDBox->setValue(swid);
     2090//    else
     2091        HwIDBox->setValue(GLWindow->hardwareMapping[swid]);
    20002092}
    20012093
  • trunk/FACT++/gui/RawEventsViewer/RawEventsViewer.h

    r14077 r14791  
    120120    valarray<double> Maxvalues;
    121121    valarray<double> PosOfMaxvalues;
     122
     123    ///Used to load zero data in case of missing fits columns
     124    void allocateZeroArray();
     125    char* fZeroArray;
     126    //bool telling whether the data is natively ordered in software or hardware id
     127    //used to correctly display monte-carlo data.
     128    bool _softwareOrdering;
    122129
    123130private:
     
    177184
    178185
     186
    179187//    int hardwareMapping[1440];
    180188//    int softwareMapping[1440];
Note: See TracChangeset for help on using the changeset viewer.