# ml4sci/cms architecture

> Architecture diagram of the GitHub repository ml4sci/cms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ml4sci/cms
- Repository: https://github.com/ml4sci/cms

## Overview

##### Main Components

a. Data Processing Pipeline
- Frame Producers (Input Layer)
- Various Taggers (Processing Layer)
- TensorFlow Models (Inference Layer)

b. Core Components
- Data Formats Module
- Frame Producers
- Multiple Specialized Taggers:
- EG Tagger
- QG Tagger
- Tau Tagger
- Top Tagger

##### System Architecture Representation

**[Data Input Layer]**
- ↓
**[Frame Processing Layer]**
- ↓
**[Tagger Layer]**
- ↓
**[Model Inference Layer]**
- ↓
**[Output Layer]**

##### Specific Elements

a. Data Flow Components:
- Input data sources
- Frame Collections
- Detector data streams

b. Processing Components:
- DetFrameProducer
- EGFrameProducer
- JetFrameProducer
- Frame Cropping/Striding utilities

c. ML Components:
- TensorFlow model integration
- ResNet models (show different channel versions)
- Inference paths

d. Tagger Components:
- EG, QG, Tau, and Top taggers
- Their respective configurations
- Inference paths

##### Key Architectural Elements to Highlight

- The modular nature of the taggers
- The shared frame production infrastructure
- The ML model integration points
- The configuration system
- The build system integration (BuildFile.xml locations)

##### Technical Details

- Interface boundaries between components
- Data format transformations
- Configuration injection points
- Resource requirements
- Performance-critical paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Process Component]:::process
        L2[(Database Component)]:::database
        L3{{ML Model Component}}:::ml
        L4[/API Component/]:::api
        L5([Support Component]):::support
    end

    subgraph "Data Input Layer"
        InputData[Raw Detector Data]:::database
        DetData[Detector Streams]:::database
    end

    subgraph "Frame Processing Layer"
        FrameCollections["Frame Collections"]:::process
        click FrameCollections "https://github.com/ML4SCI/CMS/blob/main/DataFormats/interface/FrameCollections.h"
        
        DetFrame["DetFrameProducer"]:::process
        click DetFrame "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/DetFrameProducer.h"
        
        EGFrame["EGFrameProducer"]:::process
        click EGFrame "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/EGFrameProducer.h"
        
        JetFrame["JetFrameProducer"]:::process
        click JetFrame "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/JetFrameProducer.h"
        
        FrameCrop["Frame Cropping"]:::support
        click FrameCrop "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/FrameCropping.h"
        
        FrameStride["Frame Striding"]:::support
        click FrameStride "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/FrameStriding.h"
    end

    subgraph "Tagger Layer"
        EGTagger["EG Tagger"]:::process
        click EGTagger "https://github.com/ML4SCI/CMS/tree/main/EGTagger"
        
        QGTagger["QG Tagger"]:::process
        click QGTagger "https://github.com/ML4SCI/CMS/tree/main/QGTagger"
        
        TauTagger["Tau Tagger"]:::process
        click TauTagger "https://github.com/ML4SCI/CMS/tree/main/TauTagger"
        
        TopTagger["Top Tagger"]:::process
        click TopTagger "https://github.com/ML4SCI/CMS/tree/main/TopTagger"
    end

    subgraph "Model Inference Layer"
        TFPredict["TensorFlow Prediction"]:::support
        click TFPredict "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/interface/predict_tf.h"
        
        ResNet1["ResNet 1 Channel"]:::ml
        click ResNet1 "https://github.com/ML4SCI/CMS/blob/main/tfModels/ResNet_1_channel_tf6.pb"
        
        ResNet4["ResNet 4 Channel"]:::ml
        click ResNet4 "https://github.com/ML4SCI/CMS/blob/main/tfModels/ResNet_4_channel_tf13.pb"
        
        ResNet8["ResNet 8 Channel"]:::ml
        click ResNet8 "https://github.com/ML4SCI/CMS/blob/main/tfModels/ResNet_8_channel_tf13.pb"
        
        ResNet9["ResNet 9 Channel"]:::ml
        click ResNet9 "https://github.com/ML4SCI/CMS/blob/main/tfModels/ResNet_9_channel_tf13.pb"
    end

    subgraph "Configuration Layer"
        MainConfig["Main E2eDL Config"]:::support
        click MainConfig "https://github.com/ML4SCI/CMS/blob/main/FrameProducers/python/E2eDLreco_cfg.py"
        
        EGConfig["EG Tagger Config"]:::support
        click EGConfig "https://github.com/ML4SCI/CMS/blob/main/EGTagger/python/EGTagger_cfi.py"
        
        QGConfig["QG Tagger Config"]:::support
        click QGConfig "https://github.com/ML4SCI/CMS/blob/main/QGTagger/python/QGTagger_cfi.py"
        
        TauConfig["Tau Tagger Config"]:::support
        click TauConfig "https://github.com/ML4SCI/CMS/blob/main/TauTagger/python/TauTagger_cfi.py"
        
        TopConfig["Top Tagger Config"]:::support
        click TopConfig "https://github.com/ML4SCI/CMS/blob/main/TopTagger/python/TopTagger_cfi.py"
    end

    %% Connections
    InputData --> DetData
    DetData --> FrameCollections
    FrameCollections --> DetFrame & EGFrame & JetFrame
    DetFrame & EGFrame & JetFrame --> FrameCrop
    FrameCrop --> FrameStride
    FrameStride --> EGTagger & QGTagger & TauTagger & TopTagger
    EGTagger & QGTagger & TauTagger & TopTagger --> TFPredict
    TFPredict --> ResNet1 & ResNet4 & ResNet8 & ResNet9

    MainConfig -.-> FrameCollections
    EGConfig -.-> EGTagger
    QGConfig -.-> QGTagger
    TauConfig -.-> TauTagger
    TopConfig -.-> TopTagger

    %% Styles
    classDef process fill:#a8d5ff,stroke:#333,stroke-width:2px
    classDef database fill:#f9f,stroke:#333,stroke-width:2px
    classDef ml fill:#ffb366,stroke:#333,stroke-width:2px
    classDef api fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef support fill:#f0f0f0,stroke:#333,stroke-width:2px
```
