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

Alpha ana #124

Merged
merged 37 commits into from
Apr 26, 2022
Merged

Alpha ana #124

merged 37 commits into from
Apr 26, 2022

Conversation

jgalan
Copy link
Member

@jgalan jgalan commented Jan 31, 2022

@jgalan
Copy link
Member Author

jgalan commented Jan 31, 2022

PandaX-III pipeline is failing. Perhaps due to the new TRestRawZeroSuppresionProcess? @nkx @juanangp

https://gitlab.cern.ch/rest-for-physics/framework/-/jobs/19174479

@juanangp
Copy link
Member

juanangp commented Feb 1, 2022

PandaX-III pipeline is failing. Perhaps due to the new TRestRawZeroSuppresionProcess? @nkx @juanangp

https://gitlab.cern.ch/rest-for-physics/framework/-/jobs/19174479

Indeed, looks like the issue is that we have to add a TRestRawToDetectorSignalProcess after TRestRawZeroSuppresionProcess.

@jgalan are you going to fix it in panda pipeline?

@juanangp
Copy link
Member

juanangp commented Feb 1, 2022

Another issue is that we are loosing precision because former TRestRawZeroSuppresionProcess was saving data as Double_t, while now the data is stored as a Short_t in TRestRawSignal.

@juanangp
Copy link
Member

juanangp commented Feb 1, 2022

Another issue is that we are loosing precision because former TRestRawZeroSuppresionProcess was saving data as Double_t, while now the data is stored as a Short_t in TRestRawSignal.

Any idea in how to fix this issue, shall we go back to the previous implementation?

@jgalan
Copy link
Member Author

jgalan commented Feb 2, 2022

Another issue is that we are loosing precision because former TRestRawZeroSuppresionProcess was saving data as Double_t, while now the data is stored as a Short_t in TRestRawSignal.

Aham, well the data in origin is in short format. So why the result is different? Perhaps at ZeroSuppression there is an additional manipulation before being transformed to Double_t by TRestRawToDetectorSignalProcess?

@jgalan
Copy link
Member Author

jgalan commented Feb 2, 2022

At TRestRawZeroSuppression the baseline is being subtracted when invoking GetData.

        std::vector<Int_t> pOver = s->GetPointsOverThreshold();
        for (int n = 0; n < pOver.size(); n++) {
            int j = pOver[n];
            sgn.IncreaseBinBy(j, s->GetData(j));
        }      

We should avoid to remove the baseline as soon as we stay at TRestRaw domain. And we should remove it once we transform to TRestDetectorSignal.

So, using TRestRawSignal::GetRawData instead of TRestRawSignal::GetData. The problem is that when zero-ing we loss the baseline information.

The idea behind is that we always calculate the baseline so that we do not store the values inside TRestRawSignal.

An option would be to include those data members Double_t fBaseLine = 0 and Double_t fBaseLineSigma = 0 inside TRestRawSignal, so that it can be recovered even after TRestRawZeroSuppressionProcess.

Option 1: We introduce those data members at TRestRawSignal and we move REST version to 2.4.0.

Option 2: We implement zeroSuppression as a method/option at TRestRawToDetectorSignalProcess.

@nkx what do you think?

@juanangp
Copy link
Member

juanangp commented Feb 2, 2022

Option 1: We introduce those data members at TRestRawSignal and we move REST version to 2.4.0.

Option 2: We implement zeroSuppression as a method/option at TRestRawToDetectorSignalProcess.

@nkx what do you think?

I would suggest to move to option 2

@juanangp
Copy link
Member

juanangp commented Feb 2, 2022

I really don't understand the following observabales in TRestRawZeroSuppresionProcess:

    SetObservableValue("flattail_map", flattailmap);
    SetObservableValue("FlatTails", totoalflatN);
    SetObservableValue("NFlatTailSignals", (int)flattailmap.size());

Particularly the definition:

