We have done some work on the datamixer for Ecal. It was basically along the following two lines:
- Modify the code in order to add correct handling of the gain switch
- Validate the code by producing the following samples
- Minbias with noise
- Minbias no noise mixed with nu gun with noise
- Nu gun with noise mixed with minbias no noise
Gain switch code
The idea is that in mixing two digis, the gain of the highest energy sample should be retained. The lower energy sample should be scaled to the lower (higher energy) gain taking into account that the pedestals are different for different gains. The formula we use is therefore:
when the sample to be mixed has lower energy and similar for the opposite situation. If adc_sum is then higher than 4096, the gain is switched again if we are not already in gain 1.float ratio = gainRatios[gain_new-1]/gainRatios[gain_old-1];
adc_old = (int) round ((adc_old - pedeStals[gain_old-1]) * ratio + pedeStals[gain_new-1] );
adc_sum = adc_new + adc_old;
The code is committed at the HEAD as
SimGeneral/DataMixingModule/plugins/DataMixingEMDigiWorker.cc
SimGeneral/DataMixingModule/plugins/DataMixingEMDigiWorker.h
Gain switch validation
We "validated" by looking at the
resulting FADC traces after mixingan electron gun of 1000 GeV without noise with nu gun events. We used a trivial module called PlotEcalDigis (see section Test Code below). Here are examples of FADC traces after mix. One is for a channel that switches to gain 1 (g3), one switches to gain 2 (g2) and one stays in g1 and shows noise (proving that the digis do mix).
Todo: check that without mixing the trace is flat

Known issue
There are cases in which the datamixer produces empty traces with gainId=0 (which is a non valid gainId). Under investigation.
Test Code
The code used can be checked out from UserCode/Torino/Ecal/datamixerstuff
The package UserCode/PlotEcalDigis contains the analyzer to plot FADC traces. The procedure used was the following:
cmsRun sim-singlee1000-nonoise.py
cmsRun reco-egun.py
cmsRun mm_deb_overlay_egunonnugun_cff.py
cmsRun src/User/PlotEcalDigis/python/runplotdigis_cfg.py
Note that mixOne_data_on_data_secEqNu_cfi.py has to be copied to SimGeneral/DataMixingModule/python and compiled. The last step produces a file called histo.root that with FADC traces
MinBias with Nu mixes
I generated the samples that I report here :
- Minbias with noise
- Minbias no noise mixed with nu gun with noise
- Nu gun with noise mixed with minbias no noise
#generation cmsRun sim-minbias-noise.py >& log1.log
cmsRun sim-minbias-nonoise.py >& log2.log
cmsRun sim-nugun-noise.py >& log3.log
#get reco digi cmsRun reco-minbias-noise.py >& log4.log
cmsRun reco-minbias-nonoise.py >& log5.log
cmsRun reco-nugun.py >& log6.log #mix
cmsRun src/SimGeneral/DataMixingModule/test/mm_deb_overlay_minbiasonnu_cff.py >& log7.log
cmsRun src/SimGeneral/DataMixingModule/test/mm_deb_overlay_nuonminbias_cff.py >& log8.log
#get rechits from mixed digis
cmsRun rereco-mix-MinbiasNoNoiseonNu.py >& log9.log
cmsRun rereco-mix-NuonMinBiasNoNoise.py >& log10.log
In this complicated procedure we generate and save raw data, reconstruct and generate digis, mix from reconstructed digis (note that it is possible to mix from simulated digis or rechits). Indeed we could have taken a shorter path. Then we reconstruct again to look at rechits after mixing.
Here we show the distribution of rechit energies in five cases:
Nu gun (pure noise)

Minimum bias without noise

Minimum bias with noise

Minimum bias no noise mixed on nu gun :

Nu gun mixed with minimum bias no noise

