Skip to content

Commit

Permalink
Mainly corrected WCSimWCTrigger to speed up the code. All hits after …
Browse files Browse the repository at this point in the history
…the long time window (now 2 ms) are not used. Such late hits could happen especially if a photon is blocked in a region for a long time, doing lots of reflection but not disappearing. It happened often in the mPMT geometry, but it is a general feature. Now, no hit after the Long Time Window are considered for the trigger.
  • Loading branch information
bquilain committed Jan 21, 2021
1 parent 34305b0 commit cdf89c7
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 11 deletions.
29 changes: 28 additions & 1 deletion src/WCSimEventAction.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
#define NPMTS_VERBOSE 10
#endif
//#define DEBUG

//
WCSimEventAction::WCSimEventAction(WCSimRunAction* myRun,
WCSimDetectorConstruction* myDetector,
WCSimPrimaryGeneratorAction* myGenerator)
Expand Down Expand Up @@ -239,16 +239,24 @@ void WCSimEventAction::EndOfEventAction(const G4Event* evt)
G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
WCSimWCHitsCollection* WCHC = 0;
G4String WCIDCollectionName = detectorConstructor->GetIDCollectionName();
#ifdef DEBUG
G4cout << "Load the first PMT type hits" << G4endl;
#endif
if (HCE)
{
G4String name = WCIDCollectionName;
G4int collectionID = SDman->GetCollectionID(name);
WCHC = (WCSimWCHitsCollection*)HCE->GetHC(collectionID);
}

//B.Q for the hybrid version
WCSimWCHitsCollection* WCHC2 = 0;
G4String WCIDCollectionName2;
if(detectorConstructor->GetHybridPMT()) WCIDCollectionName2 = detectorConstructor->GetIDCollectionName2();
#ifdef DEBUG
G4cout << "Load the second PMT type hits" << G4endl;
#endif

