Skip to content

Commit

Permalink
Merge pull request JeffersonLab#2 from mccaky/toy_signal
Browse files Browse the repository at this point in the history
Toy signal
  • Loading branch information
mccaky authored Feb 27, 2020
2 parents 585eb8c + cc30535 commit cc9a5ed
Show file tree
Hide file tree
Showing 92 changed files with 9,657 additions and 479 deletions.
80 changes: 80 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,85 @@
updated: 3 Feb 2020

# Heavy Photon Search Toolkit for Reconstruction

The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format. It also provides tools which can be used to analyze the ROOT format of the data.

Please change HPSTR_BASE in setup.sh for your system.


## Checkout

```bash
mkdir hpstr
cd hpstr
mkdir src build install
cd src
git clone git@github.com:JeffersonLab/hpstr.git
cd ..
```

## Compilation

```bash
cd build
cmake3 -DCMAKE_INSTALL_PREFIX=../install/ -DLCIO_DIR=$LCIO_DIR ../src/hpstr/
make -j4 install
```
To compile with debug information, just add -DCMAKE_BUILD_TYPE=Debug to the cmake3 command

## Usage

The basic command string to run hpstr is

```
Usage: hpstr <config.py> [options]
Options:
-h, --help show this help message and exit
-i inFilename, --inFile=inFilename
Input filename.
-d outDir, --outDir=outDir
Specify the output directory.
-o outFilename, --outFile=outFilename
Output filename.
```


where ```<config.py>``` is a config file (which are stored in ```hpstr/processors/config/```), followed by various command line options. Different configuration files, might have specific command line options. Please check each configuration file to check which options are available on top of the common ones.

Hpstr can both run on LCIO files to produce ROOT ntuples, producing the hpstr event with all the objects needed for analysis, and on ROOT ntuples to produce histograms. This can be setup by using the appropriate configuration file.

### Ntuples production

The configuration to produce ntuples from LCIO files is ```recoTuple_cfg.py```. Typical usage is:
```bash
hpstr recoTuple_cfg.py -i <inLcioFile> -o <outROOTFile>
```

### Making Plots

A working example on how to make some plots out of hpstr ntuple is

