Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:40

0001 //---------Author's Name: B.Fabbro DSM/IRFU/SPP CEA-Saclay
0002 //----------Copyright: Those valid for CEA sofware
0003 //----------Modified: 29/01/2014
0004 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaObject.h"
0005 
0006 //--------------------------------------
0007 //  TEcnaObject.cc
0008 //  Class creation: 15 October 2010
0009 //  Documentation: see TEcnaObject.h
0010 //--------------------------------------
0011 
0012 ClassImp(TEcnaObject);
0013 //______________________________________________________________________________
0014 //
0015 
0016 TEcnaObject::~TEcnaObject() {
0017   //destructor
0018 
0019   //  std::cout << "[Info Management] CLASS: TEcnaObject.      DESTROY OBJECT: this = " << this << std::endl;
0020 }
0021 
0022 //===================================================================
0023 //
0024 //                   Constructors
0025 //
0026 //===================================================================
0027 TEcnaObject::TEcnaObject() {
0028   // Constructor without argument
0029 
0030   //  std::cout << "[Info Management] CLASS: TEcnaObject.      CREATE OBJECT: this = " << this << std::endl;
0031 
0032   Long_t PointerValue = (Long_t)this;
0033   Int_t un = 1;
0034   NumberCreateObjectMessage("TEcnaObject", PointerValue, un);
0035 
0036   Init();
0037 }
0038 
0039 void TEcnaObject::Init() {
0040   fgMaxCar = (Int_t)512;
0041   fTTBELL = '\007';
0042 
0043   //................ Init pointers to TEcna Objects
0044   fObjectTEcnaGui = 0;
0045   fObjectTEcnaHeader = 0;
0046   fObjectTEcnaHistos = 0;
0047   fObjectTEcnaNArrayD = 0;
0048   fObjectTEcnaNumbering = 0;
0049   fObjectTEcnaParCout = 0;
0050   fObjectTEcnaParEcal = 0;
0051   fObjectTEcnaParHistos = 0;
0052   fObjectTEcnaParPaths = 0;
0053   fObjectTEcnaRead = 0;
0054   fObjectTEcnaResultType = 0;
0055   fObjectTEcnaRootFile = 0;
0056   fObjectTEcnaRun = 0;
0057   fObjectTEcnaWrite = 0;
0058 
0059   //................ Init counters of TEcna Object creation
0060   fCounterCreateTEcnaGui = 0;
0061   fCounterCreateTEcnaHeader = 0;
0062   fCounterCreateTEcnaHistos = 0;
0063   fCounterCreateTEcnaNArrayD = 0;
0064   fCounterCreateTEcnaNumbering = 0;
0065   fCounterCreateTEcnaParCout = 0;
0066   fCounterCreateTEcnaParEcal = 0;
0067   fCounterCreateTEcnaParHistos = 0;
0068   fCounterCreateTEcnaParPaths = 0;
0069   fCounterCreateTEcnaRead = 0;
0070   fCounterCreateTEcnaResultType = 0;
0071   fCounterCreateTEcnaRootFile = 0;
0072   fCounterCreateTEcnaRun = 0;
0073   fCounterCreateTEcnaWrite = 0;
0074 
0075   //................ Init counters of TEcna Object re-using
0076   fCounterReusingTEcnaGui = 0;
0077   fCounterReusingTEcnaHeader = 0;
0078   fCounterReusingTEcnaHistos = 0;
0079   fCounterReusingTEcnaNArrayD = 0;
0080   fCounterReusingTEcnaNumbering = 0;
0081   fCounterReusingTEcnaParCout = 0;
0082   fCounterReusingTEcnaParEcal = 0;
0083   fCounterReusingTEcnaParHistos = 0;
0084   fCounterReusingTEcnaParPaths = 0;
0085   fCounterReusingTEcnaRead = 0;
0086   fCounterReusingTEcnaResultType = 0;
0087   fCounterReusingTEcnaRootFile = 0;
0088   fCounterReusingTEcnaRun = 0;
0089   fCounterReusingTEcnaWrite = 0;
0090 
0091 }  // end of Init()
0092 
0093 //=======================================================================================
0094 //
0095 //              P O I N T E R /  O B J E C T   M A N A G E M E N T
0096 //
0097 //              TEcnaObject not in list because it is the manager
0098 //
0099 //=======================================================================================
0100 Bool_t TEcnaObject::RegisterPointer(const TString& ClassName, const Long_t& PointerValue) {
0101   Bool_t ClassFound = kFALSE;
0102 
0103   if (ClassName == "TEcnaGui") {
0104     ClassFound = kTRUE;
0105     fObjectTEcnaGui = PointerValue;
0106     fCounterCreateTEcnaGui++;
0107     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaGui);
0108   }
0109 
0110   if (ClassName == "TEcnaHeader") {
0111     ClassFound = kTRUE;
0112     fObjectTEcnaHeader = PointerValue;
0113     fCounterCreateTEcnaHeader++;
0114     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaHeader);
0115   }
0116 
0117   if (ClassName == "TEcnaHistos") {
0118     ClassFound = kTRUE;
0119     fObjectTEcnaHistos = PointerValue;
0120     fCounterCreateTEcnaHistos++;
0121     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaHistos);
0122   }
0123 
0124   if (ClassName == "TEcnaNArrayD") {
0125     ClassFound = kTRUE;
0126     fObjectTEcnaNArrayD = PointerValue;
0127     fCounterCreateTEcnaNArrayD++;
0128     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaNArrayD);
0129   }
0130 
0131   if (ClassName == "TEcnaNumbering") {
0132     ClassFound = kTRUE;
0133     fObjectTEcnaNumbering = PointerValue;
0134     fCounterCreateTEcnaNumbering++;
0135     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaNumbering);
0136   }
0137 
0138   if (ClassName == "TEcnaParCout") {
0139     ClassFound = kTRUE;
0140     fObjectTEcnaParCout = PointerValue;
0141     fCounterCreateTEcnaParCout++;
0142     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaParCout);
0143   }
0144 
0145   if (ClassName == "TEcnaParEcal") {
0146     ClassFound = kTRUE;
0147     fObjectTEcnaParEcal = PointerValue;
0148     fCounterCreateTEcnaParEcal++;
0149     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaParEcal);
0150   }
0151 
0152   if (ClassName == "TEcnaParHistos") {
0153     ClassFound = kTRUE;
0154     fObjectTEcnaParHistos = PointerValue;
0155     fCounterCreateTEcnaParHistos++;
0156     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaParHistos);
0157   }
0158 
0159   if (ClassName == "TEcnaParPaths") {
0160     ClassFound = kTRUE;
0161     fObjectTEcnaParPaths = PointerValue;
0162     fCounterCreateTEcnaParPaths++;
0163     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaParPaths);
0164   }
0165 
0166   if (ClassName == "TEcnaRead") {
0167     ClassFound = kTRUE;
0168     fObjectTEcnaRead = PointerValue;
0169     fCounterCreateTEcnaRead++;
0170     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaRead);
0171   }
0172 
0173   if (ClassName == "TEcnaResultType") {
0174     ClassFound = kTRUE;
0175     fObjectTEcnaResultType = PointerValue;
0176     fCounterCreateTEcnaResultType++;
0177     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaResultType);
0178   }
0179 
0180   if (ClassName == "TEcnaRootFile") {
0181     ClassFound = kTRUE;
0182     fObjectTEcnaRootFile = PointerValue;
0183     fCounterCreateTEcnaRootFile++;
0184     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaRootFile);
0185   }
0186 
0187   if (ClassName == "TEcnaRun") {
0188     ClassFound = kTRUE;
0189     fObjectTEcnaRun = PointerValue;
0190     fCounterCreateTEcnaRun++;
0191     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaRun);
0192   }
0193 
0194   if (ClassName == "TEcnaWrite") {
0195     ClassFound = kTRUE;
0196     fObjectTEcnaWrite = PointerValue;
0197     fCounterCreateTEcnaWrite++;
0198     NumberCreateObjectMessage(ClassName.Data(), PointerValue, fCounterCreateTEcnaWrite);
0199   }
0200 
0201   //.........................................................................................
0202   if (ClassFound == kFALSE) {
0203     std::cout << "!TEcnaObject::RegisterPointer(...)> Class " << ClassName << " not found." << fTTBELL << std::endl;
0204   }
0205 
0206   return ClassFound;
0207 }  // end of RegisterPointer(...)
0208 
0209 Long_t TEcnaObject::GetPointerValue(const TString& ClassName) {
0210   Long_t PointerValue = (Long_t)0;
0211 
0212   if (ClassName == "TEcnaGui") {
0213     PointerValue = fObjectTEcnaGui;
0214     fCounterReusingTEcnaGui++;
0215     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaGui);
0216   }
0217 
0218   if (ClassName == "TEcnaHeader") {
0219     PointerValue = fObjectTEcnaHeader;
0220     fCounterReusingTEcnaHeader++;
0221     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaHeader);
0222   }
0223 
0224   if (ClassName == "TEcnaHistos") {
0225     PointerValue = fObjectTEcnaHistos;
0226     fCounterReusingTEcnaHistos++;
0227     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaHistos);
0228   }
0229 
0230   if (ClassName == "TEcnaNArrayD") {
0231     PointerValue = fObjectTEcnaNArrayD;
0232     fCounterReusingTEcnaNArrayD++;
0233     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaNArrayD);
0234   }
0235 
0236   if (ClassName == "TEcnaNumbering") {
0237     PointerValue = fObjectTEcnaNumbering;
0238     fCounterReusingTEcnaNumbering++;
0239     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaNumbering);
0240   }
0241 
0242   if (ClassName == "TEcnaParCout") {
0243     PointerValue = fObjectTEcnaParCout;
0244     fCounterReusingTEcnaParCout++;
0245     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaParCout);
0246   }
0247 
0248   if (ClassName == "TEcnaParEcal") {
0249     PointerValue = fObjectTEcnaParEcal;
0250     fCounterReusingTEcnaParEcal++;
0251     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaParEcal);
0252   }
0253 
0254   if (ClassName == "TEcnaParHistos") {
0255     PointerValue = fObjectTEcnaParHistos;
0256     fCounterReusingTEcnaParHistos++;
0257     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaParHistos);
0258   }
0259 
0260   if (ClassName == "TEcnaParPaths") {
0261     PointerValue = fObjectTEcnaParPaths;
0262     fCounterReusingTEcnaParPaths++;
0263     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaParPaths);
0264   }
0265 
0266   if (ClassName == "TEcnaRead") {
0267     PointerValue = fObjectTEcnaRead;
0268     fCounterReusingTEcnaRead++;
0269     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaRead);
0270   }
0271 
0272   if (ClassName == "TEcnaResultType") {
0273     PointerValue = fObjectTEcnaResultType;
0274     fCounterReusingTEcnaResultType++;
0275     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaResultType);
0276   }
0277 
0278   if (ClassName == "TEcnaRootFile") {
0279     PointerValue = fObjectTEcnaRootFile;
0280     fCounterReusingTEcnaRootFile++;
0281     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaRootFile);
0282   }
0283 
0284   if (ClassName == "TEcnaRun") {
0285     PointerValue = fObjectTEcnaRun;
0286     fCounterReusingTEcnaRun++;
0287     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaRun);
0288   }
0289 
0290   if (ClassName == "TEcnaWrite") {
0291     PointerValue = fObjectTEcnaWrite;
0292     fCounterReusingTEcnaWrite++;
0293     NumberReuseObjectMessage(ClassName.Data(), PointerValue, fCounterReusingTEcnaWrite);
0294   }
0295 
0296   return PointerValue;
0297 }
0298 
0299 void TEcnaObject::NumberCreateObjectMessage(const TString& ClassName,
0300                                             const Long_t& PointerValue,
0301                                             const Int_t& NbOfObjects) {
0302 #define NOCM
0303 #ifndef NOCM
0304   std::cout << "*TEcnaObject::NumberCreateObjectMessage(...)> New ECNA object (pointer = " << PointerValue
0305             << ") from TEcnaObject " << this << ". Object# = " << std::setw(8) << NbOfObjects
0306             << ", Class: " << ClassName;
0307   if (NbOfObjects > 1) {
0308     std::cout << " (INFO: more than 1 object)";
0309   }
0310   std::cout << std::endl;
0311 #endif  // NOCM
0312 }
0313 
0314 void TEcnaObject::NumberReuseObjectMessage(const TString& ClassName,
0315                                            const Long_t& PointerValue,
0316                                            const Int_t& NbOfObjects) {
0317 #define NOCR
0318 #ifndef NOCR
0319   if (PointerValue != (Long_t)0) {
0320     std::cout << "*TEcnaObject::NumberReuseObjectMessage(...)> INFO: pointer " << PointerValue
0321               << " used again from TEcnaObject " << this << ". " << std::setw(8) << NbOfObjects
0322               << " times, class: " << ClassName;
0323   }
0324   std::cout << std::endl;
0325 #endif  // NOCR
0326 }