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 "Generic3D.h"
0014 #include <AIDA/IHistogram3D.h>
0015 #include <Gaudi/Histograming/Sink/Utils.h>
0016 #include <GaudiKernel/DataObject.h>
0017 #include <TH3D.h>
0018 
0019 #include <nlohmann/json.hpp>
0020 
0021 namespace Gaudi {
0022 
0023   /**@class Histogram3D
0024    *
0025    * AIDA implementation for 3 D histograms using ROOT THD2
0026    *
0027    * @author  M.Frank
0028    */
0029   class GAUDI_API Histogram3D : public DataObject, public Generic3D<AIDA::IHistogram3D, TH3D> {
0030   public:
0031     /// Standard Constructor
0032     Histogram3D();
0033     /// Standard Constructor
0034     Histogram3D( TH3D* rep );
0035 
0036     /// Fill bin content
0037     bool fill( double x, double y, double z, double weight ) override;
0038     /// Fast filling method for a given bin. It can be also the over/underflow bin
0039     virtual bool setBinContents( int i, int j, int k, int entries, double height, double error, double centreX,
0040                                  double centreY, double centreZ );
0041     /// Sets the rms of the histogram.
0042     virtual bool setRms( double rmsX, double rmsY, double rmsZ );
0043     // overwrite reset
0044     bool reset() override;
0045     // free function reset
0046     friend void reset( Histogram3D& h ) { h.reset(); }
0047     /// conversion to json via nlohmann library
0048     friend void to_json( nlohmann::json& j, Histogram3D const& h ) { j = *h.m_rep.get(); }
0049     /// Introspection method
0050     void* cast( const std::string& className ) const override;
0051     /// Create new histogram from any AIDA based histogram
0052     void copyFromAida( const AIDA::IHistogram3D& h );
0053     /// Retrieve reference to class defininition identifier
0054     const CLID&        clID() const override { return classID(); }
0055     static const CLID& classID() { return CLID_H3D; }
0056 
0057   protected:
0058     // cache sumwx and sumwy  when setting contents since I don't have bin mean
0059     double m_sumwx = 0;
0060     double m_sumwy = 0;
0061     double m_sumwz = 0;
0062 
0063   private:
0064     std::mutex m_fillSerialization;
0065   };
0066 } // namespace Gaudi