Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CRVReco/fcl/prolog_v11.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ BEGIN_PROLOG
usePulseOverlaps : true //automatically uses noFitReco option
useNoFitReco : true
usePEsPulseHeight : false //using the PEs that were calculated using the pulse height instead of pulse area
bigClusterThreshold : 800
bigClusterThreshold : 500
fiberSignalSpeed : 140 //140 mm/ns //FIXME: The correct value should be 175 mm/ns.
timeOffset : 34.5 //34.5 ns
compensateChannelStatus : [0,1,2] //not connected channels (bit 0), ignored channels in reco (bit 1), channels that have no data (bit 2)
Expand Down
2 changes: 1 addition & 1 deletion CRVReco/src/CrvPedestalFinder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace mu2e
size_t channelIndex=barIndex*4 + SiPM;
_pedestalHists.emplace_back(tfs->make<TH1F>(Form("crvPedestalHist_%lu",channelIndex),
Form("crvPedestalHist_%lu",channelIndex),
2000,-50,150)); //TODO: needs to be only between -50 and +50, but Offline currently sets the pedestal at +100
200,-50,150)); //TODO: needs to be only between -50 and +50, but Offline currently sets the pedestal at +100
}
}
}
Expand Down
25 changes: 21 additions & 4 deletions CRVReco/src/CrvRecoPulsesFinder_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#include "Offline/CRVReco/inc/MakeCrvRecoPulses.hh"

#include "Offline/CosmicRayShieldGeom/inc/CosmicRayShield.hh"
#include "Offline/DAQConditions/inc/EventTiming.hh"
#include "Offline/DataProducts/inc/CRSScintillatorBarIndex.hh"
#include "Offline/DataProducts/inc/EventWindowMarker.hh"

#include "Offline/CRVConditions/inc/CRVDigitizationPeriod.hh"
#include "Offline/CRVConditions/inc/CRVCalib.hh"
Expand Down Expand Up @@ -60,7 +62,8 @@ namespace mu2e
fhicl::Atom<float> pulseThreshold{Name("pulseThreshold"), Comment("fraction of ADC peak used as threshold to determine the pulse time interval for the no-fit option")}; //0.5
fhicl::Atom<float> pulseAreaThreshold{Name("pulseAreaThreshold"), Comment("threshold to determine the pulse area for the the no-fit option")}; //5
fhicl::Atom<float> doublePulseSeparation{Name("doublePulseSeparation"), Comment("fraction of both peaks at which double pulses can be separated in the no-fit option")}; //0.25
fhicl::Atom<art::InputTag> protonBunchTimeTag{ Name("protonBunchTimeTag"), Comment("ProtonBunchTime producer"),"EWMProducer" };
fhicl::Atom<art::InputTag> eventWindowMarkerTag{Name("eventWindowMarkerTag"), Comment("EventWindowMarker producer"),"EWMProducer"};
fhicl::Atom<art::InputTag> protonBunchTimeTag{Name("protonBunchTimeTag"), Comment("ProtonBunchTime producer"),"EWMProducer"};
fhicl::Atom<float> timeOffsetScale{Name("timeOffsetScale"), Comment("scale factor for time offsets from database (use 1.0, if measured values)")}; //1.0
fhicl::Atom<float> timeOffsetCutoffLow{Name("timeOffsetCutoffLow"), Comment("lower cutoff of time offsets (for random values - otherwise set to minimum value)")}; //-3.0ns
fhicl::Atom<float> timeOffsetCutoffHigh{Name("timeOffsetCutoffHigh"), Comment("upper cutoff of time offsets (for random values - otherwise set to maximum value)")}; //+3.0ns
Expand All @@ -80,6 +83,7 @@ namespace mu2e
boost::shared_ptr<mu2eCrv::MakeCrvRecoPulses> _makeCrvRecoPulses;

std::string _crvDigiModuleLabel;
art::InputTag _eventWindowMarkerTag;
art::InputTag _protonBunchTimeTag;

float _timeOffsetScale;
Expand All @@ -97,6 +101,7 @@ namespace mu2e
CrvRecoPulsesFinder::CrvRecoPulsesFinder(const Parameters& conf) :
art::EDProducer(conf),
_crvDigiModuleLabel(conf().crvDigiModuleLabel()),
_eventWindowMarkerTag(conf().eventWindowMarkerTag()),
_protonBunchTimeTag(conf().protonBunchTimeTag()),
_timeOffsetScale(conf().timeOffsetScale()),
_timeOffsetCutoffLow(conf().timeOffsetCutoffLow()),
Expand Down Expand Up @@ -135,9 +140,21 @@ namespace mu2e
std::unique_ptr<CrvRecoPulseCollection> crvRecoPulseCollection(new CrvRecoPulseCollection);

