diff --git a/src/WCSimEventAction.cc b/src/WCSimEventAction.cc index 9a89a6827..473981a4f 100644 --- a/src/WCSimEventAction.cc +++ b/src/WCSimEventAction.cc @@ -57,7 +57,7 @@ #define NPMTS_VERBOSE 10 #endif //#define DEBUG - +// WCSimEventAction::WCSimEventAction(WCSimRunAction* myRun, WCSimDetectorConstruction* myDetector, WCSimPrimaryGeneratorAction* myGenerator) @@ -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; @@ -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(); @@ -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(); @@ -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(); diff --git a/src/WCSimWCDigitizer.cc b/src/WCSimWCDigitizer.cc index 6d10fedc4..c681e8253 100644 --- a/src/WCSimWCDigitizer.cc +++ b/src/WCSimWCDigitizer.cc @@ -21,10 +21,9 @@ #include #ifndef NPMTS_VERBOSE -#define NPMTS_VERBOSE 10 +#define NPMTS_VERBOSE 50000 #endif - // ******************************************* // BASE CLASS // ******************************************* diff --git a/src/WCSimWCSD.cc b/src/WCSimWCSD.cc index 3c02ba84e..f2889b21e 100644 --- a/src/WCSimWCSD.cc +++ b/src/WCSimWCSD.cc @@ -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 = "<Print(); + } //Added by B. Quilain for the hybrid version G4cout<<"Tube hit list finalized"<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 = "<Print(); + } } /* { diff --git a/src/WCSimWCTrigger.cc b/src/WCSimWCTrigger.cc index 9440237b1..34edec557 100644 --- a/src/WCSimWCTrigger.cc +++ b/src/WCSimWCTrigger.cc @@ -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 @@ -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); @@ -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 digit_times; bool first_loop = true; @@ -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 @@ -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 <