int Nbefore;
        if (fNPointsFlatThreshold != 512) {
            s->InitializePointsOverThreshold(TVector2(fPointThreshold, fSignalThreshold),
                                             fNPointsOverThreshold, 512);
            Nbefore = s->GetPointsOverThreshold().size();
        }
        s->InitializePointsOverThreshold(TVector2(fPointThreshold, fSignalThreshold), fNPointsOverThreshold,
                                         fNPointsFlatThreshold);

        int Nafter = s->GetPointsOverThreshold().size();
        // cout << fRawSignalEvent->GetID() << " " << s->GetID() << " " << Nbefore << " " << Nafter << endl;
        if (Nafter != Nbefore) {
            flattailmap[s->GetID()] = Nbefore - Nafter;
            totoalflatN += Nbefore - Nafter;
        }

Note that Nbefore is not initialiazed while fNPointsFlatThreshold==512, which I think should be most of the cases, it doesn't make sense to me...

Shall we keep these observables or it is a good time to get rid of them?

@juanangp
Copy link
Member

juanangp commented Feb 2, 2022

Pipeline is failing because of c++ structure bindings. So looks like pipeline is still using C++14, indeed root version is still 6.10/08 in which only C++14 was supported.

@jgalan Can we upgrade it to ROOT 6.24 and compile in C++17?

@jgalan
Copy link
Member Author

jgalan commented Feb 2, 2022

In principle I have no problem. I believe the reason behind is to keep compatibility with older systems, so installation is possible on those systems @nkx? I guess we just need someone preparing a docker image.

Perhaps, we could say, v2.3.10 is compatible with C++14, v2.3.11 will not be compatible anymore?

We have also the LFNA GitLab instance at Unizar, where we were previously executing jobs without docker and we had much more control.

If it is not possible to keep the code compatible with both?

@juanangp
Copy link
Member

juanangp commented Feb 2, 2022

If it is not possible to keep the code compatible with both?

Yes, it is possible but I think we should implement C++17 features in the code, particularly structure bindings makes the coding easier.

I tested locally with C++17 and ROOT 6.24 and it is running fine to me.

@jgalan
Copy link
Member Author

jgalan commented Feb 2, 2022

I am not a big fan of structures. If it is as relevant as to create a structure, perhaps a full class is a better option.

@jgalan
Copy link
Member Author

jgalan commented Feb 2, 2022

I am looking at the advantages at this example https://www.geeksforgeeks.org/structured-binding-c/

And I dont really understand the benefit of linking to x_coord, would not be easier just to use p.x?

C++98 looked simple enough, why it became complex later, and then they had to redo it later again?

@juanangp
Copy link
Member

juanangp commented Feb 2, 2022

Perhaps you are looking to the wrong example, structure bindings are particularly useful for e.g. std::map, for instance the part of the code that I wrote:
C++14

std::map<int,std::pair<int,double> > windowMap = makeMap();
  for(auto it = windowMap.begin(); it!=windowMap.end();it++){
              Double_t time = it->first * fIntWindow + fIntWindow/2.;
              Double_t energy = it->second.second/it->second.first;
            }

C++17

 std::map<int,std::pair<int,double> > windowMap = makeMap();
  for(const auto &[index, pair] : windowMap){
              Double_t time = index * fIntWindow + fIntWindow/2.;
              Double_t energy = pair.second/pair.first;
            }

As you can see the implementation in C++14 is not readable and error prone while in C++17 it is easy to understand.

On the other hand C++17 has many other advantages apart of structure bindings:
https://www.codingame.com/playgrounds/2205/7-features-of-c17-that-will-simplify-your-code/introduction

Still don't understand why you are against moving forward to C++17, latest version is C++20 and C++23 is on-going...

@jgalan
Copy link
Member Author

jgalan commented Feb 3, 2022

In principle I have no problem.

Again, as I said before, I am not against.

@lobis
Copy link
Member

lobis commented Feb 3, 2022

In principle I have no problem. I believe the reason behind is to keep compatibility with older systems, so installation is possible on those systems @nkx? I guess we just need someone preparing a docker image.

Perhaps, we could say, v2.3.10 is compatible with C++14, v2.3.11 will not be compatible anymore?

We have also the LFNA GitLab instance at Unizar, where we were previously executing jobs without docker and we had much more control.