```bash
hpstr anaVtxTuple_cfg.py -i /nfs/slac/g/hps3/users/bravo/data/physrun2016/7800/hps_007800.123_v0_4.2_4.4-SNAPSHOT_rereco.root -o hps_007800.123.root -t 1
```
This example will run the standard vertex selection on a data file (to specify that this file is data one has to use the ```-t``` flag and passing 0 will tell hpstr that we are processing MonteCarlo. Plots will be produced according to the selections specified.

## Available Scripts

The sripts folder in the hpstr repo provides a serie of utilities which some or them are described here.

### Processing multiple files

The script ```run_jobPool.py``` provides a way to process multiple files with hpstr in parallel in parallel threads.
Here is an example on how to run it

```bash
python run_jobPool.py -t hpstr -c <configFile.py> -i <inDir> -z <isData> -o <outDir> -r <root|slcio>
```

where ```-c``` is used to specify the configurationFile for hpstr, ```-i``` and ```-o``` are for specifying the input and output directory respectively, ```-z``` is to choose between data (=1) and MC simulation (=0) input type, and finally ```-r``` is needed to tell hpstr to run on root or slcio files. The script runs one hpstr process for each file on the input folder matching the required extension and places the results in the output directory. Before running the user needs to create a folder ```<outDir>/logs``` otherwise the script fails [will be fixed soon].

## Contributing to Hpstr

Fork the repository first. Open an issue to first discuss what needs to be changed and then open a pull request using the issue number.
1,653 changes: 1,653 additions & 0 deletions analysis/data/listData_2016_10percent.txt

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions analysis/data/runByrun_VxVy_calibration.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#run uncVx_mean uncVx_sigma uncVy_mean uncVy_sigma uncVz_mean uncVz_sigma tgtProjX_mean tgtProjX_sigma tgtProjY_mean tgtProjY_sigma
5772 -0.091683900354 0.215941433591 -0.0768593640179 0.0880585145088 -3.96202764642 2.85097891202 -0.222518097419 0.216142575865 -0.0772576727641 0.0862467591439
7629 -0.113246598948 0.318293608185 -0.0860657518949 0.0992756085509 -4.19104585263 2.9390255072 -0.245113264379 0.31676700573 -0.0857436564803 0.0965301528603
7630 -0.115263120695 0.32023371459 -0.0822927925779 0.0989502638645 -4.17059712221 2.97107528612 -0.247291964824 0.317675164072 -0.0817515431667 0.0970450888989
7636 -0.11688994069 0.327754044889 -0.0906893235309 0.0990204582082 -4.24459927748 2.9648010199 -0.2488552368 0.32713411214 -0.0907534099205 0.095627259359
7637 -0.0798609805423 0.328936100725 -0.093783304923 0.0981048890181 -4.28422226819 2.96595462773 -0.213313340902 0.327415263035 -0.0932023225101 0.0949712562402
7644 -0.104739012745 0.32964088247 -0.085599912921 0.106861491199 -4.20144685246 2.96646117065 -0.235656380194 0.329378391621 -0.0856205984726 0.104865692766
7653 -0.108033688138 0.321037040785 -0.0813359828825 0.108984731918 -4.21164780149 2.9810074003 -0.239707464707 0.322741205908 -0.0815801083905 0.107282803272
7779 -0.130474681441 0.345134093711 -0.100344508205 0.104862123289 -4.2407031218 2.97710779271 -0.262620025292 0.345218657427 -0.100118041093 0.102120897049
7780 -0.125925894298 0.344542882343 -0.0985218080505 0.106198270579 -4.19873898689 3.00204977285 -0.257576791933 0.344809808935 -0.0984665204442 0.103802778055
7781 -0.14027306124 0.340597723982 -0.0987238152639 0.102427010061 -4.20611911835 3.0208273582 -0.272202087387 0.338622537977 -0.0990510494231 0.0995310379425
7782 -0.134595195618 0.347962139153 -0.118121948754 0.107516142228 -4.2544512899 2.98425576489 -0.265739002123 0.345535571649 -0.117389166774 0.104979028295
7783 -0.134595195618 0.347962139153 -0.118121948754 0.107516142228 -4.2544512899 2.98425576489 -0.265739002123 0.345535571649 -0.117389166774 0.104979028295
7783 -0.136400030273 0.34491754445 -0.095224732951 0.10595430732 -4.25335879353 2.91888014416 -0.264962597847 0.347098830063 -0.0939595727755 0.102303441688
7786 -0.150611808746 0.35531710295 -0.0993922757853 0.118723060995 -4.22486693686 2.88929275136 -0.282842088408 0.355463126531 -0.0976047649705 0.115526714143
7796 -0.125043278239 0.341136197665 -0.0823196916886 0.109173192464 -4.20838757916 3.03473152766 -0.257057994894 0.340763473986 -0.0822914694117 0.107237119723
7798 -0.127925449096 0.342523827823 -0.0741322823239 0.104397891259 -4.24813441374 3.0351326334 -0.259907336781 0.342852401716 -0.0739854654459 0.102220216846
7799 -0.13598106977 0.338730728082 -0.0732433449116 0.101793201638 -4.22546050776 3.03584314121 -0.267385894791 0.339121220876 -0.0732081462865 0.0997934435349
7800 -0.132067895667 0.33663731855 -0.0743550601346 0.102015199636 -4.22074152793 3.03574740213 -0.263633232772 0.335668041848 -0.0741187264136 0.100005906547
7801 -0.136357933165 0.336429243861 -0.0762191570526 0.103443939606 -4.2365607571 3.0136147778 -0.269258816389 0.334623685048 -0.0761159171232 0.1017190165
7803 -0.125814923474 0.335009501474 -0.0712889839465 0.0999171530856 -4.37219238006 3.00322502939 -0.25695002323 0.333461894332 -0.0710363902161 0.0980852204785
7804 -0.12576393526 0.33310756713 -0.0732528356373 0.0998727927845 -4.35565701469 2.98409779574 -0.257479827317 0.332540759905 -0.0730739239005 0.0977138859917
7805 -0.124071945953 0.331822226931 -0.0702410387735 0.0991450536818 -4.35765010716 2.97611077997 -0.255063876691 0.330986751199 -0.0702955088581 0.0971004573893
7807 -0.130092268002 0.333680954332 -0.0695252239289 0.100172330418 -4.29364185642 3.03767472334 -0.262540041299 0.332106828117 -0.0696163304527 0.0980494445314
7947 -0.0581775775288 0.344057761227 -0.122988240621 0.093169583106 -4.16926681284 2.97112621947 -0.189345900011 0.344943446166 -0.122993312614 0.0911677579011
7948 -0.0330748719408 0.33761162063 -0.13940160878 0.0918113264767 -4.21954287989 2.92624166644 -0.164827215794 0.337482367838 -0.139484283995 0.08985003911
7949 -0.0424297157574 0.334063341146 -0.147396308463 0.0920181997179 -4.25580247022 2.95346073695 -0.174291854198 0.333814376674 -0.147834637186 0.0890642855866
7953 -0.0112722921503 0.336350113001 -0.155134942432 0.0919594904042 -4.25291117149 2.93831167797 -0.143382521936 0.332752758997 -0.155385098419 0.0897906783934
7962 -0.0369311898767 0.334747910668 -0.152056130482 0.0926249188862 -4.2736844049 2.99125094627 -0.168095617289 0.333759444266 -0.152122792443 0.0897216868351
7963 -0.0341845020189 0.333660104369 -0.156482292023 0.0918223973706 -4.29216468418 2.95380941134 -0.165329739995 0.333898066951 -0.155943476935 0.0891894987104
7964 -0.0439538635511 0.331946781534 -0.157177443659 0.0922264364063 -4.30542039938 2.95333769933 -0.175331619387 0.332248690977 -0.156790852528 0.0892753979325
7965 -0.0332520423785 0.334248173096 -0.152787112364 0.0928579075926 -4.32105704964 2.9593590225 -0.166558328489 0.333055293292 -0.152870409457 0.0889785359917
7966 -0.0413370384949 0.335421426263 -0.153248471257 0.0923558537498 -4.32203337923 2.96357938512 -0.17283012095 0.334674070759 -0.152837220589 0.0893598859641
7968 -0.0567243046196 0.334596706131 -0.150518632596 0.094151738197 -4.33350552047 2.96420474792 -0.187907846423 0.335279067804 -0.150434083866 0.0902676046262
7969 -0.0500904562478 0.332729339508 -0.145855914611 0.0935827220381 -4.35460780356 2.96339530321 -0.182728446279 0.328544345133 -0.146786187835 0.0898576756431
7970 -0.0587960811104 0.333672455431 -0.126233489426 0.0959775776852 -4.35740969163 2.96609066417 -0.191339113364 0.332629919211 -0.126146699063 0.0934940682738
7972 0.0820535789233 0.328697929277 -0.105224071022 0.0923959291953 -4.36856137283 2.99276211779 -0.0494111547367 0.328668997191 -0.105691337696 0.0895050056096
7976 0.0481810062504 0.330886078481 -0.109213390666 0.0926340123765 -4.31204129677 2.96838668456 -0.0835390872364 0.332708513698 -0.109389815582 0.0898996398293
7982 0.0650150655524 0.331820707929 -0.10685161366 0.0909835249309 -4.32048612773 2.98411871483 -0.0671657271812 0.330137999171 -0.106656875544 0.0883546098159
7983 0.0688786024992 0.329382318595 -0.112893190564 0.090800190764 -4.29414034459 2.98483406308 -0.0635003548674 0.327170978577 -0.112781353943 0.0888249719332
7984 0.072960457505 0.330791821306 -0.115459072367 0.0923182734714 -4.29989616534 2.98305233753 -0.0592650047513 0.328856117846 -0.11519342627 0.0894274664121
7985 0.0773845694939 0.336110012639 -0.123977361578 0.0923635142754 -4.32041307965 2.96880881881 -0.0544823062065 0.335933513 -0.124091897883 0.0903493182284
7986 0.0861945303329 0.335741436572 -0.14620597236 0.092477609264 -4.32413777208 2.98521148006 -0.0454724701278 0.334770599936 -0.146646598928 0.0896514746912
7987 0.088803087648 0.343009444542 -0.153091227573 0.0926159317382 -4.32993265488 2.98201498634 -0.0432175153171 0.34150132073 -0.152816865271 0.0901424485431
7988 0.0960872568418 0.343686760736 -0.153420281417 0.0927874845098 -4.33582308033 2.97634707177 -0.0350986005738 0.344268267716 -0.153014494052 0.0897596271262
8025 0.0348997304952 0.312820202652 -0.12351466426 0.106869322522 -4.2842428437 2.97543304293 -0.0971524657683 0.314686013611 -0.123790576381 0.104512549403
8026 0.0374827061405 0.311340910831 -0.121171122368 0.107373641519 -4.31770498502 2.97386908057 -0.0943859298482 0.311420978885 -0.121385169969 0.105381752733
8027 0.0352269362524 0.312696753966 -0.118877813478 0.106869464664 -4.29629934616 2.99635997465 -0.0966371540479 0.312448403999 -0.118610206606 0.104276157742
8028 0.0332074310851 0.313366170172 -0.114232423237 0.106803680884 -4.28754374795 2.98098943265 -0.0982985732861 0.312693535985 -0.113890764571 0.104090790509
8029 0.0368637448373 0.3104697963 -0.117486339791 0.106715247896 -4.25318203776 2.97727178942 -0.0947292983299 0.311349006058 -0.117326938986 0.104070498261
8030 0.0416225552065 0.312333420783 -0.119032619725 0.106414506774 -4.26466325472 2.99672161633 -0.0900277347202 0.311790799538 -0.118607009167 0.103931365885
8031 0.0429298138012 0.314674448561 -0.119009060281 0.107134837425 -4.23151716648 3.02465619713 -0.0895354970766 0.313880750095 -0.118459021781 0.104296601713
8039 0.0428277882885 0.315118840134 -0.114508013521 0.109548787148 -4.23351242722 3.0377777732 -0.089981230736 0.31461558017 -0.114198838656 0.107062459636
8040 0.0437641250804 0.314829977743 -0.115858124271 0.109472539674 -4.24009719489 3.02541383978 -0.0886798624409 0.312731506242 -0.11557202277 0.106822829998
8041 0.0455582953854 0.317329104491 -0.115115355078 0.10926111062 -4.27684840676 3.06067531782 -0.0866811155814 0.315390664695 -0.114346821868 0.107174467093
8043 0.0442677713409 0.31364264364 -0.114159538912 0.111535783899 -4.23485090821 3.04037777682 -0.0879925888819 0.31161840453 -0.113612283553 0.108814900119
8044 0.0411990125044 0.312116669392 -0.109217345757 0.110916505633 -4.23550959339 3.05112546628 -0.0906890424881 0.311434750082 -0.10947282431 0.108591945406
8045 0.0324497250767 0.311208275629 -0.109852906128 0.108475590311 -4.21304559013 3.04285541433 -0.0993808080138 0.311533135731 -0.109712524599 0.106937787775
8046 0.0326956417032 0.313034800748 -0.110501102346 0.107539230832 -4.23037804079 3.0440616452 -0.098569573813 0.312609515063 -0.110318369952 0.105344914284
8047 0.0305335990138 0.313862370981 -0.112915460441 0.106443779428 -4.21660479283 3.04784977304 -0.100931837204 0.313587590073 -0.112764827389 0.104517819756
8048 0.0339141894597 0.312458739386 -0.119706837531 0.107743461555 -4.24073975536 2.99732365908 -0.0987157386585 0.312112094948 -0.119583774141 0.105121193503
8049 0.0319171612964 0.31275592215 -0.120202473995 0.108768131619 -4.22712595185 3.02773586421 -0.0993485182304 0.31198445114 -0.120008358188 0.106463702069
8051 0.0423150218585 0.315197007188 -0.124683554248 0.106189259251 -4.27678764234 3.01131014909 -0.0900409643353 0.314728872926 -0.124670171557 0.103496808181
8055 0.0711005825762 0.309392909464 -0.132706574855 0.105921908527 -4.31779948367 2.99776891485 -0.0606476158396 0.309879807034 -0.132856312976 0.10419813009
8057 0.0517571253282 0.313391402874 -0.118466764759 0.108143080936 -4.31933888392 3.00701358248 -0.0806510957818 0.312728239146 -0.1180400076 0.105542337989
8058 0.0532445644741 0.314049420507 -0.124854266394 0.107022078697 -4.31484910124 3.00662316347 -0.0786428407179 0.312927049975 -0.125163018511 0.104892076904
8059 0.0449912091306 0.317328209452 -0.12723010516 0.107134362798 -4.32236344016 3.00328857892 -0.087325658255 0.31680661686 -0.12711703882 0.10499699592
8072 0.07750195589 0.318646711777 -0.134732203671 0.109013860661 -4.17758743468 2.95800489669 -0.0547680369542 0.319777922968 -0.134870255031 0.107252593415
8073 0.0340259659448 0.31423675717 -0.120245934115 0.109086816647 -4.16560678718 2.98808214486 -0.0979518996568 0.315056530398 -0.119971455126 0.10693581967
8074 0.0547378094546 0.318042384296 -0.12984639818 0.105112399307 -4.17290720572 2.96866830168 -0.0769501003107 0.318488780243 -0.129606844831 0.10299128937
8075 0.0390700067904 0.321046963861 -0.126543915351 0.105088470354 -4.20945412358 2.96120248033 -0.0929862979662 0.320637544893 -0.126312572498 0.103236027844
8077 0.0605456820502 0.318340751681 -0.124057328927 0.104971395103 -4.21684386707 2.96685599089 -0.0707039171152 0.318173024895 -0.123860128046 0.102107090879
8085 0.0956920615918 0.319068748069 -0.0959977725216 0.102134393719 -4.11968162238 2.93653052064 -0.0355435973259 0.318369504133 -0.0964039870612 0.0991889612335
8086 0.121177573786 0.330960259573 -0.0994559226509 0.105333697852 -4.1605548005 2.95467233524 -0.010423529988 0.330470192302 -0.0997570204436 0.102863189265
8087 0.0902594604494 0.331249771999 -0.0807068866044 0.10360983899 -4.19670911191 2.96942204077 -0.0413274457835 0.332150832457 -0.0808032562807 0.101723892388
8088 0.137976997372 0.326966572894 -0.088479535737 0.103846781561 -4.20884214806 2.94439372486 0.00600262875978 0.327837181228 -0.0884291051417 0.101702156205
8090 0.0669543447429 0.326183583974 -0.0804206777393 0.102957848474 -4.17921798963 2.95734026941 -0.0648135258367 0.325620339242 -0.0802320684496 0.10099517562
8092 0.0448902402866 0.324197328608 -0.0736801390543 0.102515560281 -4.21815360011 2.97156660146 -0.0872255197662 0.323358730297 -0.073707660661 0.100388252074
8094 0.0406555537244 0.32459688848 -0.0703990964261 0.101084796379 -4.19730418489 2.97058859326 -0.0918062556582 0.323338112295 -0.0701406815643 0.0990404330955
8095 0.0454271006053 0.323006243917 -0.073819582723 0.102070179235 -4.19512297106 2.97466127506 -0.0860051809295 0.323360947115 -0.0739388631137 0.100243279713
8096 0.0404823516389 0.328185245789 -0.0729775265221 0.10205763944 -4.20800761225 2.9784782214 -0.0902459829141 0.327237946029 -0.0728399641743 0.100323551694
8097 0.050698291614 0.333212605243 -0.0737279916847 0.103633266026 -4.17070137213 3.01895117987 -0.080400170786 0.332434023403 -0.0735401406162 0.101802787221
8098 0.0435728164365 0.331303325941 -0.0747818790467 0.103970051901 -4.19191952433 2.98044813483 -0.0877670796948 0.330698856941 -0.0746734084459 0.101829361029
8099 0.0510542993981 0.332185301334 -0.0824271808025 0.10362559797 -4.19802831598 2.97756443474 -0.0805514661648 0.332258719201 -0.0822786996921 0.101645825982
17 changes: 17 additions & 0 deletions analysis/data/samples_xsections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"RADBeam" : {
"xsec" : 81.61e3,
"xsecerr" : 0.834,
"nGen" : 99670000
},
"tritrigBeam" : {
"xsec" : 1.416e6,
"xsecerr" : 0.00431e6,
"nGen" : 492650000
},
"wabBeam" : {
"xsec" : 0.1985e9,
"xsecerr" : 0.01973e9,
"nGen" : 996600000
}
}
75 changes: 75 additions & 0 deletions analysis/include/AnaHelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/**
* @file AnaHelpers.h
* @brief Helper class for hipster analysis
* @author PF, SLAC
*/

