# Access run number in QC checker

**URL:** <https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040>\
**Category:** O²\
**Tags:** quality-control\
**Created:** [July 28, 2021, 1:18pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040 "2021-07-28T13:18:22Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [July 28, 2021, 1:18pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/1 "2021-07-28T13:18:22Z")

</div>

Dear @pkonopka, @bvonhall,  
are there any way to access run numbers in the QC? I’m interested in accessing run number by checker in order to add message to the Monitoring Object like `msg->AddText(Form("Run %d: OK", runNumber));`.

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [July 28, 2021, 3:19pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/2 "2021-07-28T15:19:10Z")

</div>

Hi, I think you should be able to access it as MonitorObject metadata, with “RunNumber” key.  
However, I just checked some MOs on QCDB, and it seems the run number is set to zero, which is probably a bug:  
[http://qcdb.cern.ch:8083/browse/qc/CPV/MO/PedestalsOnFLP/HistAmplitude128](http://qcdb.cern.ch:8083/browse/qc/CPV/MO/PedestalsOnFLP/HistAmplitude128)  
I created an issue for this:  
[https://alice.its.cern.ch/jira/browse/QC-629](https://alice.its.cern.ch/jira/browse/QC-629)

Still this metadata key is the place where you should look for it after the problem is fixed.

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [July 28, 2021, 3:35pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/3 "2021-07-28T15:35:12Z")

</div>

Hello @pkonopka,

thank you! that’s exactly what I need. May I ask you also for the commands you used to inspect the MO in qcdb?

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [July 28, 2021, 5:10pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/4 "2021-07-28T17:10:45Z")

</div>

Oh, sorry for the flood. I thought that MOs are stored in database as `o2::quality_control::core::MonitorObject`s but actually they are stored as TH1/TH2 objects with metadata attached to database entry. Everything is displayed in ‘Metadata’ field in database browser.

---

<div class="post-metadata">

**Author:** ![pkonopka](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/p/e47774/32.png) [@pkonopka](https://alice-talk.web.cern.ch/u/pkonopka)\
**Post date:** [July 29, 2021, 6:19am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/5 "2021-07-29T06:19:09Z")

</div>

Yes, exactly

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [October 11, 2021, 5:38pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/6 "2021-10-11T17:38:11Z")

</div>

Dear Piotr, Barth,

I still facing a problem with accessing run numbers in checker. In the checker I prepared this piece of code:

```auto
        /* mo is MonitorObject which provided by PedestalTask, namely qc/CPV/MO/CPVPedestalTask/PedestalValueM2 /*
        int runNumber{ 0 };
        auto metaData = mo->getMetadataMap();
        ILOG(Info, Support) << "PedestalCheck::check() : I have following metadata:" << ENDM;
        for ( auto [key, value] : metaData) {
          ILOG(Info, Support) << "key = " << key << "; value = " << value << ENDM;
        }
        auto foundRN = metaData.find("RunNumber");
        if (foundRN != metaData.end()) {
          runNumber = std::stoi(foundRN->second);
          ILOG(Info, Support) << "PedestalCheck::check() : I found in metadata RunNumber = " << foundRN->second << ENDM;
        } else {
          ILOG(Info, Support) << "PedestalCheck::check() : I haven't found RunNumber in metadata, using from Activity." << ENDM;
          runNumber = mo->getActivity().mId;
          ILOG(Info, Support) << "PedestalCheck::check() : RunNumber = " << runNumber << ENDM;
        }

```

When I execute the code, it appears that metadata is empty((  
And also run number from the Activity is also 0!  
See output:

```auto
[279362:QC-CHECK-RUNNER-CPVPedestalCheck]: 2021-10-11 19:24:09.232421 PedestalCheck::check() : I have following metadata:
[279362:QC-CHECK-RUNNER-CPVPedestalCheck]: 2021-10-11 19:24:09.232431 PedestalCheck::check() : I haven't found RunNumber in metadata, using from Activity.
[279362:QC-CHECK-RUNNER-CPVPedestalCheck]: 2021-10-11 19:24:09.232437 PedestalCheck::check() : RunNumber = 0

```

However the metadata appears in database:  
[http://ccdb-test.cern.ch:8080/browse/qc/CPV/MO/CPVPedestalTask/PedestalValueM2](http://ccdb-test.cern.ch:8080/browse/qc/CPV/MO/CPVPedestalTask/PedestalValueM2)

 ![image](https://alice-talk.web.cern.ch/uploads/default/original/1X/28e26ab5404cf3dc8d978ea3703bb0be56640901.png)  
Is it a bug or a feature? At which step metadata is attached to MO? I just want to draw run number on the MO, nothing more. And facing such a problem…  
Any help is very appreciated.

Thank you & regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![bvonhall](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/bvonhall/32/8_2.png) [@bvonhall](https://alice-talk.web.cern.ch/u/bvonhall)\
**Post date:** [October 12, 2021, 9:04am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/7 "2021-10-12T09:04:42Z")

</div>

Hello,

`mo->getActivity()->mId` should contain what you need. If you confirm that it works I will add a sentence to the doc.

Cheesr,  
Barth

EDIT:

To answer your questions:  
We attach the run number to the monitor object in the CheckRunner. The CheckRunner knows it because it is driven by the aliECS.

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [October 12, 2021, 9:37am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/8 "2021-10-12T09:37:28Z")

</div>

Hello, Barth!

No, I don’t see proper run number in the Activity.  
In the example above I tried to access run number from the metadata or Activity, but it again appeared to be 0 (must be 42). And there were no metadata at all.

Can you please check my code in flp suite 0.31.1?  
As production example, see this [MO](https://qcg.cern.ch/?page=objectView&objectId=60ffc3a1453149f557e5b2bf&layoutId=60ffc1e9d6ff5e4d2324e81a). Text in the box says “Run 0”. Here is the [code](https://github.com/AliceO2Group/QualityControl/blob/v1.33.0/Modules/CPV/src/PedestalCheck.cxx):

```auto
msg->AddText(Form("Run %d", mo->getActivity().mId));

```

However in the qcdb run number is present in [metadata](http://qcdb.cern.ch:8083/browse/qc/CPV/MO/PedestalsOnFLP/PedestalValueM2), it is 503790.  
What am I doing wrong? At which stage you attach run number in the CheckRunner? Before PedestalCheck::check() call or after it?

Regards,  
Sergey

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [October 12, 2021, 4:18pm UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/9 "2021-10-12T16:18:13Z")

</div>

To provide more information:  
I attached metadata to MO in PedestalTask, and it appeared in the PedestalCheck::check(). So my conclusion is that metadata which appears in qcdb is attached to MO after PedestalCheck::check() called.

---

<div class="post-metadata">

**Author:** ![bvonhall](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/bvonhall/32/8_2.png) [@bvonhall](https://alice-talk.web.cern.ch/u/bvonhall)\
**Post date:** [October 13, 2021, 9:03am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/10 "2021-10-13T09:03:24Z")

</div>

Dear Sergey,

Thank you for your investigation. I have to do a bit of testing myself to understand exactly.

I’ll let you know.  
Cheers,  
Barth

---

<div class="post-metadata">

**Author:** ![bvonhall](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/bvonhall/32/8_2.png) [@bvonhall](https://alice-talk.web.cern.ch/u/bvonhall)\
**Post date:** [October 13, 2021, 9:09am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/11 "2021-10-13T09:09:00Z")

</div>

[https://alice.its.cern.ch/jira/browse/QC-671](https://alice.its.cern.ch/jira/browse/QC-671)

---

<div class="post-metadata">

**Author:** ![bvonhall](https://alice-talk.web.cern.ch/user_avatar/alice-talk.web.cern.ch/bvonhall/32/8_2.png) [@bvonhall](https://alice-talk.web.cern.ch/u/bvonhall)\
**Post date:** [October 13, 2021, 9:24am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/12 "2021-10-13T09:24:13Z")

</div>

Probably fixed in [https://github.com/AliceO2Group/QualityControl/pull/902](https://github.com/AliceO2Group/QualityControl/pull/902)

---

<div class="post-metadata">

**Author:** ![sevdokim](https://alice-talk.web.cern.ch/letter_avatar_proxy/v4/letter/s/c37758/32.png) [@sevdokim](https://alice-talk.web.cern.ch/u/sevdokim)\
**Post date:** [October 13, 2021, 10:09am UTC](https://alice-talk.web.cern.ch/t/access-run-number-in-qc-checker/1040/13 "2021-10-13T10:09:57Z")

</div>

Thanks, it is working now!  
Best regards,  
Sergey
