Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AHDC geom in mon12 #66

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

ftouchte
Copy link

Hello,

I have tried to produce plots with respect to the AHDC geometry on mon12.

The geometry information is retrieved from coatjava. In two temporary tabs (geomand geom_bis), I have presented some examples of use. The code is not perfect and has a lot unnecessary screen outputs. Thanks to this discussion, we can improve the result.

The following graph, in geom, shows a XY graph of the detector (2D view at the center of the detector).
Capture d’écran de 2024-12-13 18-03-06

The following graphs, in geom_bis, are 2D histograms showing the wire occupancy during respectively 100000 and 100 events.

100000 events
Capture d’écran de 2024-12-16 11-30-56

100 events
Capture d’écran de 2024-12-16 14-52-36

@raffaelladevita
Copy link
Collaborator

if I understood correctly, the graph would show hits for single events, right? mon12 is not really meant for that because it is usually run in accumulation mode, while CED will provide that functionality.

The 2D histogram is a better option in my opinion. A few suggestions on that:

  • currently, the histogram has a very large number of bins which based on previous experience, will make the histogram visualization very slow;
  • the number of bins could be largely reduced by changing the histogram to be for example wire layer versus wire phi. The number of bins in phi could be set to few hundreds and the bin to be filled could be chosen based on the phi range of the wire, throwing a random number to select the bin within the range. The advantage is also that the histogram would be filled continuously, which makes the occupancy patterns more easily visible.

@ftouchte
Copy link
Author

ftouchte commented Dec 18, 2024

Hello,

I have removed the XY graph as it was not convenient for mon12.

Concerning the 2D histogram, my intention to represent wires as filled circles led me to use a big number of bins : 1000x1000. Unfortunately, this big number of bins had a bad effect on the performance of the software.

Before continuing to your suggestion, I have renounced to the idea of representing wires as a filled circles. Now, representing a wire as a simple rectangle allowed me to reduced the number of bins up to 120x120 (a good compromise).

What do you think about this modification ?

120x120 bins
120bins

100x100 bins
100bins

80x80 bins
80bins

36x36 bins
36bins

Renounce to the idea of representing wires as filled circles
@raffaelladevita
Copy link
Collaborator

raffaelladevita commented Dec 19, 2024 via email

@ftouchte
Copy link
Author

ftouchte commented Jan 8, 2025

Hi,

Sorry for the delay. It's true, it's difficult to have access to a given wire in the "x vs y" representation. But, as we don't have the same number of wires in each layer, using "phi vs layer" will be also difficult.

Here is an alternative : wire vs layer

layer ID layer number
11 1
21 2
22 3
31 4
32 5
41 6
42 7
51 8

What do you think ?

Another question : I know there is a new branch with the new version of coatjava that implements the AHDC decoder. I wonder how to use this decoder in coatjava.

Capture d’écran de 2025-01-08 12-40-10

@raffaelladevita
Copy link
Collaborator

raffaelladevita commented Jan 8, 2025 via email

@baltzell
Copy link
Collaborator

here's the needed fix for coatjava: JeffersonLab/coatjava#432

@ftouchte
Copy link
Author

Hi everyone,

I have made some modification in coatjava JeffersonLab/coatjava#446 to recover more data from AHDC pulse analysis.

I have re-organised the AHDC tab in mon12 to show :

  • charge
    • occupancy
    • average of adcMax
    • average of integral
  • time
    • average of timeMax
    • average of leadingEdgeTime
    • average of timeOverThreshold
    • average of constantFractionTime

Here is the result when reading some evio files.

Screenshot from 2025-01-27 13-28-42

Screenshot from 2025-01-27 13-28-28

Here is the result when reading some hipo files containing the relevant data.

Screenshot from 2025-01-27 13-33-01

Comment

My remaining concern is the way I have computed the mean values of the decoded quantity. Is it the good way to do that?

Also, what plots should be displayed in ALERT part of the Summary tab ?

@raffaelladevita
Copy link
Collaborator

The new tabs look very good to me. Concerning your questions:

  • one alternative way to calculate averages is to fill in processEvent a histogram with the quantity to average as a weight, e.g. this.getDataGroup().getItem(0,0,0).getH2F("integral").fill(comp, layer_number, integral), and a histogram with just the number of entries, e.g. this.getDataGroup().getItem(0,0,0).getH2F("raw").fill(comp, layer_number), and then divide the first by the second in the analysisUpdate method.
  • I would display the occupancy in the summary tab.

@ftouchte
Copy link
Author

ftouchte commented Feb 4, 2025

Thank you very much, I will update the code.

@ftouchte
Copy link
Author

ftouchte commented Feb 6, 2025

Hi,

I have displayed the occupancy in the summary tab.

Concerning the analysisUpdate() method, I wonder when and how many time it is called because if

$$\overline{x}_{N} = \frac{1}{N} \sum_{k=1}^N {x_k}$$

and

$$\overline{x}_{N+1} = \frac{1}{N+1} \sum_{k=1}^{N+1}{x_k} = \frac{1}{N+1} \left( N \overline{x}_{N} + x_{N+1} \right)$$

