36 std::cout<<
"============================================================================"<<std::endl;
37 std::cout <<
"ZdcTestAnalysis:: Initialized as observer"<< std::endl;
39 std::cout <<
" Step Ntuple will be created"<< std::endl;
40 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
42 if (doNTzdcevent > 0){
43 std::cout <<
" Event Ntuple will be created"<< std::endl;
44 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
46 std::cout<<
"============================================================================"<<std::endl;
51 new TNtuple(
"NTzdcstep",
"NTzdcstep",
52 "evt:trackid:charge:pdgcode:x:y:z:stepl:stepe:eta:phi:vpx:vpy:vpz:idx:idl:pvtype:ncherphot");
56 new TNtuple(
"NTzdcevent",
"NTzdcevent",
57 "evt:ihit:fiberid:zside:subdet:layer:fiber:channel:enem:enhad:hitenergy:x:y:z:time:etot");
66 std::cout << std::endl <<
"ZdcTestAnalysis Dextructor --------> End of ZdcTestAnalysis : "
67 << std::endl << std::endl;
73 std::cout<<
"ZdcTestAnalysis: End of process"<<std::endl;
79 std::cout<<
"beggining of job"<<std::endl;;
87 std::cout << std::endl <<
"ZdcTestAnalysis: Begining of Run"<< std::endl;
89 std::cout <<
"ZDCTestAnalysis: output step file created"<< std::endl;
96 std::cout <<
"ZDCTestAnalysis: output event file created"<< std::endl;
120 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
122 G4double stepL = aStep->GetStepLength();
123 G4double stepE = aStep->GetTotalEnergyDeposit();
126 std::cout <<
"Step " << stepL <<
"," << stepE <<std::endl;
128 G4Track * theTrack = aStep->GetTrack();
129 G4int theTrackID = theTrack->GetTrackID();
130 G4double theCharge = theTrack->GetDynamicParticle()->GetCharge();
131 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
132 G4int pdgcode = theTrack->GetDefinition()->GetPDGEncoding();
134 G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
135 G4double vpx = vert_mom.x();
136 G4double vpy = vert_mom.y();
137 G4double vpz = vert_mom.z();
138 double eta = 0.5 *
log( (1.+vpz) / (1.-vpz) );
139 double phi = atan2(vpy,vpx);
141 G4ThreeVector hitPoint = preStepPoint->GetPosition();
142 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->
143 GetTopTransform().TransformPoint(hitPoint);
145 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
146 int idx = touch->GetReplicaNumber(0);
150 int historyDepth = touch->GetHistoryDepth();
152 if (historyDepth > 0) {
153 std::vector<int> theReplicaNumbers(historyDepth);
154 std::vector<G4VPhysicalVolume*> thePhysicalVolumes(historyDepth);
155 std::vector<G4String> thePVnames(historyDepth);
156 std::vector<G4LogicalVolume*> theLogicalVolumes(historyDepth);
157 std::vector<G4String> theLVnames(historyDepth);
158 std::vector<G4Material*> theMaterials(historyDepth);
159 std::vector<G4String> theMaterialNames(historyDepth);
161 for (
int jj = 0;
jj < historyDepth;
jj++) {
162 theReplicaNumbers[
jj] = touch->GetReplicaNumber(
jj);
163 thePhysicalVolumes[
jj] = touch->GetVolume(
jj);
164 thePVnames[
jj] = thePhysicalVolumes[
jj]->GetName();
165 theLogicalVolumes[
jj] = thePhysicalVolumes[
jj]->GetLogicalVolume();
166 theLVnames[
jj] = theLogicalVolumes[
jj]->GetName();
167 theMaterials[
jj] = theLogicalVolumes[
jj]->GetMaterial();
168 theMaterialNames[
jj] = theMaterials[
jj]->GetName();
170 std::cout <<
" GHD " <<
jj <<
": " << theReplicaNumbers[
jj] <<
","
171 << thePVnames[
jj] <<
"," << theLVnames[
jj] <<
","
172 << theMaterialNames[
jj] << std::endl;
175 idLayer = theReplicaNumbers[1];
176 if (thePVnames[0] ==
"ZDC_EMLayer")
178 else if (thePVnames[0] ==
"ZDC_EMAbsorber")
180 else if (thePVnames[0] ==
"ZDC_EMFiber")
182 else if (thePVnames[0] ==
"ZDC_HadLayer")
184 else if (thePVnames[0] ==
"ZDC_HadAbsorber")
186 else if (thePVnames[0] ==
"ZDC_HadFiber")
188 else if (thePVnames[0] ==
"ZDC_PhobosLayer")
190 else if (thePVnames[0] ==
"ZDC_PhobosAbsorber")
192 else if (thePVnames[0] ==
"ZDC_PhobosFiber")
197 std::cout <<
" pvtype=0 hd=" << historyDepth <<
" " << theReplicaNumbers[0] <<
","
198 << thePVnames[0] <<
"," << theLVnames[0] <<
"," << theMaterialNames[0] << std::endl;
201 else if (historyDepth == 0) {
202 int theReplicaNumber = touch->GetReplicaNumber(0);
203 G4VPhysicalVolume* thePhysicalVolume = touch->GetVolume(0);
204 G4String thePVname = thePhysicalVolume->GetName();
205 G4LogicalVolume * theLogicalVolume = thePhysicalVolume->GetLogicalVolume();
206 G4String theLVname = theLogicalVolume->GetName();
207 G4Material * theMaterial = theLogicalVolume->GetMaterial();
208 G4String theMaterialName = theMaterial->GetName();
210 std::cout <<
" hd=0 " << theReplicaNumber <<
","
211 << thePVname <<
"," << theLVname <<
","
212 << theMaterialName << std::endl;
215 std::cout <<
" hd<0: hd=" << historyDepth << std::endl;
219 double NCherPhot = -1;
247 std::cout << std::endl <<
"ZdcTest::upDate(const EndOfEvent * evt) - event #" << (*evt)()->GetEventID()
248 << std::endl <<
" # of aSteps followed in event = " <<
stepIndex << std::endl;
251 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
254 int theZDCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(
"ZDCHITS");
255 std::cout <<
" - theZDCHCid = " << theZDCHCid;
258 std::cout <<
" - theZDCHC = " << theZDCHC << std::endl;
262 float ETot=0., SEnergy=0.;
265 unsigned int unsignedfiberID=0;
266 std::map<int,float,std::less<int> > energyInFibers;
267 std::map<int,float,std::less<int> > primaries;
268 float totalEnergy = 0;
269 int nentries = theZDCHC->entries();
270 std::cout <<
" theZDCHC has " << nentries <<
" entries" << std::endl;
274 for (
int ihit = 0; ihit < nentries; ihit++) {
279 for (
int ihit = 0; ihit < nentries; ihit++) {
283 double enEm = aHit->
getEM();
284 double enHad = aHit->
getHadr();
288 std::cout <<
" entry #" << ihit <<
": fiberID=0x" << std::hex
289 << fiberID <<
std::dec <<
"; enEm=" << enEm
290 <<
"; enHad=" << enHad <<
"; hitEnergy=" << hitEnergy
291 <<
"z=" << hitPoint.z() << std::endl;
292 energyInFibers[fiberID]+= enEm + enHad;
295 if (time > maxTime) maxTime=(int)time;
297 int thesubdet, thelayer, thefiber, thechannel, thez;
298 theZdcNumScheme->
unpackZdcIndex(fiberID, thesubdet, thelayer, thefiber, thechannel, thez);
299 int unsignedsubdet, unsignedlayer, unsignedfiber, unsignedchannel, unsignedz;
301 unsignedlayer, unsignedfiber, unsignedchannel, unsignedz);
327 for (std::map<
int,
float,std::less<int> >::iterator is = energyInFibers.begin();
328 is!= energyInFibers.end(); is++)
336 G4PrimaryParticle* thePrim=0;
337 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
338 std::cout <<
"Event has " << nvertex <<
" vertex" << std::endl;
340 std::cout <<
"ZdcTest End Of Event ERROR: no vertex" << std::endl;
342 for (
int i = 0 ;
i<nvertex;
i++) {
344 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
346 std::cout <<
"ZdcTest End Of Event ERR: pointer to vertex = 0"
349 std::cout <<
"Vertex number :" <<
i << std::endl;
350 int npart = avertex->GetNumberOfParticle();
352 std::cout <<
"ZdcTest End Of Event ERR: no primary!" << std::endl;
353 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
357 double px=0.,py=0.,pz=0.;
361 px = thePrim->GetPx();
362 py = thePrim->GetPy();
363 pz = thePrim->GetPz();
366 std::cout <<
"ZdcTest End Of Event ERR: primary has p=0 " << std::endl;
369 std::cout <<
"ZdcTest End Of Event ERR: could not find primary "
378 int iEvt = (*evt)()->GetEventID();
380 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
381 else if ((iEvt < 100) && (iEvt%10 == 0))
382 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
383 else if ((iEvt < 1000) && (iEvt%100 == 0))
384 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
385 else if ((iEvt < 10000) && (iEvt%1000 == 0))
386 std::cout <<
" ZdcTest Event " << iEvt << std::endl;
397 std::cout <<
"ZdcTestAnalysis: Step file closed" << std::endl;
406 std::cout <<
"ZdcTestAnalysis: Event file closed" << std::endl;
T getParameter(std::string const &) const
math::XYZPoint getPosition() const
Float_t zdceventarray[16]
TFile * zdcOutputEventFile
virtual ~ZdcTestAnalysis()
std::string stepNtFileName
TFile * zdcOutputStepFile
void update(const BeginOfJob *run)
This routine will be called when the appropriate signal arrives.
ZdcTestAnalysis(const edm::ParameterSet &p)
XYZPointD XYZPoint
point in space with cartesian internal representation
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
static void unpackZdcIndex(const unsigned int &idx, int &subDet, int &layer, int &fiber, int &channel, int &z)
int getTimeSliceID() const
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
std::string eventNtFileName
uint32_t getUnitID() const
Power< A, B >::type pow(const A &a, const B &b)
double getEnergyDeposit() const