Ignore:
Timestamp:
01/28/13 10:21:39 (12 years ago)
Author:
lyard
Message:
Added Monte-Carlo data support. Disable 3D viewer.
Location:
trunk/FACT++/gui/RawEventsViewer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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.