If it is not possible to keep the code compatible with both?

Hello,

I use this DockerHub image to do all my tests: https://hub.docker.com/r/lobis/root-geant4-garfieldpp/tags we can use this in the pipeline if you want. There are a good combination of ROOT / Geant4 / C++ versions available, I can make more if you want.

@nkx111
Copy link
Member

nkx111 commented Feb 4, 2022

At TRestRawZeroSuppression the baseline is being subtracted when invoking GetData.

        std::vector<Int_t> pOver = s->GetPointsOverThreshold();
        for (int n = 0; n < pOver.size(); n++) {
            int j = pOver[n];
            sgn.IncreaseBinBy(j, s->GetData(j));
        }      

We should avoid to remove the baseline as soon as we stay at TRestRaw domain. And we should remove it once we transform to TRestDetectorSignal.

So, using TRestRawSignal::GetRawData instead of TRestRawSignal::GetData. The problem is that when zero-ing we loss the baseline information.

The idea behind is that we always calculate the baseline so that we do not store the values inside TRestRawSignal.

An option would be to include those data members Double_t fBaseLine = 0 and Double_t fBaseLineSigma = 0 inside TRestRawSignal, so that it can be recovered even after TRestRawZeroSuppressionProcess.

Option 1: We introduce those data members at TRestRawSignal and we move REST version to 2.4.0.

Option 2: We implement zeroSuppression as a method/option at TRestRawToDetectorSignalProcess.

@nkx what do you think?

I also stands for the option 2. It is too quick to move to 2.4.0 now.

@nkx111
Copy link
Member

nkx111 commented Feb 4, 2022

I really don't understand the following observabales in TRestRawZeroSuppresionProcess:

    SetObservableValue("flattail_map", flattailmap);
    SetObservableValue("FlatTails", totoalflatN);
    SetObservableValue("NFlatTailSignals", (int)flattailmap.size());

Particularly the definition:

int Nbefore;
        if (fNPointsFlatThreshold != 512) {
            s->InitializePointsOverThreshold(TVector2(fPointThreshold, fSignalThreshold),
                                             fNPointsOverThreshold, 512);
            Nbefore = s->GetPointsOverThreshold().size();
        }
        s->InitializePointsOverThreshold(TVector2(fPointThreshold, fSignalThreshold), fNPointsOverThreshold,
                                         fNPointsFlatThreshold);

        int Nafter = s->GetPointsOverThreshold().size();
        // cout << fRawSignalEvent->GetID() << " " << s->GetID() << " " << Nbefore << " " << Nafter << endl;
        if (Nafter != Nbefore) {
            flattailmap[s->GetID()] = Nbefore - Nafter;
            totoalflatN += Nbefore - Nafter;
        }

Note that Nbefore is not initialiazed while fNPointsFlatThreshold==512, which I think should be most of the cases, it doesn't make sense to me...

Shall we keep these observables or it is a good time to get rid of them?

These lines are some rough handling to AGET abnormal tailing signals, developed very long time ago. I think they are already out-dated for 2.3.x. We can just remove them. In future we may develop specific processes to handle those signals.

fNPointsFlatThreshold=512 means to turn off that functionality in TRestRawZeroSuppresionProcess. Here 512 is also a specialized number only for AGET electronics, which is not good.

@juanangp
Copy link
Member

juanangp commented Feb 4, 2022

I also stands for the option 2. It is too quick to move to 2.4.0 now.

I have already implemented option 2

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

Yes, but I cannot approve it myself since I created. It seems fine to me to merge it.

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

rest-for-physics/rawlib#46 pipeline is failing

@juanangp
Copy link
Member

juanangp commented Apr 5, 2022

rest-for-physics/rawlib#46 pipeline is failing

This is because the docker image is not the right one, I think should be fine after merging. Similar issues have been spotted in other PR.

@juanangp
Copy link
Member

juanangp commented Apr 5, 2022

rest-for-physics/rawlib#46 pipeline is failing

This is because the docker image is not the right one, I think should be fine after merging. Similar issues have been spotted in other PR.

In fact this is fixed in rest-for-physics/rawlib#51 which is not yet merged in master.

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

