CMS 3D CMS Logo

Public Member Functions | Private Member Functions

L1CaloInputScalesGenerator Class Reference

#include <L1TriggerConfig/L1ScalesProducers/src/L1CaloInputScalesGenerator.cc>

Inheritance diagram for L1CaloInputScalesGenerator:
edm::EDAnalyzer

List of all members.

Public Member Functions

 L1CaloInputScalesGenerator (const edm::ParameterSet &)
 ~L1CaloInputScalesGenerator ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void endJob ()

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 28 of file L1CaloInputScalesGenerator.h.


Constructor & Destructor Documentation

L1CaloInputScalesGenerator::L1CaloInputScalesGenerator ( const edm::ParameterSet iConfig) [explicit]

Definition at line 40 of file L1CaloInputScalesGenerator.cc.

{
   //now do what ever initialization is needed

}
L1CaloInputScalesGenerator::~L1CaloInputScalesGenerator ( )

Definition at line 48 of file L1CaloInputScalesGenerator.cc.

{
 
   // do anything here that needs to be done at desctruction time
   // (e.g. close files, deallocate resources etc.)

}

Member Function Documentation

void L1CaloInputScalesGenerator::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 63 of file L1CaloInputScalesGenerator.cc.

References EcalBarrel, EcalEndcap, edm::EventSetup::get(), LaserDQM_cfg::input, and convertSQLitetoXML_cfg::output.

{
   using namespace edm;


   ESHandle<CaloTPGTranscoder> caloTPGTranscoder;
   iSetup.get<CaloTPGRecord>().get(caloTPGTranscoder);
   
   EcalTPGScale* ecalTPGScale = new EcalTPGScale();
   ecalTPGScale->setEventSetup(iSetup);

   double output; 
   ofstream scalesFile("L1CaloInputScales_cfi.py");


   // Write the ecal scales, positive eta

   scalesFile << "import FWCore.ParameterSet.Config as cms\n" <<endl;

   scalesFile << "L1CaloInputScalesProducer =cms.ESProducer(\"L1CaloInputScalesProducer\"," << endl;
   scalesFile << "L1EcalEtThresholdsPositiveEta = cms.vdouble(" << endl; 


   //Python does not support arrays over 255 entries so we neeed ton accomodate it by creating new array after 255 entries
   int nEntries = 0;



   // loop over ietas, barrel
   for (unsigned short absIeta = 1; absIeta <= 28; absIeta++)
     {
       EcalSubdetector subdet = ( absIeta <= 17 ) ? EcalBarrel : EcalEndcap ;
       // 8 bits of input energy
       for (unsigned short input = 0; input <= 0xFF; input++)
         {
           output = ecalTPGScale->getTPGInGeV( (unsigned int) input, 
                                              EcalTrigTowerDetId(1, subdet,
                                                                 absIeta, 1));
           scalesFile << setprecision (8) << output;
           nEntries++;

           if (absIeta == 28 && input == 0xFF)
             {
               scalesFile << "),";
             }
           else if(nEntries>254)
             {
               scalesFile <<")+cms.vdouble(";
               nEntries=0;
             }
           else
             {
               scalesFile << ", ";
             }
         }
       scalesFile << endl;
     }

   // Write the ecal scales, negative eta

   scalesFile << endl << "\tL1EcalEtThresholdsNegativeEta = cms.vdouble(" << endl;

   nEntries=0;
   // loop over ietas, barrel first
   for (unsigned short absIeta = 1; absIeta <= 28; absIeta++)
     {
       EcalSubdetector subdet = ( absIeta <= 17 ) ? EcalBarrel : EcalEndcap ;
       // 8 bits of input energy
       for (unsigned short input = 0; input <= 0xFF; input++)
         {
           // negative eta
           output = ecalTPGScale->
             getTPGInGeV( (unsigned int) input, EcalTrigTowerDetId(-1, subdet,
                                                           absIeta, 2));
           scalesFile << setprecision (8) << output;
           nEntries++;



           if (absIeta == 28 && input == 0xFF)
             {
               scalesFile << "),";
             }
           else if(nEntries>254)
             {
               scalesFile <<")+cms.vdouble(";
               nEntries=0;
             }
           else
             {
               scalesFile << ", ";
             }
         }
       scalesFile << endl;
     }

   // Write the hcal scales (Positive Eta)

     scalesFile << endl << "\tL1HcalEtThresholdsPositiveEta = cms.vdouble(" << endl;

   // loop over ietas

     nEntries=0;
   for (unsigned short absIeta = 1; absIeta <= 32; absIeta++)
     {
       for (unsigned short input = 0; input <= 0xFF; input++)
         {
           output = caloTPGTranscoder->hcaletValue(absIeta, input); 
           scalesFile << setprecision (8) << output ;
           nEntries++;


           if (absIeta == 32 && input == 0xFF)
             {
               scalesFile << "),";
             }
           else if(nEntries>254)
             {
               scalesFile <<")+cms.vdouble(";
               nEntries=0;
             }
           else
             {
               scalesFile << ", ";
             }
         }
       scalesFile << endl;
     }

   // Write the hcal scales (Negative Eta)

     scalesFile << endl << "\tL1HcalEtThresholdsNegativeEta = cms.vdouble(" << endl;

     nEntries=0;  
   // loop over ietas
   for (unsigned short absIeta = 1; absIeta <= 32; absIeta++)
     {
       for (unsigned short input = 0; input <= 0xFF; input++)
         {
           output = caloTPGTranscoder->hcaletValue(-absIeta, input); 
           scalesFile << setprecision (8) << output ;
           nEntries++;


           if (absIeta == 32 && input == 0xFF)
             {
               scalesFile << ")";
             }
           else if(nEntries>254)
             {
               scalesFile <<")+cms.vdouble(";
               nEntries=0;
             }
           else 
             {
               scalesFile << ", ";
             }
         }
       scalesFile << endl;
     }


   scalesFile << ")" << endl;

   scalesFile.close();
}
void L1CaloInputScalesGenerator::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 233 of file L1CaloInputScalesGenerator.cc.

{
}
void L1CaloInputScalesGenerator::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 239 of file L1CaloInputScalesGenerator.cc.

                                   {
}