Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:27

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #pragma once
0012 
0013 #include "Generic2D.h"
0014 #include <AIDA/IProfile1D.h>
0015 #include <Gaudi/Histograming/Sink/Utils.h>
0016 #include <GaudiKernel/DataObject.h>
0017 #include <TProfile2D.h>
0018 
0019 #include <nlohmann/json.hpp>
0020 
0021 #include <mutex>
0022 
0023 namespace Gaudi {
0024 
0025   /**@class Profile2D
0026    *
0027    * AIDA implementation for 2 D profiles using ROOT TProfile2D
0028    *
0029    * @author  M.Frank
0030    */
0031   class GAUDI_API Profile2D : public DataObject, public Generic2D<AIDA::IProfile2D, TProfile2D> {
0032   public:
0033     /// Default Constructor
0034     Profile2D() : Base( new TProfile2D() ) {
0035       m_classType = "IProfile2D";
0036       m_rep->SetErrorOption( "s" );
0037       m_rep->SetDirectory( nullptr );
0038     }
0039     /// Default Constructor with representation object
0040     Profile2D( TProfile2D* rep );
0041 
0042     /// Fill bin content
0043     bool fill( double x, double y, double z, double weight ) override {
0044       // avoid race conditions when filling the profile
0045       auto guard = std::scoped_lock{ m_fillSerialization };
0046       m_rep->Fill( x, y, z, weight );
0047       return true;
0048     }
0049     friend void reset( Profile2D& h ) { h.reset(); }
0050     /// conversion to json via nlohmann library
0051     friend void to_json( nlohmann::json& j, Profile2D const& p ) { j = *p.m_rep.get(); }
0052     /// Retrieve reference to class defininition identifier
0053     const CLID&        clID() const override { return classID(); }
0054     static const CLID& classID() { return CLID_ProfileH2; }
0055 
0056   private:
0057     std::mutex m_fillSerialization;
0058   };
0059 } // namespace Gaudi