if (HCE)
{
G4String name;
Expand Down Expand Up @@ -353,6 +361,9 @@ void WCSimEventAction::EndOfEventAction(const G4Event* evt)
ms->Start();
#endif

#ifdef DEBUG
G4cout << "Convert separated hits in one PMT to a single hit for first PMT type" << std::endl;
#endif
//Convert the hits to PMT pulse
WCDMPMT->SetRelativeDigitizedHitTime(RelativeHitTime);
WCDMPMT->Digitize();
Expand All @@ -370,6 +381,10 @@ void WCSimEventAction::EndOfEventAction(const G4Event* evt)

//WCDNM->SetDarkMode(1);

#ifdef DEBUG
G4cout << "Add Dark Hits first PMT" << std::endl;
#endif

//Add the dark noise
WCDNM->AddDarkNoise();

Expand All @@ -380,23 +395,35 @@ void WCSimEventAction::EndOfEventAction(const G4Event* evt)
WCSimWCDigitizerBase* WCDM =
(WCSimWCDigitizerBase*)DMman->FindDigitizerModule("WCReadoutDigits");

#ifdef DEBUG
G4cout << "Digitize hits first PMT" << std::endl;
#endif
//Digitize the hits
WCDM->Digitize();

//
// Finally, apply the trigger

#ifdef DEBUG
G4cout << "Trigger for first PMT type" << std::endl;
#endif
//Get a pointer to the WC Trigger Module
WCSimWCTriggerBase* WCTM =
(WCSimWCTriggerBase*)DMman->FindDigitizerModule("WCReadout");

//tell it the dark noise rate (for calculating the average dark occupancy -> can adjust the NDigits threshold)
WCTM->SetDarkRate(WCDNM->GetDarkRate());
#ifdef DEBUG
G4cout << "B.Q" << std::endl;
#endif

//Apply the trigger
// This takes the digits, and places them into trigger gates
// Also throws away digits not contained in an trigger gate
WCTM->Digitize();
#ifdef DEBUG
G4cout << "Trigger for first PMT type is over" << std::endl;
#endif

#ifdef TIME_DAQ_STEPS
ms->Stop();
Expand Down
3 changes: 1 addition & 2 deletions src/WCSimWCDigitizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
#include <cstring>

#ifndef NPMTS_VERBOSE
#define NPMTS_VERBOSE 10
#define NPMTS_VERBOSE 50000
#endif


// *******************************************
// BASE CLASS
// *******************************************
Expand Down
8 changes: 6 additions & 2 deletions src/WCSimWCSD.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ void WCSimWCSD::EndOfEvent(G4HCofThisEvent* HCE)
G4int numHits = hitsCollection->entries();

G4cout << "There are " << numHits << " tubes hit in the WC: " << G4endl;
for (G4int i=0; i < numHits; i++)
for (G4int i=0; i < numHits; i++) {
G4cout<<"ihit ID = "<<i<<std::endl;
(*hitsCollection)[i]->Print();
}

//Added by B. Quilain for the hybrid version
G4cout<<"Tube hit list finalized"<<G4endl;
Expand All @@ -278,8 +280,10 @@ void WCSimWCSD::EndOfEvent(G4HCofThisEvent* HCE)
G4int numHits2 = hitsCollection2->entries();

G4cout << "There are " << numHits2 << " tubes hit in the WC: " << G4endl;
for (G4int i=0; i < numHits2; i++)
for (G4int i=0; i < numHits2; i++){
G4cout<<"ihit ID = "<<i<<std::endl;
(*hitsCollection2)[i]->Print();
}
}
/*
{
Expand Down
31 changes: 25 additions & 6 deletions src/WCSimWCTrigger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#ifndef WCSIMWCTRIGGER_VERBOSE
//#define WCSIMWCTRIGGER_VERBOSE
#endif

//#define DEBUG
const double WCSimWCTriggerBase::offset = 950.0; // ns. apply offset to the digit time
const double WCSimWCTriggerBase::LongTime = 2E6; // ns = 2ms. event time

Expand Down Expand Up @@ -187,6 +187,9 @@ void WCSimWCTriggerBase::Digitize()
WCSimWCDigitsCollection* WCDCPMT =
(WCSimWCDigitsCollection*)(DigiMan->GetDigiCollection(WCDCID));

#ifdef DEBUG
G4cout << "Do the trigger work" << G4endl;
#endif
// Do the work
if (WCDCPMT) {
DoTheWork(WCDCPMT);
Expand All @@ -211,9 +214,9 @@ void WCSimWCTriggerBase::AlgNDigits(WCSimWCDigitsCollection* WCDCPMT, bool remov
//loop over PMTs, and Digits in each PMT. If ndigits > Threshhold in a time window, then we have a trigger

int ntrig = 0;
int window_start_time = 0;
int window_end_time = WCSimWCTriggerBase::LongTime - ndigitsWindow;
int window_step_size = 5; //step the search window along this amount if no trigger is found
double window_start_time = 0;
double window_end_time = WCSimWCTriggerBase::LongTime - ndigitsWindow;
double window_step_size = 5.; //step the search window along this amount if no trigger is found
double lasthit;
std::vector<G4double> digit_times;
bool first_loop = true;
Expand Down Expand Up @@ -247,8 +250,16 @@ void WCSimWCTriggerBase::AlgNDigits(WCSimWCDigitsCollection* WCDCPMT, bool remov
}
//G4cout << digit_time << G4endl;
//get the time of the last hit (to make the loop shorter)
if(first_loop && (digit_time > lasthit))
lasthit = digit_time;
if(first_loop && (digit_time > lasthit)){
//Added by B.Q to avoid hits generated very late (e.g. because G4 photon is blocked somewhere and suddently escape very late):
if(digit_time < WCSimWCTriggerBase::LongTime){
lasthit = digit_time;
}
//
#ifdef DEBUG
G4cout << "Tube = " << (*WCDCPMT)[i]->GetTubeID() << ", Last hit = "<< i << ", number of p.e. = " << ip << ", timing = " << digit_time << G4endl;
#endif
}
}//loop over Digits
}//loop over PMTs

Expand Down Expand Up @@ -288,9 +299,14 @@ void WCSimWCTriggerBase::AlgNDigits(WCSimWCDigitsCollection* WCDCPMT, bool remov
<< " to " << lasthit - (ndigitsWindow - 10)
<< G4endl;
#endif
//double new_end_time = lasthit - (ndigitsWindow - 10);
window_end_time = lasthit - (ndigitsWindow - 10);
//
first_loop = false;
}
#ifdef DEBUG
G4cout << "Window start time = " << window_start_time << " end time = "<< window_end_time <<G4endl;
#endif
}

#ifdef WCSIMWCTRIGGER_VERBOSE
Expand Down Expand Up @@ -549,6 +565,9 @@ WCSimWCTriggerNDigits::~WCSimWCTriggerNDigits()
}

void WCSimWCTriggerNDigits::DoTheWork(WCSimWCDigitsCollection* WCDCPMT) {
#ifdef DEBUG
G4cout << "In do the trigger work, will launch Alg NDigitis" << G4endl;
#endif
//Apply an NDigits trigger
bool remove_hits = false;
AlgNDigits(WCDCPMT, remove_hits);
Expand Down

0 comments on commit cdf89c7

Please sign in to comment.