2 #include "G4EventManager.hh"
3 #include "G4DigiManager.hh"
10 #define NPMTS_VERBOSE -1
12 #define VERBOSE_PMT -1
14 #ifndef HYPER_VERBOSITY
26 G4String detectorElement)
27 :G4VDigitizerModule(name), myDetector(inDetector), DAQMessenger(myMessenger), DigitizerType(digitype),DigitizerClassName(
""), detectorElement(detectorElement)
31 if(detectorElement==
"tank") colName =
"WCDigitizedStoreCollection";
32 else if(detectorElement==
"OD") colName =
"WCDigitizedStoreCollection_OD";
33 collectionName.push_back(colName);
36 #ifdef HYPER_VERBOSITY
37 if(detectorElement==
"OD")G4cout<<
"WCSimWCDigitizerBase::WCSimWCDigitizerBase ☆ recording collection name "<<colName<<
" for "<<detectorElement<<G4endl;
41 G4cerr <<
"WCSimWCDAQMessenger pointer is NULL when passed to WCSimWCDigitizerBase constructor. Exiting..."
64 G4cerr <<
"WCSimWCDAQMessenger pointer is NULL when used in WCSimWCDigitizerBase::GetVariables(). Exiting..."
86 G4DigiManager* DigiMan = G4DigiManager::GetDMpointer();
91 G4String rawcollectionName;
92 if(
detectorElement==
"tank") rawcollectionName =
"WCRawPMTSignalCollection";
93 else if(
detectorElement==
"OD") rawcollectionName =
"WCRawPMTSignalCollection_OD";
94 G4int WCHCID = DigiMan->GetDigiCollectionID(rawcollectionName);
100 #ifdef HYPER_VERBOSITY
102 G4cout <<
"WCSimWCDigitizerBase::Digitize ☆ making digits collection (WCSimWCDigitsCollection*)"<<collectionName[0]
103 <<
" for "<<
detectorElement<<
" and calling DigitizeHits on "<<rawcollectionName<<
" to fill it"<<G4endl;}
109 G4cout <<
"WCSimWCDigitizerBase::Digitize didn't find hit collection for " <<
detectorElement << G4endl;
125 #ifdef WCSIMWCDIGITIZER_VERBOSE
127 G4cout<<
"Adding hit "<<gate<<
" in tube "<<tube
128 <<
" with time " << digihittime_d <<
" charge " << peSmeared_d
129 <<
" (truncated from t: " << digihittime <<
" q: " << peSmeared <<
")"
130 <<
" (made of " << digi_comp.size() <<
" raw hits with IDs ";
131 for(
unsigned int iv = 0; iv < digi_comp.size(); iv++)
132 G4cout <<
" " << digi_comp[iv] <<
",";
138 if (peSmeared > 0.0) {
142 Digi->
SetPe(gate,peSmeared_d);
143 Digi->
AddPe(digihittime_d);
144 Digi->
SetTime(gate,digihittime_d);
147 #ifdef WCSIMWCDIGITIZER_VERBOSE
149 G4cout <<
" NEW HIT" << G4endl;
156 (*DigiStore)[
DigiStoreHitMap[tube]-1]->AddDigiCompositionInfo(digi_comp);
157 #ifdef WCSIMWCDIGITIZER_VERBOSE
159 G4cout <<
" DEJA VU" << G4endl;
165 #ifdef WCSIMWCDIGITIZER_VERBOSE
167 G4cout <<
"DIGIT REJECTED with charge " << peSmeared_d
168 <<
" time " << digihittime_d << G4endl;
191 G4String detectorElement)
205 G4cout <<
"WCSimWCDigitizerSKI::DigitizeHits START WCHCPMT->entries() = " << WCHCPMT->entries() << G4endl;
217 for (G4int i = 0 ; i < WCHCPMT->entries() ; i++)
222 (*WCHCPMT)[i]->SortArrayByHitTime();
223 int tube = (*WCHCPMT)[i]->GetTubeID();
224 #ifdef WCSIMWCDIGITIZER_VERBOSE
226 G4cout <<
"tube " << tube
227 <<
" totalpe = " << (*WCHCPMT)[i]->GetTotalPe()
229 for(
int ip = 0; ip < (*WCHCPMT)[i]->GetTotalPe(); ip++)
230 G4cout <<
" " << (*WCHCPMT)[i]->GetTime(ip);
246 double intgr_start=0;
248 G4double efficiency = 0.985;
251 int digi_unique_id = 0;
252 int photon_unique_id = 0;
253 std::vector<int> digi_comp;
256 for( G4int ip = 0 ; ip < (*WCHCPMT)[i]->GetTotalPe() ; ip++)
258 double time = (*WCHCPMT)[i]->GetTime(ip);
259 double pe = (*WCHCPMT)[i]->GetPe(ip);
270 #ifdef WCSIMWCDIGITIZER_VERBOSE
272 G4cout <<
"ip " << ip
275 <<
" intgr_start " << intgr_start
276 <<
" upperlimit " << upperlimit
280 bool MakeDigit =
false;
281 if(time >= intgr_start && time <= upperlimit) {
283 photon_unique_id = ip;
284 digi_comp.push_back(photon_unique_id);
286 #ifdef WCSIMWCDIGITIZER_VERBOSE
288 G4cout<<
"INFO: time "<<time<<
" digi_id "<<digi_unique_id<<
" p_id "<<photon_unique_id<<G4endl;
291 if(ip + 1 == (*WCHCPMT)[i]->GetTotalPe()){
297 else if(digi_comp.size()) {
321 assert(digi_comp.size());
326 #ifdef WCSIMWCDIGITIZER_VERBOSE
328 G4cout <<
"DIGIT REJECTED with time " << intgr_start << G4endl;
341 #ifdef WCSIMWCDIGITIZER_VERBOSE
343 G4cout<<
"*** PREPARING FOR >1 DIGI ***"<<G4endl;
352 photon_unique_id = ip;
353 digi_comp.push_back(photon_unique_id);
357 if(ip+1 == (*WCHCPMT)[i]->GetTotalPe()) {
371 assert(digi_comp.size());
376 #ifdef WCSIMWCDIGITIZER_VERBOSE
378 G4cout <<
"DIGIT REJECTED with time " << intgr_start << G4endl;
386 G4cout<<
"WCSimWCDigitizerSKI::DigitizeHits END DigiStore->entries() " <<
DigiStore->entries() <<
"\n";
388 #ifdef WCSIMWCDIGITIZER_VERBOSE
389 G4cout<<
"\n\n\nCHECK DIGI COMP:"<<G4endl;
390 for (G4int idigi = 0 ; idigi <
DigiStore->entries() ; idigi++){
391 int tubeid = (*DigiStore)[idigi]->GetTubeID();
393 std::map< int, std::vector<int> > comp = (*DigiStore)[idigi]->GetDigiCompositionInfo();
394 for(
size_t i = 0; i < comp.size(); i++){
395 G4cout <<
"tube " << tubeid
396 <<
" gate " << i <<
" p_id";
397 for(
size_t iv = 0; iv < comp[i].size(); iv++) {
398 G4cout <<
" " << comp[i][iv];
WCSimDetectorConstruction * myDetector
Get the geometry information.
WCSimWCDAQMessenger * DAQMessenger
Get the /DAQ/ .mac options.
double DigitizerPEPrecision
Digitizer charge precision (p.e.)
double Truncate(double value, double precision)
Override the default digitizer charge resolution (p.e.)
void SetDigitizerIntegrationWindow(int iDigitizerIntegrationWindow)
virtual double GetDefaultPEPrecision()=0
Set the default digitizer-specific charge resolution (in p.e.) (overridden by .mac) ...
void SetDigitizerTimingPrecision(double iDigitizerTimingPrecision)
static void Threshold(double &pe, int &iflag)
void SetDigitizerOptions()
void SetTubeID(G4int tube)
WCSimWCDigitizerBase(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, DigitizerType_t, G4String detectorElement)
WCSimPMTObject * GetPMTPointer(G4String CollectionName)
virtual int GetDefaultIntegrationWindow()=0
Set the default digitizer-specific integration window (in ns) (overridden by .mac) ...
bool AddNewDigit(int tube, int gate, double digihittime, double peSmeared, std::vector< int > digi_comp)
void SetPe(G4int gate, G4double Q)
WCSimWCDigitsCollection * DigiStore
G4TDigiCollection< WCSimWCDigi > WCSimWCDigitsCollection
G4String GetIDCollectionName()
void SetDigitizerDeadTime(int iDigitizerDeadTime)
enum EDigitizerType DigitizerType_t
virtual double GetDefaultTimingPrecision()=0
Set the default digitizer-specific timing resolution (in ns) (overridden by .mac) ...
void AddDigiCompositionInfo(std::vector< int > &digi_comp)
double DigitizerTimingPrecision
Digitizer time precision (ns)
virtual int GetDefaultDeadTime()=0
Set the default digitizer-specific deadtime (in ns) (overridden by .mac)
std::map< int, int > DigiStoreHitMap
Used to check if a digit has already been created on a PMT.
virtual double HitTimeSmearing(double)=0
int DigitizerIntegrationWindow
Digitizer integration window (ns)
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
Save current values of options.
int DigitizerDeadTime
Digitizer deadtime (ns)
void GetVariables()
Get the default deadtime, etc. from the derived class, and override with read from the ...
int tubeid[MAX_N_ACTIVE_TUBES]
virtual ~WCSimWCDigitizerBase()
void SetDigitizerClassName(string iDigitizerClassName)
void AddPe(G4double hitTime)
void SetDigitizerPEPrecision(double iDigitizerPEPrecision)
void SetTime(G4int gate, G4double T)
G4String DigitizerClassName
Name of the digitizer class being run.
virtual void DigitizeHits(WCSimWCDigitsCollection *WCHCPMT)=0
WCSimWCDigitizerSKI(G4String name, WCSimDetectorConstruction *, WCSimWCDAQMessenger *, G4String detectorElement)
void TellMeAboutTheDigitizer(WCSimWCDigitizerBase *digitizer)
void DigitizeHits(WCSimWCDigitsCollection *WCHCPMT)