double TDC0time = 0;
art::Handle<ProtonBunchTime> protonBunchTime;
event.getByLabel(_protonBunchTimeTag, protonBunchTime);
if(protonBunchTime.isValid()) TDC0time = -protonBunchTime->pbtime_;

art::Handle<EventWindowMarker> eventWindowMarker;
event.getByLabel(_eventWindowMarkerTag,eventWindowMarker);
EventWindowMarker::SpillType spillType = eventWindowMarker->spillType();
if(spillType==EventWindowMarker::SpillType::onspill)
{
art::Handle<ProtonBunchTime> protonBunchTime;
event.getByLabel(_protonBunchTimeTag, protonBunchTime);
if(protonBunchTime.isValid())
{
ProditionsHandle<EventTiming> eventTimingHandle;
const EventTiming &eventTiming = eventTimingHandle.get(event.id());
TDC0time = -protonBunchTime->pbtime_ - eventTiming.timeFromProtonsToDRMarker(); //0ns...25ns (only for onspill)
}
}

art::Handle<CrvDigiCollection> crvDigiCollection;
event.getByLabel(_crvDigiModuleLabel,"",crvDigiCollection);
Expand Down
14 changes: 6 additions & 8 deletions CRVResponse/fcl/prolog_v11.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Offline/CommonMC/fcl/prolog.fcl"
BEGIN_PROLOG

