Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 //################## EcnaHistosExample1.cc ####################
0002 // B. Fabbro      09/08/2012
0003 //
0004 //   Drawing histos with TEcnaHistos
0005 //   with and without direct calls to TEcnaRead methods
0006 
0007 #include "CalibCalorimetry/EcalCorrelatedNoiseAnalysisAlgos/interface/TEcnaHistos.h"
0008 
0009 #include "Riostream.h"
0010 #include "TROOT.h"
0011 #include "TRint.h"
0012 
0013 #include <stdlib.h>
0014 #include <string>
0015 #include "TString.h"
0016 
0017 using namespace std;
0018 
0019 int main(int argc, char** argv) {
0020   TEcnaObject* myTEcnaManagerEB = new TEcnaObject();
0021   TEcnaObject* myTEcnaManagerEE = new TEcnaObject();
0022   TEcnaParPaths* fEcnaParPathsEB = new TEcnaParPaths(myTEcnaManagerEB);
0023   TEcnaParPaths* fEcnaParPathsEE = new TEcnaParPaths(myTEcnaManagerEE);
0024 
0025   if (fEcnaParPathsEB->GetPaths() == kTRUE && fEcnaParPathsEE->GetPaths() == kTRUE) {
0026     std::cout << "*EcnaHistosExample> Starting ROOT session" << std::endl;
0027     TRint theApp("App", &argc, argv);
0028 
0029     //--------------------------------------------------------------------
0030     //                      Init
0031     //--------------------------------------------------------------------
0032     Int_t xCnew = 0;
0033     Int_t xCdelete = 0;
0034 
0035     TString fTTBELL = "\007";
0036 
0037     //--------------------------------------------------------------------
0038     //                   view histos
0039     //--------------------------------------------------------------------
0040     //TEcnaParEcal* fEcalParEB = new TEcnaParEcal(myTEcnaManagerEB, "EB");
0041     TEcnaParEcal* fEcalParEE = new TEcnaParEcal(myTEcnaManagerEE, "EE");
0042 
0043     //TEcnaRead*   fMyRootFileEB = new TEcnaRead(myTEcnaManagerEB, "EB");
0044     TEcnaRead* fMyRootFileEE = new TEcnaRead(myTEcnaManagerEE, "EE");
0045 
0046     TEcnaHistos* MyHistosEB = new TEcnaHistos(myTEcnaManagerEB, "EB");
0047     xCnew++;
0048     TEcnaHistos* MyHistosEE = new TEcnaHistos(myTEcnaManagerEE, "EE");
0049     xCnew++;
0050 
0051     //.............. Declarations and default values
0052     TString fKeyAnaType = "StdPeg12";  // Analysis name
0053     Int_t fKeyNbOfSamples = 10;        // Number of required samples
0054     Int_t fKeyRunNumber = 136098;      // Run number
0055     Int_t fKeyFirstEvt = 1;            // First Event number (to be analyzed)
0056     Int_t fKeyLastEvt = 0;             // Last Event number (to be analyzed)
0057     Int_t fKeyNbOfEvts = 150;          // Number of required events (events to be analyzed)
0058     Int_t fKeySuMoNumber = 11;         // Super-module number (EB)
0059     Int_t fKeyDeeNumber = 3;           // Dee number (EE)
0060 
0061     Int_t SMtower = 1;
0062     Int_t TowEcha = 1;
0063 
0064     //================================== Plots
0065 
0066     fKeyAnaType = "StdPeg12";
0067     fKeyRunNumber = 136098;
0068     fKeyFirstEvt = 1;
0069     fKeyLastEvt = 0;
0070     fKeyNbOfEvts = 150;
0071     fKeySuMoNumber = 11;
0072     MyHistosEB->FileParameters(
0073         fKeyAnaType.Data(), fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0074 
0075     MyHistosEB->SetHistoColorPalette(" ");
0076 
0077     MyHistosEB->GeneralTitle("EcnaHistosExample1");
0078     MyHistosEB->SetHistoScaleY("LIN");
0079 
0080     //............................. Pedestals
0081     MyHistosEB->SetHistoMin(0.);
0082     MyHistosEB->SetHistoMax();
0083     MyHistosEB->Plot1DHisto("Crystal#", "Ped", "SM");
0084 
0085     //.............................
0086     fKeyAnaType = "StdPeg12";
0087     fKeyRunNumber = 136098;
0088     fKeyLastEvt = 0;
0089     fKeySuMoNumber = 11;
0090 
0091     //.................................... EtaPhiSuperModuleMeanCorss (EB)
0092     MyHistosEB->PlotDetector("MCs", "SM");
0093 
0094 #define FPLO
0095 #ifdef FPLO
0096     //............................. Correlations between samples
0097     SMtower = 21;
0098     TowEcha = 12;
0099     MyHistosEB->PlotMatrix("Cor", "Mss", SMtower, TowEcha, "LEGO2Z");
0100 #endif  // FPLO
0101 
0102 #define NOLO
0103 #ifdef NOLO
0104     //--------------------------------------------------- Proj, Log
0105     fKeyFirstEvt = 1;
0106     fKeySuMoNumber = 3;
0107     MyHistosEB->FileParameters(
0108         "StdPeg12", fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0109     MyHistosEB->SetHistoMax(2.5);
0110     MyHistosEB->SetHistoScaleY("LOG");
0111     //MyHistosEB->Plot1DHisto("LowFrequencyNoise", "NbOfXtals", "SM", "SAME");
0112 
0113     std::cout << "*EcnaHistosExample1> *** TEST OF WRONG CODE (BEGINNING)."
0114               << " MESSAGE: < code not found > (and lists after) ARE THERE ON PURPOSE." << std::endl
0115               << std::endl;
0116 
0117     MyHistosEB->Plot1DHisto("LowFrequencyNoise", "NbOfXtal", "SM", "SAME");
0118     std::cout << std::endl
0119               << "*EcnaHistosExample1> *** TEST OF WRONG CODE (END)."
0120               << " MESSAGE: < code not found > (and lists after) WERE THERE ON PURPOSE." << std::endl;
0121 
0122     //.................................
0123     fKeySuMoNumber = 4;
0124     MyHistosEB->FileParameters(
0125         "StdPeg12", fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0126     MyHistosEB->Plot1DHisto("LowFrequencyNoise", "NbOfXtals", "SM", "SAME");
0127     //.................................
0128     fKeySuMoNumber = 5;
0129     MyHistosEB->FileParameters(
0130         "StdPeg12", fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0131     MyHistosEB->Plot1DHisto("LowFrequencyNoise", "NbOfXtals", "SM", "SAME");
0132 
0133     MyHistosEB->SetHistoMax(2.5);
0134     MyHistosEB->Plot1DHisto("HighFrequencyNoise", "NbOfXtals", "SM");
0135 
0136     MyHistosEB->SetHistoScaleY("LIN");
0137 #endif  // NOLO
0138 
0139 #define SAMP
0140 #ifdef SAMP
0141     //--------------------------------------------------- tests option SAME n
0142 
0143     MyHistosEB->NewCanvas("SAME n");
0144     MyHistosEB->SetHistoScaleY("LIN");
0145     MyHistosEB->SetHistoMax(2.5);
0146     MyHistosEB->Plot1DHisto("Xtal", "TNo", "SM", "SAME n");
0147     MyHistosEB->Plot1DHisto("Xtal", "LFN", "SM", "SAME n");
0148     MyHistosEB->Plot1DHisto("Xtal", "HFN", "SM", "SAME n");
0149 
0150     MyHistosEB->NewCanvas("SAME n");
0151     MyHistosEB->SetHistoScaleY("LOG");
0152     MyHistosEB->SetHistoMax(2.5);
0153     MyHistosEB->Plot1DHisto("TNo", "NbOfXtals", "SM", "SAME n");
0154     MyHistosEB->Plot1DHisto("LFN", "NbOfXtals", "SM", "SAME n");
0155     MyHistosEB->Plot1DHisto("HFN", "NbOfXtals", "SM", "SAME n");
0156 
0157     MyHistosEB->SetHistoScaleY("LIN");
0158 
0159 #endif  // SAMP
0160 
0161 #define SIGM
0162 #ifdef SIGM
0163     //.................................. Sample sigma Distribution for 7 crystals
0164     fKeyAnaType = "StdPeg12";
0165     fKeyRunNumber = 136098;
0166     fKeyFirstEvt = 1;
0167     fKeyLastEvt = 0;
0168     fKeySuMoNumber = 17;
0169     MyHistosEB->FileParameters(
0170         fKeyAnaType.Data(), fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0171 
0172     MyHistosEB->SetHistoScaleY("LIN");
0173 
0174     SMtower = 38;
0175 
0176     MyHistosEB->SetHistoColorPalette("rainbow");
0177 
0178     TowEcha = 10;
0179     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0180     TowEcha = 11;
0181     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0182     TowEcha = 12;
0183     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0184     TowEcha = 13;
0185     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0186     TowEcha = 14;
0187     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0188     TowEcha = 15;
0189     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0190     TowEcha = 16;
0191     MyHistosEB->Plot1DHisto("SampleSigma", "NOS", SMtower, TowEcha, "SAME");
0192 #endif  // SIGM
0193 
0194 #define SIGC
0195 #ifdef SIGC
0196 
0197     Int_t DeeSC = 245;
0198     //..................................... Dee & crystal numbering
0199     MyHistosEE->SCCrystalNumbering(fKeyDeeNumber, DeeSC);
0200     MyHistosEE->DeeSCNumbering(fKeyDeeNumber);
0201 
0202 #endif  // SIGC
0203 
0204     //..................................... stability
0205 
0206 #define SIGS
0207 #ifdef SIGS
0208     //........................................... History Plots
0209     SMtower = 28;
0210     TowEcha = 12;
0211     MyHistosEB->SetHistoScaleY("LIN");
0212     fKeyAnaType = "StdPeg12";
0213     fKeyFirstEvt = 1;
0214     fKeyLastEvt = 0;
0215     fKeySuMoNumber = 17;
0216     MyHistosEB->SetHistoColorPalette(" ");
0217 
0218     MyHistosEB->FileParameters(
0219         fKeyAnaType.Data(), fKeyNbOfSamples, 0, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeySuMoNumber);
0220 
0221     TString run_par_file_name = "Ecna_132440_137033";
0222 
0223     MyHistosEB->SetHistoMin(0.15);
0224     MyHistosEB->SetHistoMax(0.8);
0225     MyHistosEB->PlotHistory("Time", "MCs", run_par_file_name, SMtower, TowEcha);
0226 
0227     MyHistosEB->SetHistoMin(-0.2);
0228     MyHistosEB->SetHistoMax(0.75);
0229     MyHistosEB->PlotHistory("MCs", "NOR", run_par_file_name, SMtower, TowEcha);
0230 
0231     MyHistosEB->NewCanvas("SAME n");
0232     MyHistosEB->SetHistoMin(0.);
0233     MyHistosEB->SetHistoMax(2.5);
0234     MyHistosEB->PlotHistory("Time", "TotalNoise", run_par_file_name, SMtower, TowEcha, "SAME n");
0235     MyHistosEB->PlotHistory("Time", "LFN", run_par_file_name, SMtower, TowEcha, "SAME n");
0236     MyHistosEB->PlotHistory("Time", "HFN", run_par_file_name, SMtower, TowEcha, "SAME n");
0237     MyHistosEB->PlotHistory("Time", "MeanCorss", run_par_file_name, SMtower, TowEcha, "SAME n");
0238     MyHistosEB->PlotHistory("Time", "SigCorss", run_par_file_name, SMtower, TowEcha, "SAME n");
0239 #endif  // SIGS
0240 
0241 #define SIGE
0242 #ifdef SIGE
0243     //............................................ EE plots
0244     fKeyAnaType = "StdPeg12";
0245     fKeyRunNumber = 136098;
0246     fKeyFirstEvt = 1;
0247     fKeyLastEvt = 0;
0248     fKeyDeeNumber = 2;
0249 
0250     MyHistosEE->SetHistoScaleY("LIN");
0251     MyHistosEE->GeneralTitle("EcnaHistosExample1");
0252 
0253     fMyRootFileEE->PrintNoComment();
0254     fMyRootFileEE->FileParameters(fKeyAnaType,
0255                                   fKeyNbOfSamples,
0256                                   fKeyRunNumber,
0257                                   fKeyFirstEvt,
0258                                   fKeyLastEvt,
0259                                   fKeyNbOfEvts,
0260                                   fKeyDeeNumber,
0261                                   fEcnaParPathsEE->ResultsRootFilePath().Data());
0262 
0263     if (fMyRootFileEE->LookAtRootFile() == kTRUE) {
0264       TVectorD read_ee_histo(fEcalParEE->MaxSCInEE());
0265       read_ee_histo = fMyRootFileEE->Read1DHisto(fEcalParEE->MaxSCInEE(), "total noise", "EE");
0266 
0267       MyHistosEE->FileParameters(fMyRootFileEE);
0268       MyHistosEE->SetHistoMax(3.5);
0269       MyHistosEE->SetHistoScaleY("LIN");
0270       MyHistosEE->PlotDetector(read_ee_histo, "TotalNoise", "EE");
0271       MyHistosEE->Plot1DHisto(read_ee_histo, "SC", "TotalNoise", "EE");
0272     }
0273 
0274     MyHistosEE->FileParameters(
0275         fKeyAnaType.Data(), fKeyNbOfSamples, fKeyRunNumber, fKeyFirstEvt, fKeyLastEvt, fKeyNbOfEvts, fKeyDeeNumber);
0276     MyHistosEE->SetHistoScaleY("LIN");
0277     MyHistosEE->SetHistoMin();
0278     MyHistosEE->SetHistoMax();
0279     MyHistosEE->PlotDetector("TNo", "Dee");
0280 
0281 #endif  // SIGE
0282     //.......................................................................
0283 
0284     std::cout << "*EcnaHistosExample1> End of the example. You can quit ROOT (.q)" << std::endl;
0285 
0286     Bool_t retVal = kTRUE;
0287     theApp.Run(retVal);
0288     std::cout << std::endl << "*EcnaHistosExample> Terminating ROOT session." << std::endl;
0289     theApp.Terminate(0);
0290     std::cout << "*EcnaHistosExample> Exiting main program." << std::endl;
0291     exit(0);
0292 
0293     delete MyHistosEB;
0294     xCdelete++;
0295     delete MyHistosEE;
0296     xCdelete++;
0297 
0298     if (xCnew != xCdelete) {
0299       std::cout << "!EcnaHistosExample1> WRONG MANAGEMENT OF ALLOCATIONS: xCnew = " << xCnew
0300                 << ", xCdelete = " << xCdelete << '\007' << std::endl;
0301     } else {
0302       //  std::cout << "*EcnaHistosExample1> BRAVO! GOOD MANAGEMENT OF ALLOCATIONS: xCnew = "
0303       //      << xCnew << ", xCdelete = " << xCdelete << std::endl;
0304     }
0305   }
0306 }