Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:25:18

0001 #ifndef RecoHI_HiEvtPlaneAlgos_LoadEPDB_h
0002 #define RecoHI_HiEvtPlaneAlgos_LoadEPDB_h
0003 
0004 // system include files
0005 #include <memory>
0006 #include <iostream>
0007 #include <string>
0008 
0009 // user include files
0010 #include "CondFormats/HIObjects/interface/RPFlatParams.h"
0011 
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 
0014 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0015 
0016 #include "DataFormats/HeavyIonEvent/interface/EvtPlane.h"
0017 #include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneFlatten.h"
0018 #include "RecoHI/HiEvtPlaneAlgos/interface/HiEvtPlaneList.h"
0019 #include <vector>
0020 
0021 class LoadEPDB {
0022 public:
0023   explicit LoadEPDB(const RPFlatParams& flatparmsDB_, HiEvtPlaneFlatten** flat) {
0024     int Hbins;
0025     int Obins;
0026     int flatTableSize = flatparmsDB_.m_table.size();
0027     genFlatPsi_ = kTRUE;
0028     if (flatTableSize < flat[0]->getHBins() + 2 * flat[0]->getOBins()) {
0029       genFlatPsi_ = kFALSE;
0030     } else {
0031       Hbins = flat[0]->getHBins();
0032       Obins = flat[0]->getOBins();
0033 
0034       for (int i = 0; i < flatTableSize; i++) {
0035         const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[i]);
0036         for (int j = 0; j < hi::NumEPNames; j++) {
0037           int indx = thisBin->RPNameIndx[j];
0038           if (indx < 0 || indx >= hi::NumEPNames) {
0039             genFlatPsi_ = kFALSE;
0040             break;
0041           }
0042           if (indx >= 0) {
0043             if (i < Hbins) {
0044               flat[indx]->setXDB(i, thisBin->x[j]);
0045               flat[indx]->setYDB(i, thisBin->y[j]);
0046             } else if (i >= Hbins && i < Hbins + Obins) {
0047               flat[indx]->setXoffDB(i - Hbins, thisBin->x[j]);
0048               flat[indx]->setYoffDB(i - Hbins, thisBin->y[j]);
0049             } else if (i >= Hbins + Obins && i < Hbins + 2 * Obins) {
0050               flat[indx]->setPtDB(i - Hbins - Obins, thisBin->x[j]);
0051               flat[indx]->setPt2DB(i - Hbins - Obins, thisBin->y[j]);
0052             }
0053           }
0054         }
0055       }
0056       int cbins = 0;
0057       while (flatTableSize > Hbins + 2 * Obins + cbins) {
0058         const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins]);
0059         double centbinning = thisBin->x[0];
0060         int ncentbins = (int)thisBin->y[0] + 0.01;
0061         if (ncentbins == 0)
0062           break;
0063         for (int j = 0; j < ncentbins; j++) {
0064           const RPFlatParams::EP* thisBin = &(flatparmsDB_.m_table[Hbins + 2 * Obins + cbins + j + 1]);
0065           if (fabs(centbinning - 1.) < 0.01) {
0066             for (int i = 0; i < hi::NumEPNames; i++) {
0067               flat[i]->setCentRes1(j, thisBin->x[i], thisBin->y[i]);
0068             }
0069           }
0070           if (fabs(centbinning - 2.) < 0.01) {
0071             for (int i = 0; i < hi::NumEPNames; i++)
0072               flat[i]->setCentRes2(j, thisBin->x[i], thisBin->y[i]);
0073           }
0074           if (fabs(centbinning - 5.) < 0.01) {
0075             for (int i = 0; i < hi::NumEPNames; i++)
0076               flat[i]->setCentRes5(j, thisBin->x[i], thisBin->y[i]);
0077           }
0078           if (fabs(centbinning - 10.) < 0.01) {
0079             for (int i = 0; i < hi::NumEPNames; i++)
0080               flat[i]->setCentRes10(j, thisBin->x[i], thisBin->y[i]);
0081           }
0082           if (fabs(centbinning - 20.) < 0.01) {
0083             for (int i = 0; i < hi::NumEPNames; i++)
0084               flat[i]->setCentRes20(j, thisBin->x[i], thisBin->y[i]);
0085           }
0086           if (fabs(centbinning - 25.) < 0.01) {
0087             for (int i = 0; i < hi::NumEPNames; i++)
0088               flat[i]->setCentRes25(j, thisBin->x[i], thisBin->y[i]);
0089           }
0090           if (fabs(centbinning - 30.) < 0.01) {
0091             for (int i = 0; i < hi::NumEPNames; i++)
0092               flat[i]->setCentRes30(j, thisBin->x[i], thisBin->y[i]);
0093           }
0094           if (fabs(centbinning - 40.) < 0.01) {
0095             for (int i = 0; i < hi::NumEPNames; i++)
0096               flat[i]->setCentRes40(j, thisBin->x[i], thisBin->y[i]);
0097           }
0098         }
0099 
0100         cbins += ncentbins + 1;
0101       }
0102     }
0103   }
0104 
0105   bool IsSuccess() { return genFlatPsi_; }
0106   ~LoadEPDB() {}
0107 
0108 private:
0109   bool genFlatPsi_;
0110 };
0111 
0112 #endif