The last three distribution seem compatible, proving that the mixing works
Electrons of 250 GeV on top of electrons of 1000 GeV
We have generated electrons of different energies in the same eta/phi region to check that samples with different gains are added consistently.
Note : in the following "e100" is reported where it should be "e1000", as the configuration file
sim-singlee100-noise-small.py actually contains settings for e1000. This is why there are switches to gainId=3.
#test gain switch e250 on e100 in a small region
cmsRun sim-singlee100-noise-small.py
cmsRun sim-singlee250-noise-small.py cmsRun reco-egun-100-small.py
cmsRun reco-egun-250-small.py
cmsRun src/SimGeneral/DataMixingModule/test/mm_deb_overlay_egunonegun_cff.py
cmsRun src/User/PlotEcalDigis/python/runplotdigis_cfg.py
Here are a couple examples
Summing
Adding signals -2 191
1 199[1] 201[1] 200[1] 293[1] 3147[2] 4071[2] 3637[2] 2805[2] 2033[2] 1435[2]
2 201[1] 200[1] 199[1] 203[1] 532[1] 638[1] 591[1] 496[1] 409[1] 341[1]

Adding signals -1 12
1 200[1] 200[1] 199[1] 205[1] 499[1] 597[1] 550[1] 465[1] 389[1] 326[1]
2 198[1] 200[1] 201[1] 256[1] 3825[1] 2589[2] 2322[2] 1809[2] 1333[2] 963[2]

Adding signals -1 11
1 202[1] 199[1] 200[1] 352[1] 941[3] 1166[3] 1054[3] 848[3] 656[3] 506[3]
2 200[1] 201[1] 198[1] 390[1] 1128[3] 1410[3] 1270[3] 1011[3] 771[3] 585[3]

Adding signals -1 190
1 200[1] 200[1] 202[1] 209[1] 767[1] 944[1] 860[1] 700[1] 554[1] 438[1]
2 200[1] 200[1] 199[1] 204[1] 476[1] 565[1] 525[1] 446[1] 373[1] 318[1]

Adding signals -1 191
1 197[1] 198[1] 202[1] 213[1] 1122[1] 1416[1] 1278[1] 1021[1] 779[1] 588[1]
2 201[1] 199[1] 202[1] 414[1] 1252[3] 1572[3] 1413[3] 1120[3] 847[3] 636[3]
The opposite overlay (electrons of 250 GeV on electrons of 1000 GeV) has been tested and gave sensible results (question: why are'nt the input traces just swapped ?)Adding signals -2 191
1 200[1] 199[1] 202[1] 291[1] 3119[2] 4034[2] 3602[2] 2779[2] 2018[2] 1423[2]
2 201[1] 200[1] 201[1] 202[1] 517[1] 617[1] 573[1] 481[1] 399[1] 334[1]

Adding signals -1 191
1 199[1] 203[1] 198[1] 214[1] 1009[1] 1268[1] 1150[1] 922[1] 706[1] 540[1]
2 200[1] 200[1] 199[1] 411[1] 1236[3] 1554[3] 1400[3] 1108[3] 839[3] 630[3]

Adding signals -1 190
1 199[1] 200[1] 199[1] 209[1] 675[1] 821[1] 753[1] 622[1] 497[1] 401[1]
2 200[1] 199[1] 199[1] 205[1] 448[1] 534[1] 495[1] 425[1] 358[1] 306[1]

Adding signals -1 11
1 199[1] 200[1] 201[1] 325[1] 3847[2] 992[3] 900[3] 730[3] 573[3] 452[3]
2 199[1] 202[1] 201[1] 398[1] 1163[3] 1457[3] 1312[3] 1043[3] 793[3] 600[3]

Adding signals -1 12
1 199[1] 200[1] 200[1] 203[1] 440[1] 515[1] 484[1] 414[1] 351[1] 302[1]
2 200[1] 200[1] 198[1] 255[1] 3826[1] 2586[2] 2317[2] 1805[2] 1331[2] 960[2]