#include <iostream>


#include "TMatrix.h"
#include "TVector3.h"
#include "TRotation.h"
#include "TMatrixDSym.h"
#include "TMatrixTSym.h"

//HPSTR
#include "Track.h"
#include "TrackerHit.h"
#include "Particle.h"
#include "Vertex.h"



class AnaHelpers {

public :

AnaHelpers();

/*
* Rotate a vector from HPS to SVT Frame (i.e. for position/momentum rotation)
*/


TVector3 rotateToSvtFrame(TVector3 v);

/*
* Rotate a vector from HPS to SVT Frame via TRotation
*/

TVector3 rotationToSvtFrame(const TVector3& v);

/*
* Rotate a matrix from HPS to SVT Frame (i.e. for covariance matrix rotation)
*/

TMatrixDSym rotateToSvtFrame(TMatrixDSym cov) {
return cov.Similarity(*rotSvt_sym);
}

TMatrixDSym rotateToHpsFrame(TMatrixDSym cov) {
return cov.SimilarityT(*rotSvt_sym);
}

/**
* Checks if a track has a 3d hit on innermost layer and second innermost layer
*/

void InnermostLayerCheck(Track* trk, bool& foundL1, bool& foundL2);

bool GetParticlesFromVtx(Vertex* vtx, Particle*& ele, Particle*& pos);

bool MatchToGBLTracks(int ele_id, int pos_id, Track* & ele_trk, Track* & pos_trk, std::vector<Track*>& trks);

static std::string getFileName(std::string filePath, bool withExtension);

private:

//Angle between SVT system and HPS coordinates
const double SVT_ANGLE = -30.5e-3;
TRotation rotSvt;
TMatrixDSym* rotSvt_sym;
};


Loading

0 comments on commit cc9a5ed

Please sign in to comment.