Skip to content

BS parameters for MC production & upload to CondDB

francescobrivio edited this page Sep 13, 2022 · 7 revisions

General idea:

The whole procedure consists of these steps:

  1. define the parameter values, e.g. starting from the measurement of beamspot on data;
  2. create a set of VtxSmearing parameters in this file;
  3. create and upload a BeamSpotRcd payload containing the corresponding parameter values ("TAG_v0_mc");
  4. fit the beamspot on the RelVal MC samples produced with the input VtxSmearing parameters + .db file created in the steps above;
  5. create and upload a second BeamSpotRcd payload ("TAG_v1_mc") containing the newly measured parameter values.

In the following steps 2-4 are described. Step 5 is exactly the same as step 3, starting from the new .txt file.


Step2: VtxSmearing parameters

1. start from the (averaged over the period you’re interested in) BS x, y, z and sigma z handy;
2. you also need the position of the BPIX barycentre;
3. apply a translation of -BPIX to your BS, so that the centre of the reference frame coincides with the position of the BPIX barycentre. These are the x,y and z coordinates to be passed to the vtx smearing module.
4. beta*: you take from the LHC beam parameters during the relevant run.
5. emittance: can be computed from https://lpc.web.cern.ch/lumiCalc.html, using sigma_x, sigma_y and beta star. Basically you have to change the "Normalised transverse emittance" value until you get "Transverse beam spot" equal to the sigma_x or sigma_y value you need (not "Transverse beam size at IP").

  • 5.1 in the emittance formula you’ll have to choose between sigma_x and _y, and you’ll probably see the two differ slightly in data. In pp runs this is due to a small tilt wrt the beam z direction and the sigma with the lowest value is the one closest to the actual beam transverse width.
  • 5.2 the machinery takes in the non-normalised transverse emittance in cm, you’ll need to plug in a 10^2 factor to the number you get from the calculator

Step3: Prepare the payload

1. Prepare a .txt file in the usual BS format with the parameters corresponding to those of the new set of VtxSmearing parameters (i.e. the positions should be compatible with the ones added in the new VtxSmearing parameters).
2. You are now with file named, e.g., BeamFit_*.txt. In order to create a .db file to be uploaded to DropBox, open this file and remove the first four lines (i.e. remove:

Runnumber 1
BeginTimeOfFit 1970.01.01 00:00:00 GMT 0
EndTimeOfFit 1970.01.01 00:00:00 GMT 0
LumiRange 1 - 90

3. Open the python file write2DB.py and modify the name of the output file (modify here) and the creation tag (modify here). The name of input txt file will be passed via command line.

4. Now run

cmsRun write2DB.py inputFile=BeamFit_*.txt

You will have a .db file in your directory. To check if the stored values do agree with your previous txt file, you can run the script readDB.py modifying the input file and the tag accordingly.

5. In order to upload the .db file to dropbox, follow the instructions on https://twiki.cern.ch/twiki/bin/view/CMS/ConditionUploader#Usage The final .txt file for the upload to dropbox should be something like

{
    "destinationDatabase": "oracle://cms_orcon_prod/CMS_COND_31X_BEAMSPOT",
    "destinationTags": {
        "BeamSpotObjects_0TdNdEtaCollision2015_v0_mc": {
            "dependencies": {},
            "synchronizeTo": "offline"
        }
    },
    "inputTag": "BeamSpotObjects_0TdNdEtaCollision2015_v0_mc",
    "since": null,
    "userText": "Beamspot as measured in data, run 247324, LS88-311, special dNdEta run, 0 Tesla"
}

6. Finally, queue your tag to the chosen queue as explained here

Step4: Run the beamspot fit on a MC sample:

cmsrel CMSSW_X_X_X
cd CMSSW_X_X_X/src
cmsenv
git cms-addpkg RecoVertex/BeamSpotProducer
scram b -j 8
cd RecoVertex/BeamSpotProducer/test
cmsRun BeamFit_LumiBased_NewAlignWorkflow.py

Before running cmsRun, make sure you properly modified the input files and parameters (saveNtuples, ...).
In order to fit the BS parameters using the whole statistics, set

process.d0_phi_analyzer.BSAnalyzerParameters.fitEveryNLumi   = -1  
process.d0_phi_analyzer.BSAnalyzerParameters.resetEveryNLumi = -1

The location of input data can be found on https://cmsweb.cern.ch/das/.
(Input data format is something like
/RelValMinBias_13/CMSSW_7_4_6_patch5-TkAlMinBias-74X_mcRun2_startup_realisticBS_Queue-v1/ALCARECO )

NB. The .txt output file is not re-created every time you run the cfg, but the results are appended at the end of the file. If you run twice the same cfg, make sure not to have duplicate entries in the payload.txt.

(partially old:
If you have run the BS fit per each LS, and you want to to produce the average beamspot parameters over the entire run, you can use the script RecoVertex/BeamSpotProducer/python/workflow/test/test_workflow.py.
You should change

  • the run number (here): it is 1 in MC
  • the input .txt file (here)
  • comment from line 39 to 57, since this is needed only for data

)

Clone this wiki locally