and this method is used more that one time, I think we could accumulate error :

$$\overline{x}_{N+1} \neq \frac{\overline{x}_{N} + x_{N+1}}{N+1}$$

Am I right ?

Screenshot from 2025-02-06 23-06-24

@raffaelladevita
Copy link
Collaborator

You are right: doing it like that would introduce a bias.

In suggesting this approach, I forgot to mention something important...
You will need two histograms for each quantity you want to compute the average of: one that you should keep filling with the weight equal to the quantity to average, and a second one that will be filled in analysisUpdate with. the ratio of the first histogram and the raw occupancy.
Referring to the example above, in processEvent, you would have:

          this.getDataGroup().getItem(0,0,0).getH2F("raw_integral").fill(comp, layer_number, integral);
          this.getDataGroup().getItem(0,0,0).getH2F("raw").fill(comp, layer_number);

and in analysisUpdate

         H2F h1 = this.getDataGroup().getItem(0,0,0).getH2F("integral");
         H2F h2 = this.getDataGroup().getItem(0,0,0).getH2F("raw_integral");
         H2F h3 = this.getDataGroup().getItem(0,0,0).getH2F("raw");
        for(int ibin=0; ibin<h1.getDataBufferSize(); ibin++) {
            float b2 = h.2getDataBufferBin(ibin);
            float b3 = h3.getDataBufferBin(ibin);
            if(b3>0)
                h1.setDataBufferBin(ibin, b2/b2);
        }

@ftouchte
Copy link
Author

ftouchte commented Feb 7, 2025

I have finally used the analysisUpdate() method to compute the averages of each decoding outputs.

Everything works fine with hipo files. For evio files, as we need to use the decoder, I had to store more data in the AHDC::adc bank. So I have done some modifications in coatjava.

JeffersonLab/coatjava/pull/446

@whit2333
Copy link

whit2333 commented Feb 9, 2025

@raffaelladevita could you please review/merge?

@raffaelladevita
Copy link
Collaborator

raffaelladevita commented Feb 9, 2025 via email

@whit2333
Copy link

whit2333 commented Feb 9, 2025