rest-for-physics/rawlib#46 pipeline is failing

This is because the docker image is not the right one, I think should be fine after merging. Similar issues have been spotted in other PR.

In fact this is fixed in rest-for-physics/rawlib#51 which is not yet merged in master.

But rest-for-physics/rawlib#51 is also failing

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

Actually rawlib at master is also failing after merging rest-for-physics/rawlib#50. Perhaps we just need to update the docker image? @lobis

@juanangp
Copy link
Member

juanangp commented Apr 5, 2022

rest-for-physics/rawlib#46 pipeline is failing

This is because the docker image is not the right one, I think should be fine after merging. Similar issues have been spotted in other PR.

In fact this is fixed in rest-for-physics/rawlib#51 which is not yet merged in master.

But rest-for-physics/rawlib#51 is also failing

Indeed, this is another un-related issue to this PR after the migration to C++17. This issue arises from performing on-the-fly compilation of STL containers and hardcoding compilation flags in the code:

system(Form("gcc %s -std=c++11 -I`root-config --incdir` "

A patch could be

system(Form("gcc %s `root-config --cflags` "

@lobis we had a chat about this, we don't have any related issue?

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

However, the rawlib pipeline seems to fail at the cmake level.

-- Testing disabled (Disabled by default, enabled via -DTEST=ON flag)
-- Check for ROOT_DICT_OUTPUT_DIR: /builds/rest-for-physics/rawlib/framework/build/rootdict
-- Check for ROOT_DICT_CINT_DEFINITIONS: 
-- External dependencies:
CMake Error at source/framework/external/CMakeLists.txt:4 (include):
  include could not find load file:

    FetchContent


-- making build files for /builds/rest-for-physics/rawlib/framework/source/framework, schema evolution: 
specified sub-dirs: external/tinyxml;tools;core;analysis
Empty submodule dir: libraries/track. Option: RESTLIB_TRACK=OFF
Empty submodule dir: libraries/geant4. Option: RESTLIB_GEANT4=OFF

https://gitlab.cern.ch/rest-for-physics/rawlib/-/jobs/20856420

@juanangp
Copy link
Member

juanangp commented Apr 5, 2022

However, the rawlib pipeline seems to fail at the cmake level.

master is failing because we don't have the proper docker image.

Docker image is updated on rest-for-physics/rawlib#51, however is failing becasue of

system(Form("gcc %s -std=c++11 -I`root-config --incdir` "

@jgalan
Copy link
Member Author

jgalan commented Apr 5, 2022

So, then why dont try to update it at that PR using system(Form("gcc %s root-config --cflags " and see if it goes through? I guess it makes sense, so that we do not force c++11.

@juanangp juanangp requested a review from lobis April 18, 2022 10:57
lobis
lobis previously approved these changes Apr 20, 2022

#message(STATUS Garfield_INCLUDE_DIRS ${Garfield_INCLUDE_DIRS})

find_library(Garfield_LIBRARIES NAMES libGarfield.so Garfield
HINTS ${Garfield_DIR}/lib ${Garfield_LIB_DIR}
$ENV{GARFIELD_HOME}/lib)
$ENV{GARFIELD_DIR}/lib)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://cmake.org/cmake/help/latest/command/find_library.html
If I understand this correctly, this change should be equivalent to removing $ENV{GARFIELD_HOME}/lib) from the macro. Why is this needed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this line is not needed and it was actually removed, I don't understand how it end up in this PR.

As fas as I remember some commits were cherry-pick from this PR to master. Perhaps something when wrong in between.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This branch is behind master, perhaps it will be fixed once master is merged in this branch. Highly recommended.

Screenshot 2022-04-20 at 21 35 51

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess thats why "outdated" appears next to the file name

@jgalan jgalan dismissed stale reviews from lobis and juanangp via ff37137 April 22, 2022 09:03
juanangp
juanangp previously approved these changes Apr 25, 2022
@juanangp juanangp requested a review from lobis April 25, 2022 11:21
@juanangp juanangp merged commit 0153c04 into master Apr 26, 2022
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.

4 participants