Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:46

0001 //################## EcnaCalculationsExample.cc ####################
0002 // B. Fabbro       21/10/2010
0003 //
0004 //
0005 
0006 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaRun.h"
0007 
0008 #include "Riostream.h"
0009 #include "TROOT.h"
0010 #include "TRint.h"
0011 
0012 #include <stdlib.h>
0013 #include <string>
0014 #include "TString.h"
0015 
0016 using namespace std;
0017 
0018 int main(int argc, char** argv) {
0019   //--------------------------------------------------------------------
0020   //                      Init
0021   //--------------------------------------------------------------------
0022   Int_t xCnew = 0;
0023   Int_t xCdelete = 0;
0024 
0025   TString fTTBELL = "\007";
0026 
0027   //--------------------------------------------------------------------
0028   //                   TEcnaRun
0029   //--------------------------------------------------------------------
0030   Int_t fKeyNbOfSamples = 10;  // Number of required samples
0031 
0032   TEcnaObject* myTEcnaManager = new TEcnaObject();
0033 
0034   std::cout << "!EcnaCalculationsExample> CONTROLE 1" << std::endl;
0035 
0036   TEcnaRun* MyRunEB = new TEcnaRun(myTEcnaManager, "EB", fKeyNbOfSamples);
0037   xCnew++;
0038 
0039   std::cout << "!EcnaCalculationsExample> CONTROLE 2" << std::endl;
0040 
0041   //.............. Declarations and default values
0042 
0043   TString fKeyAnaType = "AdcPeg12";  // Analysis name for the Adc file
0044   TString fKeyStdType = "StdPeg12";  // Analysis name for the Std (calculated) file
0045   Int_t fKeyRunNumber = 136098;      // Run number
0046   Int_t fKeyFirstEvt = 1;            // First Event number (to be analyzed)
0047   Int_t fKeyLastEvt = 0;             // Last Event number  (to be analyzed)
0048   Int_t fKeyNbOfEvts = 150;          // Number of events (events to be analyzed)
0049   Int_t fKeySuMoNumber = 18;         // Super-module number (EB)
0050 
0051   MyRunEB->GetReadyToReadData(
0052       fKeyAnaType.Data(), fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0053 
0054   Bool_t ok_read = MyRunEB->ReadSampleAdcValues();
0055 
0056   if (ok_read == kTRUE) {
0057     MyRunEB->GetReadyToCompute();
0058 
0059     //------- Standard calculations
0060     MyRunEB->StandardCalculations();
0061 
0062     //------- Expert 1 calculations long time, big file
0063     //MyRunEB->Expert1Calculations();
0064 
0065     //------- Expert 2 calculations long time
0066     //MyRunEB->Expert2Calculations();
0067 
0068     Bool_t ok_root_file = MyRunEB->WriteNewRootFile(fKeyStdType.Data());
0069 
0070     if (ok_root_file == kTRUE) {
0071       std::cout << "*EcnaCalculationsExample> Write ROOT file OK" << std::endl;
0072     } else {
0073       std::cout << "!EcnaCalculationsExample> Writing ROOT file failure." << fTTBELL << std::endl;
0074     }
0075   } else {
0076     std::cout << "!EcnaCalculationsExample> ROOT file not found." << fTTBELL << std::endl;
0077   }
0078   //.......................................................................
0079 
0080   delete MyRunEB;
0081   xCdelete++;
0082 
0083   std::cout << "*H4Cna(main)> End of the example." << std::endl;
0084 
0085   if (xCnew != xCdelete) {
0086     std::cout << "!H4Cna(main)> WRONG MANAGEMENT OF ALLOCATIONS: xCnew = " << xCnew << ", xCdelete = " << xCdelete
0087               << '\007' << std::endl;
0088   } else {
0089     //  std::cout << "*H4Cna(main)> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: xCnew = "
0090     //      << xCnew << ", xCdelete = " << xCdelete << std::endl;
0091   }
0092 
0093   std::cout << "*EcnaCalculationsExample> Exiting main program." << std::endl;
0094   exit(0);
0095 }