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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 8.1.p2)


  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 // $Id: G4DigiManager.cc,v 1.7 2006/06/29 21:13:04 gunter Exp $
                                                   >>  28 // GEANT4 tag $Name: geant4-08-01-patch-01 $
 27 //                                                 29 //
 28                                                    30 
 29 #include "G4DigiManager.hh"                        31 #include "G4DigiManager.hh"
 30 #include "G4Event.hh"                              32 #include "G4Event.hh"
 31 #include "G4VHitsCollection.hh"                    33 #include "G4VHitsCollection.hh"
 32 #include "G4VDigiCollection.hh"                    34 #include "G4VDigiCollection.hh"
 33 #include "G4DMmessenger.hh"                        35 #include "G4DMmessenger.hh"
 34 #include "G4DCofThisEvent.hh"                      36 #include "G4DCofThisEvent.hh"
 35 #include "G4RunManager.hh"                         37 #include "G4RunManager.hh"
 36 #include "G4SDManager.hh"                          38 #include "G4SDManager.hh"
 37 #include "G4ios.hh"                                39 #include "G4ios.hh"
 38                                                    40 
 39                                                    41 
 40 G4ThreadLocal G4DigiManager* G4DigiManager::fD <<  42 G4DigiManager* G4DigiManager::fDManager = 0;
 41                                                    43 
 42 G4DigiManager* G4DigiManager::GetDMpointer()       44 G4DigiManager* G4DigiManager::GetDMpointer()
 43 {                                                  45 {
 44   if(!fDManager)                                   46   if(!fDManager)
 45   {                                                47   {
 46     fDManager = new G4DigiManager;                 48     fDManager = new G4DigiManager;
 47   }                                                49   }
 48   return fDManager;                                50   return fDManager;
 49 }                                                  51 }
 50                                                    52 
 51 G4DigiManager* G4DigiManager::GetDMpointerIfEx     53 G4DigiManager* G4DigiManager::GetDMpointerIfExist()
 52 { return fDManager; }                              54 { return fDManager; }
 53                                                    55 
 54 G4DigiManager::G4DigiManager():verboseLevel(0)     56 G4DigiManager::G4DigiManager():verboseLevel(0)
 55 {                                                  57 { 
 56   theMessenger = new G4DMmessenger(this);          58   theMessenger = new G4DMmessenger(this); 
 57   runManager = G4RunManager::GetRunManager();      59   runManager = G4RunManager::GetRunManager();
 58   SDManager = G4SDManager::GetSDMpointer();        60   SDManager = G4SDManager::GetSDMpointer();
 59   DCtable = new G4DCtable;                         61   DCtable = new G4DCtable;
 60 }                                                  62 }
 61                                                    63 
 62 G4DigiManager::~G4DigiManager()                    64 G4DigiManager::~G4DigiManager()
 63 {                                                  65 {
 64   //DMtable.clearAndDestroy();                     66   //DMtable.clearAndDestroy();
 65   for(G4int i=0;i<G4int(DMtable.size());++i)   <<  67   for(G4int i=0;i<int(DMtable.size());i++)
 66   { delete DMtable[i]; }                           68   { delete DMtable[i]; }
 67   DMtable.clear();                                 69   DMtable.clear();
 68   delete DCtable;                                  70   delete DCtable;
 69   delete theMessenger;                             71   delete theMessenger;
 70 }                                                  72 }
 71                                                    73 
 72 void G4DigiManager::AddNewModule(G4VDigitizerM     74 void G4DigiManager::AddNewModule(G4VDigitizerModule* DM)
 73 {                                                  75 {
 74   G4String DMname = DM->GetName();                 76   G4String DMname = DM->GetName();
 75   for(G4int j=0;j<G4int(DMtable.size());++j)   <<  77   for(int j=0;j<int(DMtable.size());j++)
 76   {                                                78   {
 77     if(DMtable[j]==DM)                             79     if(DMtable[j]==DM)
 78     {                                              80     { 
 79       G4cout << "<" << DMname << "> has alread <<  81       G4cout << "<" << DMname << "> has already been registored." << G4endl; 
 80       return;                                      82       return;
 81     }                                              83     }
 82   }                                                84   }
 83   if( verboseLevel > 0 )                           85   if( verboseLevel > 0 )
 84   {                                                86   {
 85     G4cout << "New DigitizerModule <" << DMnam     87     G4cout << "New DigitizerModule <" << DMname
 86          << "> is registered." << G4endl;      <<  88          << "> is registored." << G4endl;
 87   }                                                89   }
 88   DMtable.push_back(DM);                           90   DMtable.push_back(DM);
 89                                                    91 
 90   G4int numberOfCollections = DM->GetNumberOfC     92   G4int numberOfCollections = DM->GetNumberOfCollections();
 91   for(G4int i=0;i<numberOfCollections;++i)     <<  93   for(int i=0;i<numberOfCollections;i++)
 92   {                                                94   {
 93     G4String DCname = DM->GetCollectionName(i)     95     G4String DCname = DM->GetCollectionName(i);
 94     if( DCtable->Registor(DMname,DCname) < 0 )     96     if( DCtable->Registor(DMname,DCname) < 0 )
 95     {                                              97     { 
 96       G4cout << "DigiCollection <" << DCname       98       G4cout << "DigiCollection <" << DCname 
 97            << "> has already been registered w <<  99            << "> has already been registored with "
 98            << DMname << " DigitizerModule." <<    100            << DMname << " DigitizerModule." << G4endl;
 99     }                                             101     }
100     else if( verboseLevel > 0 )                   102     else if( verboseLevel > 0 )
101     {                                             103     {
102       G4cout << "DigiCollection " << DCname       104       G4cout << "DigiCollection " << DCname 
103            << " is registered. " << G4endl;    << 105            << " is registored. " << G4endl;
104     }                                             106     }
105   }                                               107   }
106                                                   108   
107   runManager->SetDCtable(DCtable);                109   runManager->SetDCtable(DCtable);
108 }                                                 110 }
109                                                   111 
110 void G4DigiManager::Digitize(const G4String& m << 112 void G4DigiManager::Digitize(G4String mName)
111 {                                                 113 {
112   G4VDigitizerModule* aDM = FindDigitizerModul    114   G4VDigitizerModule* aDM = FindDigitizerModule(mName);
113   if(aDM)                                         115   if(aDM)
114   { aDM->Digitize(); }                            116   { aDM->Digitize(); }
115   else                                            117   else
116   { G4cout << "Unknown digitizer module <" <<     118   { G4cout << "Unknown digitizer module <" << mName << ">. Digitize() ignored." << G4endl; }
117 }                                                 119 }
118                                                   120 
119 G4VDigitizerModule* G4DigiManager::FindDigitiz << 121 G4VDigitizerModule* G4DigiManager::FindDigitizerModule(G4String mName)
120 {                                                 122 {
121   for(G4int i=0;i<G4int(DMtable.size());++i)   << 123   for(G4int i=0;i<int(DMtable.size());i++)
122   {                                               124   {
123     if(DMtable[i]->GetName() == mName) return     125     if(DMtable[i]->GetName() == mName) return DMtable[i];
124   }                                               126   }
125   return NULL;                                    127   return NULL;
126 }                                                 128 }
127                                                   129 
128 const G4VHitsCollection* G4DigiManager::GetHit    130 const G4VHitsCollection* G4DigiManager::GetHitsCollection(G4int HCID,G4int eventID)
129 {                                                 131 {
130   const G4Event* evt = NULL;                      132   const G4Event* evt = NULL;
131   if(eventID==0)                                  133   if(eventID==0)
132   { evt = runManager->GetCurrentEvent(); }        134   { evt = runManager->GetCurrentEvent(); }
133   else                                            135   else
134   { evt = runManager->GetPreviousEvent(eventID    136   { evt = runManager->GetPreviousEvent(eventID); }
135   if(evt==NULL) return NULL;                      137   if(evt==NULL) return NULL;
136                                                   138   
137   G4HCofThisEvent* HCE = evt->GetHCofThisEvent    139   G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
138   if(HCE==NULL) return NULL;                      140   if(HCE==NULL) return NULL;
139                                                   141 
140   return HCE->GetHC(HCID);                        142   return HCE->GetHC(HCID);
141 }                                                 143 }
142                                                   144 
143 const G4VDigiCollection* G4DigiManager::GetDig    145 const G4VDigiCollection* G4DigiManager::GetDigiCollection(G4int DCID,G4int eventID)
144 {                                                 146 {
145   const G4Event* evt = NULL;                      147   const G4Event* evt = NULL;
146   if(eventID==0)                                  148   if(eventID==0)
147   { evt = runManager->GetCurrentEvent(); }        149   { evt = runManager->GetCurrentEvent(); }
148   else                                            150   else
149   { evt = runManager->GetPreviousEvent(eventID    151   { evt = runManager->GetPreviousEvent(eventID); }
150   if(evt==NULL) return NULL;                      152   if(evt==NULL) return NULL;
151                                                   153   
152   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    154   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
153   if(DCE==NULL) return NULL;                      155   if(DCE==NULL) return NULL;
154                                                   156 
155   return DCE->GetDC(DCID);                        157   return DCE->GetDC(DCID);
156 }                                                 158 }
157                                                   159 
158 G4int G4DigiManager::GetHitsCollectionID(const << 160 G4int G4DigiManager::GetHitsCollectionID(G4String HCname)
159 {                                                 161 {
160   return SDManager->GetCollectionID(HCname);      162   return SDManager->GetCollectionID(HCname);
161 }                                                 163 }
162                                                   164 
163 G4int G4DigiManager::GetDigiCollectionID(const << 165 G4int G4DigiManager::GetDigiCollectionID(G4String DCname)
164 {                                                 166 {
165   G4int i = DCtable->GetCollectionID(DCname);     167   G4int i = DCtable->GetCollectionID(DCname);
166   if(i==-2)                                       168   if(i==-2)
167   { G4cout << "< " << DCname << "> is ambegiou    169   { G4cout << "< " << DCname << "> is ambegious." << G4endl; }
168   return i;                                       170   return i;
169 }                                                 171 }
170                                                   172 
171 void G4DigiManager::SetDigiCollection(G4int DC    173 void G4DigiManager::SetDigiCollection(G4int DCID,G4VDigiCollection* aDC)
172 {                                                 174 {
173   const G4Event* consEvt = runManager->GetCurr    175   const G4Event* consEvt = runManager->GetCurrentEvent();
174   if(consEvt==NULL)                               176   if(consEvt==NULL) 
175   {                                               177   {
176     G4cout << "G4DigiManager::SetDigiCollectio    178     G4cout << "G4DigiManager::SetDigiCollection --- "
177          << "Event object is not available." <    179          << "Event object is not available." << G4endl;
178     return;                                       180     return;
179   }                                               181   }
180                                                   182   
181   G4Event* evt = (G4Event*)consEvt;               183   G4Event* evt = (G4Event*)consEvt;
182   G4DCofThisEvent* DCE = evt->GetDCofThisEvent    184   G4DCofThisEvent* DCE = evt->GetDCofThisEvent();
183   if(DCE==NULL)                                   185   if(DCE==NULL)
184   {                                               186   {
185     DCE = new G4DCofThisEvent(DCtable->entries    187     DCE = new G4DCofThisEvent(DCtable->entries());
186     evt->SetDCofThisEvent(DCE);                   188     evt->SetDCofThisEvent(DCE);
187     if(verboseLevel>0)                            189     if(verboseLevel>0)
188     { G4cout << "DCofThisEvent object is added    190     { G4cout << "DCofThisEvent object is added to current G4Event." << G4endl; }
189   }                                               191   }
190                                                   192 
191   DCE->AddDigiCollection(DCID,aDC);               193   DCE->AddDigiCollection(DCID,aDC);
192                                                   194 
193   if(verboseLevel>0)                              195   if(verboseLevel>0)
194   {                                               196   {
195     G4cout << aDC->GetName() << " is stored at    197     G4cout << aDC->GetName() << " is stored at " << DCID 
196          << "-th slot of G4DCofThisEvent." <<     198          << "-th slot of G4DCofThisEvent." << G4endl;
197   }                                               199   }
198 }                                                 200 }
199                                                   201   
200 void G4DigiManager::SetVerboseLevel(G4int val)    202 void G4DigiManager::SetVerboseLevel(G4int val)
201 {                                                 203 {
202   verboseLevel = val;                             204   verboseLevel = val;
203   for(G4int i=0;i<G4int(DMtable.size());++i)   << 205   for(G4int i=0;i<int(DMtable.size());i++)
204   { DMtable[i]->SetVerboseLevel(val); }           206   { DMtable[i]->SetVerboseLevel(val); }
205 }                                                 207 }
206                                                   208 
207 void G4DigiManager::List() const                  209 void G4DigiManager::List() const
208 {                                                 210 {
209   for(G4int i=0;i<G4int(DMtable.size());++i)   << 211   for(G4int i=0;i<int(DMtable.size());i++)
210   { G4cout << "   " << i << " : " << DMtable[i    212   { G4cout << "   " << i << " : " << DMtable[i]->GetName() << G4endl; }
211 }                                                 213 }
212                                                   214 
213                                                   215 
214                                                   216 
215                                                   217