Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
//################## EcnaCalculationsExample.cc ####################
// B. Fabbro       21/10/2010
//
//

#include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRun.h"

#include "Riostream.h"
#include "TROOT.h"
#include "TRint.h"

#include <stdlib.h>
#include <string>
#include "TString.h"

using namespace std;

int main(int argc, char** argv) {
  //--------------------------------------------------------------------
  //                      Init
  //--------------------------------------------------------------------
  Int_t xCnew = 0;
  Int_t xCdelete = 0;

  TString fTTBELL = "\007";

  //--------------------------------------------------------------------
  //                   TEcnaRun
  //--------------------------------------------------------------------
  Int_t fKeyNbOfSamples = 10;  // Number of required samples

  TEcnaObject* myTEcnaManager = new TEcnaObject();

  std::cout << "!EcnaCalculationsExample> CONTROLE 1" << std::endl;

  TEcnaRun* MyRunEB = new TEcnaRun(myTEcnaManager, "EB", fKeyNbOfSamples);
  xCnew++;

  std::cout << "!EcnaCalculationsExample> CONTROLE 2" << std::endl;

  //.............. Declarations and default values

  TString fKeyAnaType = "AdcPeg12";  // Analysis name for the Adc file
  TString fKeyStdType = "StdPeg12";  // Analysis name for the Std (calculated) file
  Int_t fKeyRunNumber = 136098;      // Run number
  Int_t fKeyFirstEvt = 1;            // First Event number (to be analyzed)
  Int_t fKeyLastEvt = 0;             // Last Event number  (to be analyzed)
  Int_t fKeyNbOfEvts = 150;          // Number of events (events to be analyzed)
  Int_t fKeySuMoNumber = 18;         // Super-module number (EB)

  MyRunEB->GetReadyToReadData(
      fKeyAnaType.Data(), fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);

  Bool_t ok_read = MyRunEB->ReadSampleAdcValues();

  if (ok_read == kTRUE) {
    MyRunEB->GetReadyToCompute();

    //------- Standard calculations
    MyRunEB->StandardCalculations();

    //------- Expert 1 calculations long time, big file
    //MyRunEB->Expert1Calculations();

    //------- Expert 2 calculations long time
    //MyRunEB->Expert2Calculations();

    Bool_t ok_root_file = MyRunEB->WriteNewRootFile(fKeyStdType.Data());

    if (ok_root_file == kTRUE) {
      std::cout << "*EcnaCalculationsExample> Write ROOT file OK" << std::endl;
    } else {
      std::cout << "!EcnaCalculationsExample> Writing ROOT file failure." << fTTBELL << std::endl;
    }
  } else {
    std::cout << "!EcnaCalculationsExample> ROOT file not found." << fTTBELL << std::endl;
  }
  //.......................................................................

  delete MyRunEB;
  xCdelete++;

  std::cout << "*H4Cna(main)> End of the example." << std::endl;

  if (xCnew != xCdelete) {
    std::cout << "!H4Cna(main)> WRONG MANAGEMENT OF ALLOCATIONS: xCnew = " << xCnew << ", xCdelete = " << xCdelete
              << '\007' << std::endl;
  } else {
    //  std::cout << "*H4Cna(main)> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: xCnew = "
    //      << xCnew << ", xCdelete = " << xCdelete << std::endl;
  }

  std::cout << "*EcnaCalculationsExample> Exiting main program." << std::endl;
  exit(0);
}