@ftouchte What is the status of the decoder (evio)? I assume this (JeffersonLab/coatjava#446) is the PR that has those changes?

@ftouchte ftouchte linked an issue Feb 10, 2025 that may be closed by this pull request
Merge branch 'main' of https://github.com/JeffersonLab/mon12 into issue/sync-fork
@whit2333
Copy link

@ftouchte could you please rebase the PR?

@ftouchte
Copy link
Author

ftouchte commented Feb 17, 2025

@whit2333 I think my PR is already up to date with the recent changes in mon12.

@whit2333
Copy link

whit2333 commented Feb 20, 2025

I just checked on clondaq7 with a recent run and I get this repeated error

[bank] Error (PUT) :: ( AHDC::adc) the entry id has type Short while requested UNDEFINED

@baltzell or @raffaelladevita do you know what line is causing this error to print?

@ftouchte
Copy link
Author

ftouchte commented Feb 20, 2025

I just checked on clondaq7 with a recent run and I get this repeated error

[bank] Error (PUT) :: ( AHDC::adc) the entry id has type Short while requested UNDEFINED

@whit2333
This can occur when

  • the CLAS12DIR environment variable does not indicate the good caotjava repository
  • when using mvn install, the coatjava package is usually re-downloaded from the maven repository. So that can overwrite the local coatjava
  • there is also the version comptability. When building the development coatjava, it will create a package with the version 11.1.2-SNAPSHOT, while mon12 currently requires the version 11.1.0-SNAPSHOT.

To deal with that, I have just rename the package name and overwrite the coatjava downloaded by maven (/home/username/.m2/repository/org/jlab/coat/coat-libs).

@whit2333
Copy link

whit2333 commented Feb 20, 2025

@ftouchte , you are right I needed to update my coatjava version. The errors remain and the histograms are still not being populated.
Can you check with a recent run (https://userweb.jlab.org/~whit/data_files/CI_tests/alert_020771.evio.00000)?

@ftouchte
Copy link
Author

@whit2333
Yes, here is the result.

Terminal output (mon12_output.txt )

Plot
Screenshot from 2025-02-21 11-27-35

Here are the steps I have followed :

#mvn clean

ifarm2401.jlab.org> mvn install
Failed to load native library:jansi-2.4.1-c408528079fcc0ac-libjansi.so. The native library file at /tmp/jansi-2.4.1-c408528079fcc0ac-libjansi.so is not executable, make sure that the directory is mounted on a partition without the noexec flag, or set the jansi.tmpdir system property to point to a proper location.  osinfo: Linux/x86_64
java.lang.UnsatisfiedLinkError: /tmp/jansi-2.4.1-c408528079fcc0ac-libjansi.so: /tmp/jansi-2.4.1-c408528079fcc0ac-libjansi.so: failed to map segment from shared object
[INFO] Scanning for projects...
[INFO] 
[INFO] --------------------< org.clas.detector:clas12mon >---------------------
[INFO] Building clas12mon 7.10
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from clas12maven: https://clasweb.jlab.org/clas12maven/org/jlab/coat/coat-libs/11.1.0-SNAPSHOT/maven-metadata.xml
[INFO] 
[INFO] --- resources:3.3.1:resources (default-resources) @ clas12mon ---
...
ifarm2401.jlab.org> echo $CLAS12DIR
/u/scigroup/cvmfs/hallb/clas12/sw/noarch/coatjava/11.1.1
ifarm2401.jlab.org> setenv CLAS12DIR /w/hallb-scshelf2102/clas12/users/touchte/coatjava/coatjava
ifarm2401.jlab.org> echo $CLAS12DIR
/w/hallb-scshelf2102/clas12/users/touchte/coatjava/coatjava
ifarm2401.jlab.org> ls -ll /home/touchte/.m2/repository/org/jlab/coat/coat-libs/11.1.0-SNAPSHOT/
total 259230
-rw-r--r--. 1 touchte clas12-grp 198289518 Feb 12 10:50 coat-libs-11.1.0-SNAPSHOT.jar
-rw-r--r--. 1 touchte enp              477 Jan  2 17:37 coat-libs-11.1.0-SNAPSHOT.pom
-rw-r--r--. 1 touchte enp              226 Feb  6 16:27 _remote.repositories
-rw-r--r--. 1 touchte enp              235 Feb 21 05:12 resolver-status.properties
ifarm2401.jlab.org> 
ifarm2401.jlab.org> cp /w/hallb-scshelf2102/clas12/users/touchte/coatjava/coatjava/lib/clas/coat-libs-11.1.2-SNAPSHOT.jar /home/touchte/.m2/repository/org/jlab/coat/coat-libs/11.1.0-SNAPSHOT/coat-libs-11.1.0-SNAPSHOT.jar 
ifarm2401.jlab.org> ls -ll /home/touchte/.m2/repository/org/jlab/coat/coat-libs/11.1.0-SNAPSHOT/
total 259278
-rw-r--r--. 1 touchte clas12-grp 198298382 Feb 21 05:21 coat-libs-11.1.0-SNAPSHOT.jar
-rw-r--r--. 1 touchte enp              477 Jan  2 17:37 coat-libs-11.1.0-SNAPSHOT.pom
-rw-r--r--. 1 touchte enp              226 Feb  6 16:27 _remote.repositories
-rw-r--r--. 1 touchte enp              235 Feb 21 05:12 resolver-status.properties
ifarm2401.jlab.org> 
ifarm2401.jlab.org> 
ifarm2401.jlab.org> 
ifarm2401.jlab.org> ./bin/mo
mon12*       mon12_hydra* mon12_rgc*   mon12_rgd*   mon12_rge*   mon12_rgk*   mon12-rgl*   mon12_rgm*   
ifarm2401.jlab.org> ./bin/mon12
[HipoDataSync] ---> dictionary size = 241
[ConstantsManager] --->  loading table for run = 2284
[DB] --->  open connection with : mysql://[email protected]/clas12
[DB] --->  database variation   : default
[DB] --->  database run number  : 2,284
[DB] --->  database time stamp  : 2/21/25, 5:25 AM
[DB] --->  database connection  : success
***** >>> adding :      BMTconfig / table = /daq/config/bmt
[DB] --->  database disconnect  : success
[RCDB] --->  open connection with : mysql://[email protected]/rcdb
[RCDB] --->  database connection  : success
[RCDB] --->  database disconnect  : success
...
#see file mon12_output.txt

Remark, this figure shows another issue related to the slco indexing in the AHDC::adc bank. Indeed, if you look at a decoded file, for example /w/hallb-scshelf2102/clas12/users/touchte/alert_020771.evio.00000.hipo , you will notice that all the hits of the AHDC::adc bank have the same sector, layer, component, order identifiers while the AHDC::wf bank has more realistic slco identifiers. I suspect there is a issue when copying the sloc index of the AHDC::wf bank to the AHDC::adc bank

https://github.com/JeffersonLab/coatjava/blob/e4ba622ad161e9f1fc55478f5c1b0e09a3656c65/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java#L274
or
https://github.com/JeffersonLab/coatjava/blob/e4ba622ad161e9f1fc55478f5c1b0e09a3656c65/common-tools/clas-detector/src/main/java/org/jlab/detector/pulse/ModeAHDC.java#L296

copyIndices() is a method defined in HipoExtractor.

@raffaelladevita
Copy link
Collaborator

see JeffersonLab/coatjava#483
When this will be resolved, a new coatjava release can be tagged and used for building mon12

@ftouchte
Copy link
Author

ftouchte commented Feb 21, 2025

I think, I just understand what is going wrong. It is in ModeAHDC, I never fill the id attribute of a pulse in the extract method. I will fix this issue, do some test on evio files and create a new pull request in coatjava. Thanks for noticing @raffaelladevita !

@ftouchte
Copy link
Author

I have fixed the issue. JeffersonLab/coatjava#480

Screenshot from 2025-02-23 12-28-11

@baltzell
Copy link
Collaborator

can this be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Submit mon12 modification for AHDC
4 participants