Skip to content

SNDSW - FEDRA conversion functions#132

Open
antonioiuliano2 wants to merge 21 commits intoSND-LHC:masterfrom
antonioiuliano2:ConvertEmuBaseTracks
Open

SNDSW - FEDRA conversion functions#132
antonioiuliano2 wants to merge 21 commits intoSND-LHC:masterfrom
antonioiuliano2:ConvertEmuBaseTracks

Conversation

@antonioiuliano2
Copy link

@antonioiuliano2 antonioiuliano2 commented Nov 22, 2022

Dear All,

With this pull request I am organizing the functions I use to move between the detector reference system using for the scanning (units in micron, y vertical, each brick coordinates from 0 to 192000), and the physics reference system used in SNDLHC global data analysis (units in cm, slight rotation, unique origin for all the system). The transformation is done in the class EmulsionDet, by using LocalToMaster for positions and LocalToMasterVect for angle.

Currently, the passage from and to FEDRA objects is done in a separate python module, but it may also be added to the EmulsionDet class if we would prefer to have all in C++.

I have also added the drawing function to the 2D event display.
I attach here an example of a simulated muon neutrino vertex display, both in our FEDRA system and in the SNDSW system.

vertex_2694_MCEvent_3786_BrickID11_pullrequest
front_view_vertex_2694_FEDRA

Please let me know if you have any comment or question,
Antonio

@antonioiuliano2
Copy link
Author

Dear all,

with the help of @dcentanni , I have updated the pull request with the automated script to perform all digitization and reconstruction.
Since it is quite different from the sndsw usual command, I have prepared a small notebook of example here:
https://github.com/antonioiuliano2/tutorial_fedra/blob/master/EmulsionDetPoint_digitization_reconstruction.ipynb

I have tested it with one of the test simulations produced by Martina (the 10 GeV one).
Please let me know if you have any comment before merging this pull request

@antonioiuliano2
Copy link
Author

Good morning,

Is there any comment or suggestion for this pull request? If not, can we merge it so everyone can use these functions?

Best Regards,
Antonio

Copy link

@olantwin olantwin left a comment

Choose a reason for hiding this comment

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

I can't judge the FEDRA side of things, but it looks like this should not interfere with any existing sndsw code.

TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
//going there
nav->cd(pathtoplate.Data());
//returning position to master

Choose a reason for hiding this comment

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

What position?

Copy link
Author

Choose a reason for hiding this comment

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

My bad sorry, it should be angles, or even better vector.

//from sndsw cm to emulsion micron and from center to corner (our scanning takes 0,0 in a corner)
}

void EmulsionDet::GetLocalAngles(Int_t id, const Double_t* globalang, Double_t* localang){

Choose a reason for hiding this comment

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

I think these thin wrappers around the transformation methods of the TGeoNavigator adds very little.
It might be worth just getting this navigator once and then just using its methods directly.

Copy link
Author

Choose a reason for hiding this comment

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

I was following what is done in the GetPosition functions for the electronic detectors, using the navigator to access the position of the hit. What would you propose to do instead?

Copy link

Choose a reason for hiding this comment

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

Where are these actually used?

If this mirrors the naming conventions and interface for the other detectors, you should follow them, but in my opinion the naming is very confusing and the abstraction offers little benefit for a lot of boilerplate...

@@ -0,0 +1,40 @@
#!/bin/bash

# Bash script wrapping all of "FairShip2Fedra" conversion tools

Choose a reason for hiding this comment

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

Why not give this scripts some arguments so that one doesn't have to move files around?
This would allow using it e.g. in HTCondor without too many acrobatics.

Choose a reason for hiding this comment

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

I wonder whether e.g. a makefile might be more appropriate to steer the conversion process.

Copy link

@olantwin olantwin left a comment

Choose a reason for hiding this comment

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

Seems like the changes should not affect any other parts of sndsw. I've added some comments on the individual scripts.

For the new C++ and python files, I would recommend formatting them using clang-format and black respectively, as some of them are not easy to read.

For the shell scripts, it might be worth running shellcheck over them, as they look quite fragile. Maybe add some error checking as well?

Choose a reason for hiding this comment

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

will these changes have any impact on existing MC data being read with the new code?

Copy link
Author

Choose a reason for hiding this comment

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

No, it will only provide additional information. It fixes a bug in the DecodeBrickID, and it provide passage of position from local to global coordinates and viceversa.

All the information is retrieved with the TGeoNavigator from the geofile, so it should reflect the geometry of the MC simulation (if the right geofile is provided)

Choose a reason for hiding this comment

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

What is the use case for drawEmuTrack?
For the trident matching, I take the vertex and the attached track slopes from the emulsion scan, and overlay the electronic data with a given emu vertex. Only requires to read an ascii file once. I am wondering how much functionality should be inside the event display, if it would not be better to provide some already converted data to the event display.

In the method below, initialization is called for every call of the draw method. Is this on purpose? There is drawEmuTrack with argument itrack and brickID, and there is also drawEmuVertex with same arguments. Wouldn't it be better to combine both? Otherwise, the user has to take care to call both with the same arguments.

Copy link
Author

Choose a reason for hiding this comment

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

I agree, I basically used this method for testing the code when I was developing, since displaying tracks and vertexing was the easiest way to check that the positions were in the right place;

At production, a more efficient way can be surely pursued, I agree we can put the function in a different python script and then pass the converted data to the event display.

@matclim
Copy link

matclim commented Jul 31, 2024

The conversion from the emulsion coordinate system (assuming cm) as taken from the code (geometry/sndLHC_TI18geom_config.py) is reported to be DX = 46.8 and DY = -15.5. The conversion in question produces the following distance between the true MC shower center (determined by the distance to the center of the bin with the largest content with bin widths < 0.5mm) and the segments over 100 events of pi0 with energy between 100 MeV and 5 TeV spread out over the entire emulsion detector:

image

An attempt was made to change the distance manually to DX = 47.3; DY = -15.8; (trial and error was used to ensure the distance peak was as close as possible to 0, high confidence that the results are accurate within 1mm) This improves the performance and produce the following distance of segments and tracks respectively (for 100-1000 events of e- this time, same geometry):

image

image

The distance peak evidently cannot be brought to 0 as radial expansion is being looked at here. All of the displacements examples above were hard coded into the analysis code and are not part of SNDSW software.

@antonioiuliano2
Copy link
Author

Hello @matclim,

Thank you for your feedback!

Could you please add the information about which Monte Carlo production are you using?
I wonder if this discrepancy is related to the geometry file used.

Concerning this old pull request, I believe we should isolate the new conversion functions directly related to the SNDSW classes, and make a cleaner and updated pull request.

All the other Monte Carlo and FEDRA scripts are very old and now outdated, since the working versions are already included in the Emulsion Reconstruction repository.

@matclim
Copy link

matclim commented Jul 31, 2024

The MC script that was used was before spread production was implemented but was as follows:

python $SNDSW_ROOT/shipLHC/run_simSND.py -n 100 --PG --pID 111 --Estart 0.01 --Eend 5000 --EmuDet

the latest commit from the master is 15f50a8 not other geometry changes were made. Some changes were added in shipLHC/run_simSND.py to the primGen in order to allow for the diffuse production of particles all over the target.

Concerning the last point, should a new issue be created?

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.

5 participants