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5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /readout/src/G4DigiManager.cc (Version 11.3.0) and /readout/src/G4DigiManager.cc (Version 11.1.3)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 //                                                 26 //
 27 //                                                 27 //
 28                                                    28 
 29 #include "G4DigiManager.hh"                        29 #include "G4DigiManager.hh"
 30 #include "G4Event.hh"                              30 #include "G4Event.hh"
 31 #include "G4VHitsCollection.hh"                    31 #include "G4VHitsCollection.hh"
 32 #include "G4VDigiCollection.hh"                    32 #include "G4VDigiCollection.hh"
 33 #include "G4DMmessenger.hh"                        33 #include "G4DMmessenger.hh"
 34 #include "G4DCofThisEvent.hh"                      34 #include "G4DCofThisEvent.hh"
 35 #include "G4RunManager.hh"                         35 #include "G4RunManager.hh"
 36 #include "G4SDManager.hh"                          36 #include "G4SDManager.hh"
 37 #include "G4ios.hh"                                37 #include "G4ios.hh"
 38                                                    38 
 39                                                    39 
 40 G4ThreadLocal G4DigiManager* G4DigiManager::fD     40 G4ThreadLocal G4DigiManager* G4DigiManager::fDManager = 0;
 41                                                    41 
 42 G4DigiManager* G4DigiManager::GetDMpointer()       42 G4DigiManager* G4DigiManager::GetDMpointer()
 43 {                                                  43 {
 44   if(!fDManager)                                   44   if(!fDManager)
 45   {                                                45   {
 46     fDManager = new G4DigiManager;                 46     fDManager = new G4DigiManager;
 47   }                                                47   }
 48   return fDManager;                                48   return fDManager;
 49 }                                                  49 }
 50                                                    50 
 51 G4DigiManager* G4DigiManager::GetDMpointerIfEx     51 G4DigiManager* G4DigiManager::GetDMpointerIfExist()
 52 { return fDManager; }                              52 { return fDManager; }
 53                                                    53 
 54 G4DigiManager::G4DigiManager():verboseLevel(0)     54 G4DigiManager::G4DigiManager():verboseLevel(0)
 55 {                                                  55 { 
 56   theMessenger = new G4DMmessenger(this);          56   theMessenger = new G4DMmessenger(this); 
 57   runManager = G4RunManager::GetRunManager();      57   runManager = G4RunManager::GetRunManager();
 58   SDManager = G4SDManager::GetSDMpointer();        58   SDManager = G4SDManager::GetSDMpointer();
 59   DCtable = new G4DCtable;                         59   DCtable = new G4DCtable;
 60 }                                                  60 }
 61                                                    61 
 62 G4DigiManager::~G4DigiManager()                    62 G4DigiManager::~G4DigiManager()
 63 {                                                  63 {
 64   //DMtable.clearAndDestroy();                     64   //DMtable.clearAndDestroy();
 65   for(G4int i=0;i<G4int(DMtable.size());++i)   <<  65   for(G4int i=0;i<int(DMtable.size());i++)
 66   { delete DMtable[i]; }                           66   { delete DMtable[i]; }
 67   DMtable.clear();                                 67   DMtable.clear();
 68   delete DCtable;                                  68   delete DCtable;
 69   delete theMessenger;                             69   delete theMessenger;
 70 }                                                  70 }
 71                                                    71 
 72 void G4DigiManager::AddNewModule(G4VDigitizerM     72 void G4DigiManager::AddNewModule(G4VDigitizerModule* DM)
 73 {                                                  73 {
 74   G4String DMname = DM->GetName();                 74   G4String DMname = DM->GetName();
 75   for(G4int j=0;j<G4int(DMtable.size());++j)   <<  75   for(int j=0;j<int(DMtable.size());j++)
 76   {                                                76   {
 77     if(DMtable[j]==DM)                             77     if(DMtable[j]==DM)
 78     {                                              78     { 
 79       G4cout << "<" << DMname << "> has alread     79       G4cout << "<" << DMname << "> has already been registered." << G4endl; 
 80       return;                                      80       return;
 81     }                                              81     }
 82   }                                                82   }
 83   if( verboseLevel > 0 )                           83   if( verboseLevel > 0 )
 84   {                                                84   {
 85     G4cout << "New DigitizerModule <" << DMnam     85     G4cout << "New DigitizerModule <" << DMname
 86          << "> is registered." << G4endl;          86          << "> is registered." << G4endl;
 87   }                                                87   }
 88   DMtable.push_back(DM);                           88   DMtable.push_back(DM);
 89                                                    89 
 90   G4int numberOfCollections = DM->GetNumberOfC     90   G4int numberOfCollections = DM->GetNumberOfCollections();
 91   for(G4int i=0;i<numberOfCollections;++i)     <<  91   for(int i=0;i<numberOfCollections;i++)
 92   {                                                92   {
 93     G4String DCname = DM->GetCollectionName(i)     93     G4String DCname = DM->GetCollectionName(i);
 94     if( DCtable->Registor(DMname,DCname) < 0 )     94     if( DCtable->Registor(DMname,DCname) < 0 )
 95     {                                              95     { 
 96       G4cout << "DigiCollection <" << DCname       96       G4cout << "DigiCollection <" << DCname 
 97            << "> has already been registered w     97            << "> has already been registered with "
 98            << DMname << " DigitizerModule." <<     98            << DMname << " DigitizerModule." << G4endl;
 99     }                                              99     }
100     else if( verboseLevel > 0 )                   100     else if( verboseLevel > 0 )
101     {                                             101     {
102       G4cout << "DigiCollection " << DCname       102       G4cout << "DigiCollection " << DCname 
103            << " is registered. " << G4endl;       103            << " is registered. " << G4endl;
104     }                                             104     }
105   }                                               105   }
106                                                   106   
107   runManager->SetDCtable(DCtable);                107   runManager->SetDCtable(DCtable);
108 }                                                 108 }
109                                                   109 
110 void G4DigiManager::Digitize(const G4String& m << 110 void G4DigiManager::Digitize(G4String mName)
111 {                                                 111 {
112   G4VDigitizerModule* aDM = FindDigitizerModul    112   G4VDigitizerModule* aDM = FindDigitizerModule(mName);
113   if(aDM)                                         113   if(aDM)
114   { aDM->Digitize(); }                            114   { aDM->Digitize(); }
115   else                                            115   else
116   { G4cout << "Unknown digitizer module <" <<     116   { G4cout << "Unknown digitizer module <" << mName << ">. Digitize() ignored." << G4endl; }
117 }                                                 117 }
118                                                   118 
119 G4VDigitizerModule* G4DigiManager::FindDigitiz << 119 G4VDigitizerModule* G4DigiManager::FindDigitizerModule(G4String mName)
120 {                                                 120 {
121   for(G4int i=0;i<G4int(DMtable.size());++i)   << 121   for(G4int i=0;i<int(DMtable.size());i++)
122   {                                               122   {
123     if(DMtable[i]->GetName() == mName) return     123     if(DMtable[i]->GetName() == mName) return DMtable[i];
124   }                                               124   }
125   return NULL;                                    125   return NULL;
126 }                                                 126 }
127                                                   127 
128 const G4VHitsCollection* G4DigiManager::GetHit    128 const G4VHitsCollection* G4DigiManager::GetHitsCollection(G4int HCID,G4int eventID)
129 {                                                 129 {
130   const G4Event* evt = NULL;                      130   const G4Event* evt = NULL;
131   if(eventID==0)                                  131   if(eventID==0)
132   { evt = runManager->GetCurrentEvent(); }        132   { evt = runManager->GetCurrentEvent(); }
133   else                                            133   else
134   { evt = runManager->GetPreviousEvent(eventID    134   { evt = runManager->GetPreviousEvent(eventID); }
135   if(evt==NULL) return NULL;                      135   if(evt==NULL) return NULL;
136                                                   136   
137   G4HCofThisEvent* HCE = evt->GetHCofThisEvent    137   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
138   if(HCE==NULL) return NULL;                      138   if(HCE==NULL) return NULL;
139                                                   139 
140   return HCE->GetHC(HCID);                        140   return HCE->GetHC(HCID);
141 }                                                 141 }
142                                                   142 
143 const G4VDigiCollection* G4DigiManager::GetDig    143 const G4VDigiCollection* G4DigiManager::GetDigiCollection(G4int DCID,G4int eventID)
144 {                                                 144 {
145   const G4Event* evt = NULL;                      145   const G4Event* evt = NULL;
146   if(eventID==0)                                  146   if(eventID==0)
147   { evt = runManager->GetCurrentEvent(); }        147   { evt = runManager->GetCurrentEvent(); }
148   else                                            148   else
149   { evt = runManager->GetPreviousEvent(eventID    149   { evt = runManager->GetPreviousEvent(eventID); }
150   if(evt==NULL) return NULL;                      150   if(evt==NULL) return NULL;
151                                                   151   
152   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    152   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
153   if(DCE==NULL) return NULL;                      153   if(DCE==NULL) return NULL;
154                                                   154 
155   return DCE->GetDC(DCID);                        155   return DCE->GetDC(DCID);
156 }                                                 156 }
157                                                   157 
158 G4int G4DigiManager::GetHitsCollectionID(const << 158 G4int G4DigiManager::GetHitsCollectionID(G4String HCname)
159 {                                                 159 {
160   return SDManager->GetCollectionID(HCname);      160   return SDManager->GetCollectionID(HCname);
161 }                                                 161 }
162                                                   162 
163 G4int G4DigiManager::GetDigiCollectionID(const << 163 G4int G4DigiManager::GetDigiCollectionID(G4String DCname)
164 {                                                 164 {
165   G4int i = DCtable->GetCollectionID(DCname);     165   G4int i = DCtable->GetCollectionID(DCname);
166   if(i==-2)                                       166   if(i==-2)
167   { G4cout << "< " << DCname << "> is ambegiou    167   { G4cout << "< " << DCname << "> is ambegious." << G4endl; }
168   return i;                                       168   return i;
169 }                                                 169 }
170                                                   170 
171 void G4DigiManager::SetDigiCollection(G4int DC    171 void G4DigiManager::SetDigiCollection(G4int DCID,G4VDigiCollection* aDC)
172 {                                                 172 {
173   const G4Event* consEvt = runManager->GetCurr    173   const G4Event* consEvt = runManager->GetCurrentEvent();
174   if(consEvt==NULL)                               174   if(consEvt==NULL) 
175   {                                               175   {
176     G4cout << "G4DigiManager::SetDigiCollectio    176     G4cout << "G4DigiManager::SetDigiCollection --- "
177          << "Event object is not available." <    177          << "Event object is not available." << G4endl;
178     return;                                       178     return;
179   }                                               179   }
180                                                   180   
181   G4Event* evt = (G4Event*)consEvt;               181   G4Event* evt = (G4Event*)consEvt;
182   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    182   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
183   if(DCE==NULL)                                   183   if(DCE==NULL)
184   {                                               184   {
185     DCE = new G4DCofThisEvent(DCtable->entries    185     DCE = new G4DCofThisEvent(DCtable->entries());
186     evt->SetDCofThisEvent(DCE);                   186     evt->SetDCofThisEvent(DCE);
187     if(verboseLevel>0)                            187     if(verboseLevel>0)
188     { G4cout << "DCofThisEvent object is added    188     { G4cout << "DCofThisEvent object is added to current G4Event." << G4endl; }
189   }                                               189   }
190                                                   190 
191   DCE->AddDigiCollection(DCID,aDC);               191   DCE->AddDigiCollection(DCID,aDC);
192                                                   192 
193   if(verboseLevel>0)                              193   if(verboseLevel>0)
194   {                                               194   {
195     G4cout << aDC->GetName() << " is stored at    195     G4cout << aDC->GetName() << " is stored at " << DCID 
196          << "-th slot of G4DCofThisEvent." <<     196          << "-th slot of G4DCofThisEvent." << G4endl;
197   }                                               197   }
198 }                                                 198 }
199                                                   199   
200 void G4DigiManager::SetVerboseLevel(G4int val)    200 void G4DigiManager::SetVerboseLevel(G4int val)
201 {                                                 201 {
202   verboseLevel = val;                             202   verboseLevel = val;
203   for(G4int i=0;i<G4int(DMtable.size());++i)   << 203   for(G4int i=0;i<int(DMtable.size());i++)
204   { DMtable[i]->SetVerboseLevel(val); }           204   { DMtable[i]->SetVerboseLevel(val); }
205 }                                                 205 }
206                                                   206 
207 void G4DigiManager::List() const                  207 void G4DigiManager::List() const
208 {                                                 208 {
209   for(G4int i=0;i<G4int(DMtable.size());++i)   << 209   for(G4int i=0;i<int(DMtable.size());i++)
210   { G4cout << "   " << i << " : " << DMtable[i    210   { G4cout << "   " << i << " : " << DMtable[i]->GetName() << G4endl; }
211 }                                                 211 }
212                                                   212 
213                                                   213 
214                                                   214 
215                                                   215