Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2026-07-16 08:10:35

0001 // Tell emacs that this is a C++ source
0002 //  -*- C++ -*-.
0003 #ifndef DISPLAYEVENTS_H
0004 #define DISPLAYEVENTS_H
0005 
0006 #include <fun4all/SubsysReco.h>
0007 
0008 #include <trackbase/ActsGeometry.h>
0009 #include <calotrigger/TriggerAnalyzer.h>
0010 #include <calotrigger/TriggerRunInfo.h>
0011 #include <ffarawobjects/Gl1Packet.h>
0012 #include <globalvertex/SvtxVertex.h>
0013 #include <globalvertex/SvtxVertexMap.h>
0014 #include <trackbase/TrkrCluster.h>           // for TrkrCluster
0015 #include <trackbase/TrkrClusterContainer.h>
0016 #include <trackbase_historic/SvtxTrack.h>
0017 #include <trackbase_historic/SvtxTrackMap.h>
0018 
0019 //calo stuff
0020 #include <calobase/RawClusterDefs.h>
0021 #include <calobase/RawCluster.h>
0022 #include <calobase/RawClusterContainer.h>
0023 #include <calobase/RawClusterUtility.h>
0024 #include <calobase/RawTowerContainer.h>
0025 #include <calobase/RawTowerGeom.h>
0026 #include <calobase/RawTowerGeomContainer.h>
0027 #include <calobase/TowerInfo.h>
0028 #include <calobase/TowerInfoContainer.h>
0029 #include <calobase/TowerInfoDefs.h>
0030 
0031 #include <nlohmann/json.hpp>
0032 
0033 #include <string>
0034 #include <fstream>
0035 
0036 using json = nlohmann::json;
0037 
0038 class PHCompositeNode;
0039 class SvtxTrackMap;
0040 class SvtxTrack;
0041 class SvtxVertexMap;
0042 class SvtxVertex;
0043 class TriggerAnalyzer;
0044 
0045 //calo stuff
0046 class RawCluster;
0047 class RawClusterContainer;
0048 class RawTower;
0049 class RawTowerContainer;
0050 class RawTowerGeomContainer;
0051 
0052 class displayEvents : public SubsysReco
0053 {
0054  public:
0055 
0056   displayEvents(const std::string &name = "displayEvents");
0057 
0058   ~displayEvents() override;
0059 
0060   int Init(PHCompositeNode *topNode) override;
0061 
0062   int process_event(PHCompositeNode *topNode) override;
0063 
0064   int End(PHCompositeNode *topNode) override;
0065 
0066   void setEventDisplayPath(std::string path) { m_evt_display_path = path; }
0067 
0068   void setMaxEvtDisplays(int max = 10) { m_max_displays = max; }
0069 
0070   void setDecayTag(std::string tag) { m_decay_tag = tag; }
0071 
0072   void useTheseBCOs(std::vector<uint64_t> bcoList) { m_bco_list = bcoList; }
0073 
0074   void plotsApproved(bool approved = true) { m_approved = approved; }
0075 
0076   void addCaloInfo(bool add = true) { loadCalos = add; }
0077 
0078   void dontShowTrackClusters(bool avoid = true) { m_dont_show_track_clus = avoid; }
0079 
0080  private:
0081   int counter = 0;
0082   int m_runNumber = 0;
0083   std::string m_evt_display_path = "./";
0084   std::string m_run_date = "2024-04-14";
0085   std::string m_decay_tag = "200 GeV p+p";
0086   std::vector<uint64_t> m_bco_list;
0087   int m_max_displays = 100;
0088   bool m_approved = false;
0089   bool loadCalos = false;
0090   bool m_dont_show_track_clus = false;
0091 
0092   int load_nodes(PHCompositeNode *topNode);
0093   std::string getParticleName(int ID);
0094   SvtxTrack *getTrack(unsigned int track_id, SvtxTrackMap *trackmap);
0095   void getJSONdata(std::vector<SvtxTrack*> tracks, json &data);
0096   std::string getDate();
0097   bool isInRange(float min, float value, float max);
0098 
0099   ActsGeometry *geometry {nullptr};
0100   SvtxTrack *m_track {nullptr};
0101   SvtxTrackMap *m_trackMap {nullptr};
0102   SvtxTrackMap *m_kfp_trackMap {nullptr};
0103   SvtxVertexMap *m_vertexMap {nullptr};
0104   SvtxVertex *m_vertex {nullptr};
0105   Gl1Packet *gl1packet {nullptr};
0106   TriggerAnalyzer *triggeranalyzer {nullptr};
0107   TriggerRunInfo *triggerruninfo {nullptr};
0108   TrkrClusterContainer *dst_clustermap {nullptr};
0109 
0110   std::vector<SvtxTrack*> all_tracks;
0111 
0112   std::ofstream json_output;
0113 
0114   std::string eventName = "EVENT";
0115   std::string metadataName = "META";
0116   std::string allTrackName = "ALL";
0117   std::string trackName = "TRACKS";
0118   std::string hitsName = "HITS";
0119   std::vector<std::string> hitsNameVector = {allTrackName};
0120 
0121   int yellow = 16252672;
0122   int orange = 16743424;
0123   int green = 1834752;
0124   int turquoise = 4251856;
0125   int blue = 12031;
0126   int red = 16711680;
0127   int pink = 16070058;
0128   int white = 16446450;
0129 
0130   long emcalColor = 16766464;
0131   long ihcalColor = 4290445312;
0132   long ohcalColor = 24773;
0133 
0134   int allColour = white;
0135 
0136   std::map<std::string, int> pidToColourMap{
0137   {allTrackName, allColour}};
0138 
0139   //calo stuff
0140   void getJSONcalo(json &jsonData, std::string calo, TowerInfoContainer *towerCont, RawTowerGeomContainer *geom);
0141   json caloMetadata(std::string type);
0142   TowerInfoContainer *towersEM{nullptr};
0143   RawTowerGeomContainer *geomEMCal{nullptr};
0144   TowerInfoContainer *towersIH{nullptr};
0145   RawTowerGeomContainer *geoIHCal{nullptr};
0146   TowerInfoContainer *towersOH{nullptr};
0147   RawTowerGeomContainer *geoOHCal{nullptr};
0148 
0149   bool hasEMCal = true;
0150   bool hasIHCal = true;
0151   bool hasOHCal = true;
0152 
0153   std::string emcalName = "EMCal";
0154   std::string ihcalName = "IHCal";
0155   std::string ohcalName = "OHCal";
0156 
0157   std::map<std::string, float> caloThreshold{
0158     {emcalName, 0.08},
0159     {ihcalName, 0.01},
0160     {ohcalName, 0.04}};
0161     //{emcalName, 0.12},
0162     //{ihcalName, 0.01},
0163     //{ohcalName, 0.04}};
0164 };
0165 
0166 #endif // DISPLAYEVENTS_H