Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:18:30

0001 #ifndef __TRACKDEADLAYERTAGGING_H__
0002 #define __TRACKDEADLAYERTAGGING_H__
0003 
0004 #include <fun4all/SubsysReco.h>
0005 #include <string>
0006 #include <trackbase_historic/TrackSeedContainer.h>
0007 #include <trackbase_historic/SvtxTrackMap.h>
0008 #include <trackbase/ActsGeometry.h>
0009 #include <globalvertex/SvtxVertexMap.h>
0010 #include <trackbase/TrackVertexCrossingAssoc.h>
0011 #include <trackbase/TrkrClusterContainer.h>
0012 #include <g4detectors/PHG4CylinderGeomContainer.h>
0013 #include <g4detectors/PHG4TpcGeomContainer.h>
0014 #include <trackreco/ActsPropagator.h>
0015 #include <tpc/TpcGlobalPositionWrapper.h>
0016 
0017 //Forward declerations
0018 class PHCompositeNode;
0019 class TFile;
0020 class TTree;
0021 class TNtuple;
0022 
0023 struct MissingSensor
0024 {
0025   int event;
0026   int trackID;
0027   int layer;
0028   int phi_id;
0029   int z_id;
0030   int local_x;
0031   int local_y;
0032   // check if two instances of missing sensor are on the same physical sensor
0033   // (i.e. ignore event and trackID, and ignore zbin/tbin for TPC)
0034   bool isSameSensor(const MissingSensor& othersensor)
0035   {
0036     if(layer!=othersensor.layer) return false;
0037     if(layer<7) // silicon sensor -- needs all spatial coordinates to agree
0038     {
0039       return (layer==othersensor.layer)&&
0040              (phi_id==othersensor.phi_id)&&
0041              (z_id==othersensor.z_id)&&
0042              (local_x==othersensor.local_x)&&
0043              (local_y==othersensor.local_y);
0044     }
0045     else if(layer<55) // TPC sensor -- phibin, side and layer are the only meaningful quantities
0046     {
0047       return (layer==othersensor.layer)&&
0048              (z_id==othersensor.z_id)&&
0049              (local_x==othersensor.local_x);
0050     }
0051     else if(layer<57) // TPOT sensor -- tile ID, strip number and layer are the only meaningful quanitities
0052     {
0053       return (layer==othersensor.layer)&&
0054              (phi_id==othersensor.phi_id)&&
0055              (local_x==othersensor.local_x);
0056     }
0057     else return false; // fall through for control flow reasons
0058   }
0059 };
0060 
0061 struct MissingSpacePoint
0062 {
0063   int layer;
0064   Surface surface;
0065   Acts::Vector2 local_intersection;
0066   Acts::Vector3 global_intersection;
0067 };
0068 
0069 // dNdEta pp analysis module
0070 class TrackDeadLayerTagging: public SubsysReco
0071 {
0072  public: 
0073   //Default constructor
0074   TrackDeadLayerTagging(const std::string &name="TrackDeadLayerTagging");
0075 
0076   //Initialization, called for initialization
0077   int InitRun(PHCompositeNode *);
0078 
0079   //Process Event, called for each event
0080   int process_event(PHCompositeNode *);
0081 
0082   //End, write and close files
0083   int End(PHCompositeNode *);
0084 
0085   //Change output filename
0086   void set_filename(const char* file)
0087   { if(file) _outfile = file; }
0088 
0089   void setUseActsPropagator(bool val) { useActsPropagator = val; }
0090   void setIgnoreSilicon(bool val) { ignoreSilicon = val; }
0091   void setIgnoreTpc(bool val) { ignoreTpc = val; }
0092 
0093  private:
0094   //output filename
0095   std::string _outfile;
0096    
0097   //Event counter
0098   int _event;
0099 
0100   //Branches
0101   int _trackID;
0102   int _layer;
0103   int _phiID;
0104   int _zID;
0105   int _localindX;
0106   int _localindY;
0107   int _isDead;
0108   double _global_x;
0109   double _global_y;
0110   double _global_z;
0111 
0112   // if false, use helix propagation instead of ACTS propagator
0113   bool useActsPropagator = true;
0114   // flags to ignore silicon or TPC missing sensors, if doing seed-specific studies
0115   bool ignoreSilicon = false;
0116   bool ignoreTpc = false;
0117 
0118   TrkrClusterContainer* _clustermap = nullptr;
0119   SvtxTrackMap* _trackmap = nullptr;
0120   SvtxVertexMap* _vertexmap = nullptr;
0121   ActsGeometry* _tGeometry = nullptr;
0122   PHG4CylinderGeomContainer* _inttGeom = nullptr;
0123   PHG4CylinderGeomContainer* _tpotGeom = nullptr;
0124   PHG4TpcGeomContainer* _tpcGeom = nullptr;
0125 
0126   std::array<std::vector<MissingSensor>,57> _dead_sensors; // per layer
0127 
0128   TpcGlobalPositionWrapper tpcglobal;
0129   
0130   TTree* _missing_sensors = nullptr;
0131 
0132   //Get all the nodes
0133   void GetNodes(PHCompositeNode *);
0134 
0135   void get_dead_sensor_maps();
0136   void get_surfaces();
0137   bool is_dead(MissingSensor& sensor);
0138 
0139   std::vector<std::map<Acts::GeometryIdentifier,TrkrDefs::hitsetkey>> _surface_maps;
0140   std::vector<float> getFitParams(TrackSeed* seed);
0141   std::vector<int> get_missing_layers(SvtxTrack* track);
0142   std::vector<MissingSpacePoint> get_missing_space_points(SvtxTrack* track, std::vector<int> missing_layers);
0143   std::vector<MissingSensor> find_sensors(std::vector<MissingSpacePoint> &missing_space_points);
0144 
0145   void find_dead_layers(PHCompositeNode *);
0146 };
0147 
0148 #endif //* __TRACKDEADLAYERTAGGING_H__ *//