28 ntcastors_evt,
ntcastors_trackid,
ntcastors_charge,
ntcastors_pdgcode,
ntcastors_x,
ntcastors_y,
ntcastors_z,
ntcastors_stepl,
ntcastors_stepe,
ntcastors_eta,
ntcastors_phi,
ntcastors_vpx,
ntcastors_vpy,
ntcastors_vpz
32 ntcastore_evt,
ntcastore_ihit,
ntcastore_detector,
ntcastore_sector,
ntcastore_module,
ntcastore_enem,
ntcastore_enhad,
ntcastore_hitenergy,
ntcastore_x,
ntcastore_y,
ntcastore_z
46 std::cout<<
"============================================================================"<<std::endl;
47 std::cout <<
"CastorTestAnalysis:: Initialized as observer"<< std::endl;
48 if (doNTcastorstep > 0){
49 std::cout <<
" Step Ntuple will be created"<< std::endl;
50 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
52 if (doNTcastorevent > 0){
53 std::cout <<
" Event Ntuple will be created"<< std::endl;
54 std::cout <<
" Step Ntuple file: "<<stepNtFileName<<std::endl;
56 std::cout<<
"============================================================================"<<std::endl;
59 if (doNTcastorstep > 0)
60 castorstepntuple =
new TNtuple(
"NTcastorstep",
"NTcastorstep",
"evt:trackid:charge:pdgcode:x:y:z:stepl:stepe:eta:phi:vpx:vpy:vpz");
62 if (doNTcastorevent > 0)
63 castoreventntuple =
new TNtuple(
"NTcastorevent",
"NTcastorevent",
"evt:ihit:detector:sector:module:enem:totalenergy:hitenergy:x:y:z");
71 std::cout << std::endl <<
"End of CastorTestAnalysis"
75 std::cout<<
"CastorTestAnalysis: End of process"<<std::endl;
82 std::cout <<
" Starting new job " << std::endl;
88 std::cout << std::endl <<
"CastorTestAnalysis: Starting Run"<< std::endl;
90 std::cout <<
"CastorTestAnalysis: output step root file created"<< std::endl;
97 std::cout <<
"CastorTestAnalysis: output event root 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();
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();
186 if ( theTrack->GetNextVolume() != 0 )
187 LogDebug(
"ForwardSim") <<
" NextVolume: " << theTrack->GetNextVolume()->GetName() ;
189 LogDebug(
"ForwardSim") <<
" NextVolume: OutOfWorld" ;
202 std::cout << std::endl <<
"CastorTest::update(EndOfEvent * evt) - event #" << (*evt)()->GetEventID() << std::endl;
205 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
206 std::cout <<
"update(*evt) --> accessed all HC";
208 int CAFIid = G4SDManager::GetSDMpointer()->GetCollectionID(
"CastorFI");
237 int particleType = 0;
238 G4PrimaryParticle* thePrim=0;
239 G4int nvertex = (*evt)()->GetNumberOfPrimaryVertex();
240 std::cout <<
"Event has " << nvertex <<
" vertex" << std::endl;
241 if (nvertex==0)
std::cout <<
"CASTORTest End Of Event ERROR: no vertex" << std::endl;
243 for (
int i = 0 ;
i<nvertex;
i++) {
244 G4PrimaryVertex* avertex = (*evt)()->GetPrimaryVertex(
i);
246 std::cout <<
"CASTORTest End Of Event ERR: pointer to vertex = 0" << std::endl;
247 std::cout <<
"Vertex number :" <<
i << std::endl;
248 int npart = avertex->GetNumberOfParticle();
250 std::cout <<
"CASTORTest End Of Event ERR: no primary!" << std::endl;
251 if (thePrim==0) thePrim=avertex->GetPrimary(trackID);
254 double px=0.,py=0.,pz=0., pInit=0;
255 double eta = 0.,
phi = 0.;
258 px = thePrim->GetPx();
259 py = thePrim->GetPy();
260 pz = thePrim->GetPz();
263 std::cout <<
"CASTORTest End Of Event ERR: primary has p=0 " << std::endl;
265 float costheta = pz/pInit;
269 if (px != 0)
phi = atan(py/px);
271 particleType = thePrim->GetPDGcode();
273 std::cout <<
"CASTORTest End Of Event ERR: could not find primary "
276 LogDebug(
"ForwardSim") <<
"CastorTestAnalysis: Particle Type "
277 << particleType <<
" p/eta/phi " << pInit <<
", "
278 << eta <<
", " <<
phi;
281 int iEvt = (*evt)()->GetEventID();
283 std::cout <<
" CastorTest Event " << iEvt << std::endl;
284 else if ((iEvt < 100) && (iEvt%10 == 0))
285 std::cout <<
" CastorTest Event " << iEvt << std::endl;
286 else if ((iEvt < 1000) && (iEvt%100 == 0))
287 std::cout <<
" CastorTest Event " << iEvt << std::endl;
288 else if ((iEvt < 10000) && (iEvt%1000 == 0))
289 std::cout <<
" CastorTest Event " << iEvt << std::endl;
291 std::cout << std::endl <<
"===>>> Done writing user histograms " << std::endl;
299 int nentries = hc->entries();
303 unsigned int volumeID=0;
304 int det=0,
zside, sector, zmodule;
305 std::map<int,float,std::less<int> > themap;
306 double totalEnergy = 0;
307 double hitEnergy = 0;
308 double en_in_sd = 0.;
310 for (
int ihit = 0; ihit < nentries; ihit++) {
315 for (
int ihit = 0; ihit < nentries; ihit++) {
358 std::cout <<
"CastorTestAnalysis: Ntuple step written" <<std::endl;
360 std::cout <<
"CastorTestAnalysis: Step file closed" << std::endl;
366 std::cout <<
"CastorTestAnalysis: Ntuple event written" << std::endl;
368 std::cout <<
"CastorTestAnalysis: Event file closed" << std::endl;
T getParameter(std::string const &) const
math::XYZPoint getPosition() const
Float_t castoreventarray[11]
TNtuple * castoreventntuple
TNtuple * castorstepntuple
Geom::Theta< T > theta() const
static void unpackIndex(const uint32_t &idx, int &z, int §or, int &zmodule)
CastorNumberingScheme * theCastorNumScheme
Tan< T >::type tan(const T &t)
Float_t castorsteparray[14]
virtual ~CastorTestAnalysis()
CastorTestAnalysis(const edm::ParameterSet &p)
std::string stepNtFileName
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
TFile * castorOutputStepFile
void update(const BeginOfJob *run)
This routine will be called when the appropriate signal arrives.
uint32_t getUnitID() const
TFile * castorOutputEventFile
Power< A, B >::type pow(const A &a, const B &b)
void getCastorBranchData(const CaloG4HitCollection *hc)
std::string eventNtFileName
double getEnergyDeposit() const