Skip to content

2. How to add a detector tab

raffaelladevita edited this page Nov 7, 2021 · 2 revisions

Each detector tab extends the DetectorMonitor class, with detector specific code, i.e. histogram definition, filling, analyzing and plotting. The DetectorMonitor class provides all other basic functionalities like saving histograms to hipo files or pictures, uploading histograms to the logbook, resetting histograms, selecting events based on trigger bits, etc.

To facilitate the development of a new detects tab, the EXAMPLEmonitor class is provided showing the methods that will have to be updated. The developer will have to:

  • clone the EXAMPLEmonitor class into a new class with appropriate name;
  • set the list of sub-tab titles at
    public EXAMPLEmonitor(String name) {
        super(name);
        
        this.setDetectorTabNames("Example");
        this.init(false);
    }
  • update the definition of the histograms in the method createHistos. In addition to the histograms that will be displayed in the detector tab, define one summary histograms for the summary tabs;
    @Override
    public void createHistos() {
        // initialize canvas and create histograms
        this.setNumberOfEvents(0);
        this.getDetectorCanvas().getCanvas("Example").divide(1, 2);
        this.getDetectorCanvas().getCanvas("Example").setGridX(false);
        this.getDetectorCanvas().getCanvas("Example").setGridY(false);
        H1F summary = new H1F("summary","summary",6,1,7);
        summary.setTitleX("sector");
        summary.setTitleY("Example hits");
        summary.setTitle("Example");
        summary.setFillColor(36);
        DataGroup sum = new DataGroup(1,1);
        sum.addDataSet(summary, 0);
        this.setDetectorSummary(sum);
        H2F occADC = new H2F("occADC", "occADC", 6, 0.5, 6.5, 8, 0.5, 8.5);
        occADC.setTitleY("ring-PMT");
        occADC.setTitleX("sector");
        occADC.setTitle("ADC Occupancy");
        H2F occTDC = new H2F("occTDC", "occTDC", 6, 0.5, 6.5, 8, 0.5, 8.5);
        occTDC.setTitleY("ring-PMT");
        occTDC.setTitleX("sector");
        occTDC.setTitle("TDC Occupancy");
        DataGroup dg = new DataGroup(1,2);
        dg.addDataSet(occADC, 0);
        dg.addDataSet(occTDC, 1);
        this.getDataGroup().add(dg,0,0,0);
    }
  • update the method plotHistos, defining how histograms are plotted in the different sub tabs.
    @Override
    public void plotHistos() {
        // plotting histos
        this.getDetectorCanvas().getCanvas("Occupancies").cd(0);
        this.getDetectorCanvas().getCanvas("Occupancies").draw(this.getDataGroup().getItem(0,0,0).getH2F("occADC"));
        this.getDetectorCanvas().getCanvas("Occupancies").cd(1);
        this.getDetectorCanvas().getCanvas("Occupancies").draw(this.getDataGroup().getItem(0,0,0).getH1F("occTDC"));
        this.getDetectorCanvas().getCanvas("Occupancies").update();
    }
  • update the method processEvent, defining how histograms are filled:
    @Override
    public void processEvent(DataEvent event) {
        // process event info and fill the histograms
        if(event.hasBank("HTCC::adc")==true){
	    DataBank bank = event.getBank("HTCC::adc");
	    int rows = bank.rows();
	    for(int loop = 0; loop < rows; loop++){
                int sector  = bank.getByte("sector", loop);
                int layer   = bank.getByte("layer", loop);
                int comp    = bank.getShort("component", loop);
                int order   = bank.getByte("order", loop);
                int adc     = bank.getInt("ADC", loop);
                float time  = bank.getFloat("time", loop);

                if(adc>0 && time>0) {
                    this.getDataGroup().getItem(0,0,0).getH2F("occADC").fill(sector*1.0,((comp-1)*2+layer)*1.0);
                    this.getDetectorSummary().getH1F("summary").fill(sector*1.0);
                }
	    }
    	}
    }
  • add necessary histogram analysis steps (fit, normalization, ...) in the analysisUpdate method:
    @Override
    public void analysisUpdate() {
        // use to manipulate the histograms (fit, normalize, ...)
    }
  • add the monitor class to the list of monitors in the main EventViewer class:
    public final void initMonitors() {
        monitors.put("BAND",        new BANDmonitor("BAND"));
        monitors.put("BMT",         new BMTmonitor("BMT"));
        monitors.put("BST",         new BSTmonitor("BST"));
        monitors.put("CND",         new CNDmonitor("CND")); 
        monitors.put("CTOF",        new CTOFmonitor("CTOF")); 
        monitors.put("DC",          new DCmonitor("DC"));     
        monitors.put("ECAL",        new ECmonitor("ECAL"));       
        monitors.put("FMT",         new FMTmonitor("FMT"));      
        monitors.put("FTCAL",       new FTCALmonitor("FTCAL"));   
        monitors.put("FTHODO",      new FTHODOmonitor("FTHODO")); 
        monitors.put("FTOF",        new FTOFmonitor("FTOF"));             
        monitors.put("FTTRK",       new FTTRKmonitor("FTTRK"));   
        monitors.put("HTCC",        new HTCCmonitor("HTCC"));     
        monitors.put("LTCC",        new LTCCmonitor("LTCC")); 
        monitors.put("RICH",        new RICHmonitor("RICH"));    
        monitors.put("RTPC",        new RTPCmonitor("RTPC"));    
        monitors.put("RF",          new RFmonitor("RF"));       
        monitors.put("HEL",         new HELmonitor("HEL"));      
        monitors.put("FCUP",        new FCUPmonitor("FCUP")); 
        monitors.put("Trigger",     new TRIGGERmonitor("Trigger"));
        monitors.put("TimeJitter",  new TJITTERmonitor("TimeJitter"));
    }
Clone this wiki locally