5 #include "art_root_io/TFileService.h" 6 #include "art_root_io/TFileDirectory.h" 8 #include "canvas/Persistency/Common/FindManyP.h" 48 #include "TDirectory.h" 57 #include "TGraphErrors.h" 60 #include "TTimeStamp.h" 66 #include "TTimeStamp.h" 70 #include "TPaveStats.h" 165 fHitsModuleLabel (pset.
get<
std::
string >(
"HitsModuleLabel",
"") ),
166 fTrackModuleLabel (pset.
get<
std::
string >(
"TrackModuleLabel",
"") ),
167 fCalorimetryModuleLabel (pset.
get<
std::
string >(
"CalorimetryModuleLabel",
"") ),
168 fSaveCaloInfo (pset.
get<
bool>(
"SaveCaloInfo",false)),
169 fSaveTrackInfo (pset.
get<
bool>(
"SaveTrackInfo",false))
183 pdg_beamparticles=tfs->make<TH1F>(
"beam_pdg",
"beam particle pdgs;pdg;no of beam particles",6000,-2999.5,3000.5);
184 calibration_constants=tfs->make<TH1F>(
"calibration_constants",
"calibration constants;calibration constants;no of hits",6000,0.003000,0.009000);
185 electric_field_YZ=tfs->make<TH2F>(
"EField_YZ_x_0",
"Electric field for YZ plane at x= -300cm;Z coordinate;Y coordinate",139,0,695,120,0,600);
186 electric_field_YZ_3=tfs->make<TH2F>(
"EField_YZ_x_3",
"Electric field for YZ plane at x= -25cm;Z coordinate;Y coordinate",139,0,695,120,0,600);
187 EFieldX=tfs->make<TH1F>(
"EFieldX",
"Electric Field for Y=300cm && Z=350cm;X coordinate;Efield in kV/cm",120,-360,360);
188 EField3DX=tfs->make<TH3F>(
"EField3DX",
"Electric FieldX 3D",144,-360,360,120,0,600,139,0,695);
192 fEventTree = tfs->make<TTree>(
"Event",
"Event Tree from Reco");
267 std::vector<art::Ptr<recob::Track> > tracklist;
271 std::vector<art::Ptr<recob::Hit>> hitlist;
302 auto const* SCE = lar::providerFrom<spacecharge::SpaceChargeService>();
305 std::cout<<detProp.Temperature()<<
endl;
306 std::cout<<
"drift velocity "<<detProp.DriftVelocity(0.50,87.0)<<
std::endl;
307 double efield=detProp.Efield();
310 for(
int i=0;i<120;i++){
311 double xcord=-360+i*6;
313 double Ef=efield+efield*fEfieldOffsets.X();
314 EFieldX->SetBinContent(i+1, Ef);
317 for(
int i=0;i<144;i++){
318 for(
int j=0;j<120;j++){
319 for(
int k=0;
k<139;
k++){
320 double x1=i*5.0-357.5;
324 double EfX=efield+efield*fEfieldOffsets.X();
334 double EField1=efield;
336 for(
int i=0;i<139;i++){
338 for(
int j=0;j<120;j++){
341 EField1 = std::sqrt((efield + efield*fEfieldOffsets.X())*(efield + efield*fEfieldOffsets.X())+(efield*fEfieldOffsets.Y())*(efield*fEfieldOffsets.Y())+(efield*fEfieldOffsets.Z())*(efield*fEfieldOffsets.Z()));
346 for(
int i=0;i<139;i++){
348 for(
int j=0;j<120;j++){
351 EField1 = std::sqrt((efield + efield*fEfieldOffsets.X())*(efield + efield*fEfieldOffsets.X())+(efield*fEfieldOffsets.Y()*efield*fEfieldOffsets.Y())+(efield*fEfieldOffsets.Z()*efield*fEfieldOffsets.Z()));
357 size_t NTracks = tracklist.size();
358 for(
size_t i=0; i<NTracks;++i){
360 std::vector<art::Ptr<anab::Calorimetry>> calos=fmcal.at(i);
367 double theta_xz = std::atan2(dir_start.X(), dir_start.Z());
368 double theta_yz = std::atan2(dir_start.Y(), dir_start.Z());
374 std::vector<art::Ptr<recob::Hit>> allHits=fmtht.at(i);
378 std::map<int,double> trkide;
379 std::map<int,double> trknumelec;
380 std::vector<float> hitpeakT;
382 for(
size_t h1=0;
h1<allHits.size();
h1++){
383 hitpeakT.push_back(allHits[
h1]->PeakTime());
387 min=*min_element(hitpeakT.begin(),hitpeakT.end());
388 max=*max_element(hitpeakT.begin(),hitpeakT.end());
391 for(
size_t h=0;
h<allHits.size();
h++){
393 std::vector<sim::TrackIDE> eveIDs = bt_serv->
HitToTrackIDEs(clockData, hit);
394 for(
size_t e=0;
e<eveIDs.size(); ++
e){
395 trkide[eveIDs[
e].trackID] += eveIDs[
e].energy;
403 if((ii->second)>maxe){
411 float total_energy=0.0;
412 for(
size_t h=0;
h<allHits.size();
h++){
415 std::vector<sim::TrackIDE> eveIDs = bt_serv->
HitToTrackIDEs(clockData, hit);
416 for(
size_t e=0;
e<eveIDs.size(); ++
e){
417 if (eveIDs[
e].trackID == trackid) total_energy += eveIDs[
e].energy;
425 if(!particle)
continue;
427 int origin_type=mc->
Origin();
431 if(particle->
Process()==
"primary" && origin_type==4){
436 if(!(pdg1==2212 && (particle->
Process()==
"primary") && origin_type==4))
continue;
438 for(
size_t h=0;
h<allHits.size();
h++){
440 std::vector<const sim::IDE*> eventIDs = bt_serv->
HitToSimIDEs_Ps(clockData, hit);
442 int number_electrons=0;
445 for(
size_t e=0;
e<eventIDs.size(); ++
e){
448 number_electrons+=eventIDs[
e]->numElectrons;
503 for(
size_t ical = 0; ical<calos.size(); ++ical){
504 if(!calos[ical])
continue;
505 if(!calos[ical]->
PlaneID().isValid)
continue;
506 int planenum = calos[ical]->PlaneID().Plane;
507 if(planenum<0||planenum>2)
continue;
508 const size_t NHits = calos[ical] ->
dEdx().size();
510 for(
size_t iHit = 0; iHit < NHits; ++iHit){
511 const auto& TrkPos = (calos[ical] -> XYZ())[iHit];
521 Efield[
beam_proton-1][planenum][iHit]=sqrt((efield + efield*fEfieldOffsets.X())*(efield + efield*fEfieldOffsets.X())+(efield*fEfieldOffsets.Y())*(efield*fEfieldOffsets.Y())+(efield*fEfieldOffsets.Z())*(efield*fEfieldOffsets.Z()));
580 for(
int j=0; j<3; j++){
581 for(
int k=0;
k<3000;
k++){
def analyze(root, level, gtrees, gbranches, doprint)
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
Double_t Total_energy[kMaxTracks]
constexpr std::uint32_t timeLow() const
TH1F * calibration_constants
const TLorentzVector & EndPosition() const
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
Float_t trackthetayz[kMaxTracks]
Float_t EndPointx[kMaxTracks]
Float_t trkendcosxyz[kMaxTracks][3]
Handle< PROD > getHandle(SelectorBase const &) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
const simb::MCParticle * TrackIdToParticle_P(int id) const
geo::WireID WireID() const
Float_t trkendx[kMaxTracks]
void beginRun(const art::Run &run)
Int_t TrackId_geant[kMaxTracks]
Float_t trkendy[kMaxTracks]
constexpr std::uint32_t timeHigh() const
Float_t StartPointy[kMaxTracks]
simb::Origin_t Origin() const
Float_t peakT_min[kMaxTracks]
Float_t trkstartcosxyz[kMaxTracks][3]
Vector_t VertexDirection() const
Float_t trkhitz[kMaxTracks][3][3000]
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
Int_t pdg_all_beam[kMaxTracks]
Float_t StartPointz[kMaxTracks]
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Vector_t
Type for representation of momenta in 3D space.
Float_t EndPointx_corrected[kMaxTracks]
std::string Process() const
virtual ~protonanalysis()
void analyze(const art::Event &evt)
object containing MC flux information
art framework interface to geometry description
Float_t peakT_max[kMaxTracks]
QTextStream & reset(QTextStream &s)
Float_t Efield[kMaxTracks][3][3000]
double dEdx(float dqdx, float Efield)
double Length(size_t p=0) const
Access to various track properties.
#define DEFINE_ART_MODULE(klass)
std::string fHitsModuleLabel
Double_t momentum[kMaxTracks]
Float_t trkstarty[kMaxTracks]
const art::Ptr< simb::MCTruth > & TrackIdToMCTruth_P(int id) const
Float_t trkdqdx[kMaxTracks][3][3000]
Point_t const & Vertex() const
Float_t EndPointz[kMaxTracks]
Float_t trkpitch[kMaxTracks][3][3000]
SubRunNumber_t subRun() const
TH2F * electric_field_YZ_3
Float_t StartPointx[kMaxTracks]
Float_t trkendz[kMaxTracks]
static int max(int a, int b)
PlaneID_t Plane
Index of the plane within its TPC.
Definition of data types for geometry description.
Detector simulation of raw signals on wires.
Float_t EndPointy_corrected[kMaxTracks]
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Float_t trkresrange[kMaxTracks][3][3000]
double Vx(const int i=0) const
Float_t trkstartx[kMaxTracks]
Declaration of signal hit object.
Double_t EndE[kMaxTracks]
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
std::string fTrackModuleLabel
Vector_t EndDirection() const
const TLorentzVector & Momentum(const int i=0) const
Provides recob::Track data product.
Float_t EndPointy[kMaxTracks]
double Vz(const int i=0) const
EventNumber_t event() const
Point_t const & End() const
Declaration of basic channel signal object.
detail::Node< FrameID, bool > PlaneID
Float_t trackthetaxz[kMaxTracks]
Float_t EndPointz_corrected[kMaxTracks]
std::vector< const sim::IDE * > HitToSimIDEs_Ps(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
Float_t trkhitx[kMaxTracks][3][3000]
Float_t trkdedx[kMaxTracks][3][3000]
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Float_t trklen[kMaxTracks]
def momentum(x1, x2, x3, scale=1.)
Float_t trkstartz[kMaxTracks]
Float_t trkhity[kMaxTracks][3][3000]
Int_t ntrkhits[kMaxTracks][3]
double Vy(const int i=0) const
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
constexpr Point origin()
Returns a origin position with a point of the specified type.
std::string fCalorimetryModuleLabel
QTextStream & endl(QTextStream &s)
Event finding and building.
Float_t xprojectedlen[kMaxTracks]