DigitizationStart: 400.0 //ns after event window start (i.e. 400ns after first clock tick after POT) --> 400ns...425ns after POT
CrvSteps:
{
module_type : CrvStepsFromStepPointMCs
Expand Down Expand Up @@ -85,17 +86,15 @@ BEGIN_PROLOG
photonYieldVariationCutoffLow :-0.2 //the photon yield variation is cut off at 20% below the mean
photonYieldVariationCutoffHigh : 0.2 //the photon yield variation is cut off at 20% above the mean
//note: if measured deviations are used, the cutoffs should be set to the maximum values
digitizationStart : 400.0 //400ns
digitizationEnd : 1750.0 //1750ns
digitizationStartMargin : 50.0 //50ns
digitizationStart : @local::DigitizationStart
digitizationStartMargin : 50.0 //ns start recording earlier to account for photon travel times and electronics response times
}
CrvSiPMCharges:
{
module_type : CrvSiPMChargeGenerator
crvPhotonsModuleLabel : "CrvPhotons"
digitizationStart : 400.0 //400ns
digitizationEnd : 1750.0 //1750ns
digitizationStartMargin : 50.0 //50ns
digitizationStart : @local::DigitizationStart
digitizationStartMargin : 50.0 //ns start recording earlier to account for electronics response times

nPixelsX : 40
nPixelsY : 40
Expand Down Expand Up @@ -126,8 +125,7 @@ BEGIN_PROLOG
{
module_type : CrvWaveformsGenerator
crvSiPMChargesModuleLabel : "CrvSiPMCharges"
digitizationStart : 400.0 //400ns
digitizationEnd : 1750.0 //1750ns
digitizationStart : @local::DigitizationStart
singlePEWaveformFileName : "Offline/CRVResponse/data/singlePEWaveform_v3.txt"
singlePEWaveformPrecision : 0.5 //0.5 ns
singlePEWaveformStretchFactor: 1.047 //1.047 for singlePEWaveform_v3.txt //from comparison with testbeam data
Expand Down
103 changes: 42 additions & 61 deletions CRVResponse/src/CrvPhotonGenerator_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ namespace mu2e
fhicl::Atom<double> photonYieldVariationScale{ Name("photonYieldVariationScale"),Comment("scale factor of the photon yield variation")};
fhicl::Atom<double> photonYieldVariationCutoffLow{ Name("photonYieldVariationCutoffLow"),Comment("lower cutoff at photon yield variation")};
fhicl::Atom<double> photonYieldVariationCutoffHigh{ Name("photonYieldVariationCutoffHigh"),Comment("upper cutoff at photon yield variation")};
fhicl::Atom<double> digitizationStart{ Name("digitizationStart"), Comment("start of digitization")};
fhicl::Atom<double> digitizationEnd{ Name("digitizationEnd"), Comment("end of digitization")};
fhicl::Atom<double> digitizationStart{ Name("digitizationStart"), Comment("start of digitization after DAQ event window start")};
fhicl::Atom<double> digitizationStartMargin{ Name("digitizationStartMargin"),
Comment("time window before digitization starts to account for photon travel time and electronics response.")};
fhicl::Atom<art::InputTag> eventWindowMarkerTag{ Name("eventWindowMarkerTag"), Comment("EventWindowMarker producer"),"EWMProducer" };
Expand All @@ -82,7 +81,6 @@ namespace mu2e
void beginRun(art::Run& r);

private:

int _debug;
std::vector<std::string> _moduleLabels;
std::vector<std::string> _processNames;
Expand All @@ -102,39 +100,37 @@ namespace mu2e
double _photonYieldVariationCutoffHigh;

//On-spill
//-Event length: 1695ns (microbunch period)
//-Digitization window
//---needs to start about 100ns before the tracker digitization
// to catch cosmic ray muons which may cause signals in the tracker.
//---nominal: 400ns ... 1750ns (in proton time frame)
//---gets adjusted for jitter
//---first DAQ clock tick after POT occurs between 0ns and 25ns after protons.
// 25ns jitter is due to the microbunch period not being an integer multiple of the DAQ clock period.
//---these first DAQ clock ticks define the event window.
// due to the above variations, the event window length varies between 1675ns and 1700ns.
//---digitization start: 400ns after event window start (--> 400ns...425ns after POT)
//---digitization end: at the end of the event window (i.e. first DAQ clock after the next POT),
// which is 1675ns or 1700ns after the event window start
//-CrvSteps
//---start recording CrvSteps 50ns before digitzation window (i.e. at 350ns)
//---start recording CrvSteps 50ns before digitzation window (=350ns after event window start)
// to account for photon travel time and electroncs response time.
//---stop recording CrvSteps at end of digitization window (i.e. at 1750ns).
//---these digitization windows are repeated with the microbunch period (1695ns).
//---therefore, the times when CrvSteps should be recorded are
// 350ns+n*1695ns ... 1750ns+i*1695ns with i being an integer.
//---this gives blind times of 1750ns+(i-1)*1695 ... 350ns+i*1695ns
// where CrvSteps should not be recorded.
//---for simplicity only apply one blind time for i=0: 55ns ... 350ns.
//---stop recording CrvSteps at end of digitization window.
//---CrvSteps before 50ns before the digitization window are removed (dead time).
//---CrvSteps after the end of the event window belong to the next event(s).
// for simplicity, no time wrapping and removal of CrvSteps that occur in the dead time will be done.
//-CrvPhotons
//---photons get time wrapped modulus microbunch period (1695ns).
//---photons before the blind time (digitization end - microbunch period = 55ns)
// get move the to the time interval between the end of the microbunch
// period (1695ns) and the end the of the digitization period (1750ns).
//---all other photons before digitization start will be removed.
//---no further consideration of the digitization window for the photons;
// this will be done at the digitization step.
//
//Off-spill
//-Event length: 100000ns
//-Digitization window
//---full event length
//-CrvSteps
//---start recording CrvSteps 50ns before event window start
// to account for photon travel time.
//---stop recording CrvSteps at event window end.
//---record all CrvSteps within event window
//-CrvPhotons
//---no time wrapping
//---photons outside the event window will be removed.

double _digitizationStart; //400ns
double _digitizationEnd; //1750ns
double _digitizationStart; //400ns after event window start (400ns...425ns after POT)
double _digitizationStartMargin; //50ns (used to account for photon travel time and electronics response time)
art::InputTag _eventWindowMarkerTag;
art::InputTag _protonBunchTimeMCTag;
Expand All @@ -160,7 +156,6 @@ namespace mu2e
_photonYieldVariationCutoffLow(conf().photonYieldVariationCutoffLow()),
_photonYieldVariationCutoffHigh(conf().photonYieldVariationCutoffHigh()),
_digitizationStart(conf().digitizationStart()),
_digitizationEnd(conf().digitizationEnd()),
_digitizationStartMargin(conf().digitizationStartMargin()),
_eventWindowMarkerTag(conf().eventWindowMarkerTag()),
_protonBunchTimeMCTag(conf().protonBunchTimeMCTag()),
Expand Down Expand Up @@ -256,19 +251,25 @@ namespace mu2e
art::Handle<EventWindowMarker> eventWindowMarker;
event.getByLabel(_eventWindowMarkerTag,eventWindowMarker);
EventWindowMarker::SpillType spillType = eventWindowMarker->spillType();
double eventWindowLength = eventWindowMarker->eventLength();

art::Handle<ProtonBunchTimeMC> protonBunchTimeMC;
event.getByLabel(_protonBunchTimeMCTag, protonBunchTimeMC);
double eventWindowStart = -protonBunchTimeMC->pbtime_;
double eventWindowEnd = eventWindowStart + eventWindowLength;
double eventWindowLength = eventWindowMarker->eventLength(); //onspill: 1675ns/1700ns, offspill: 100000ns

ProditionsHandle<EventTiming> eventTimingHandle;
const EventTiming &eventTiming = eventTimingHandle.get(event.id());
double jitter = eventWindowStart - eventTiming.timeFromProtonsToDRMarker();
//offspill
double eventWindowStart=0;
double startTime=0;
double endTime=eventWindowLength;

double digitizationStart=_digitizationStart+jitter;
double digitizationEnd=_digitizationEnd+jitter;
//onspill
if(spillType==EventWindowMarker::SpillType::onspill)
{
art::Handle<ProtonBunchTimeMC> protonBunchTimeMC;
event.getByLabel(_protonBunchTimeMCTag, protonBunchTimeMC);
ProditionsHandle<EventTiming> eventTimingHandle;
const EventTiming &eventTiming = eventTimingHandle.get(event.id());
eventWindowStart = -protonBunchTimeMC->pbtime_ - eventTiming.timeFromProtonsToDRMarker(); //0ns...25ns (only for onspill)

startTime=eventWindowStart+_digitizationStart-_digitizationStartMargin; //350ns...375ns
endTime=eventWindowStart+eventWindowLength; //up to ~1720ns
}

for(size_t j=0; j<_selectors.size(); ++j)
{
Expand All @@ -284,18 +285,8 @@ namespace mu2e
double t2 = step.endTime();
if(isnan(t1) || isnan(t2)) continue; //This situation was observed once. Not sure how it happened.

//see explanation above
//On-spill: Ignore CrvSteps between digitizationEnd-microBunchPeriod (i.e. 1750ns-1695ns=55ns)
// and digitizationStart-digitizationStartMargin (i.e. 400ns-50ns=350ns).
//Off-spill: Ignore CrvSteps outside of eventwindowStart-digitizationStartMargin and eventWindowEnd.
if(spillType==EventWindowMarker::SpillType::onspill)
{
if(t1>digitizationEnd-_microBunchPeriod && t2<digitizationStart-_digitizationStartMargin) continue;
}
else
{
if(t2<eventWindowStart-_digitizationStartMargin || t1>eventWindowEnd) continue;
}
if(t2<startTime) continue;
//for simplicity (due to time wrapping) no other crvSteps will be removed

CLHEP::Hep3Vector pos1 = step.startPosition(); //TODO: Need to convert everything into XYZVec, so that const references can be used
CLHEP::Hep3Vector pos2 = step.endPosition();
Expand Down Expand Up @@ -351,18 +342,8 @@ namespace mu2e
double timeTmp=times[itime];
if(spillType==EventWindowMarker::SpillType::onspill)
{
timeTmp = fmod(timeTmp,_microBunchPeriod);
//photons before the digitization start get removed except photons
//in the first 55ns (digitization end - microbunch period) which get
//moved to the interval between the end of the microbunch period and
//the end of the digitization window.
if(timeTmp<digitizationEnd-_microBunchPeriod) timeTmp+=_microBunchPeriod;
if(timeTmp<digitizationStart-_digitizationStartMargin) continue;
}
else
{
//photons outside the eventWindow get removed
if(timeTmp<eventWindowStart-_digitizationStartMargin || timeTmp>eventWindowEnd) continue;
//time wrap around endTime to avoid breaking pulses apart inside the digi window
timeTmp = fmod(timeTmp-(endTime-_microBunchPeriod),_microBunchPeriod)+(endTime-_microBunchPeriod);
}
photons.emplace_back(timeTmp,crvStepPtr);
}
Expand Down
Loading