Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:54

0001 #include "L1Trigger/GlobalCaloTrigger/test/gctTestSingleEvent.h"
0002 
0003 #include "FWCore/Utilities/interface/Exception.h"
0004 
0005 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0006 
0007 #include <fstream>
0008 #include <iostream>
0009 
0010 gctTestSingleEvent::gctTestSingleEvent() {}
0011 gctTestSingleEvent::~gctTestSingleEvent() {}
0012 
0013 // Read the region Et values for a single event from a text file and prepare them to be loaded into the GCT
0014 std::vector<L1CaloRegion> gctTestSingleEvent::loadEvent(const std::string &fileName, const int16_t bx) {
0015   std::vector<L1CaloRegion> result;
0016 
0017   std::ifstream inFile;
0018 
0019   std::cout << "Reading event data from file " << fileName << std::endl;
0020 
0021   inFile.open(fileName.c_str(), std::ios::in);
0022 
0023   unsigned phi, et;
0024 
0025   // Expect each line of the file to start with the phi value, followed by the et
0026   // for each eta. When we get to the end of the file and try to read the next phi,
0027   // recognise the end-of-file condition and quit reading.
0028   inFile >> phi;
0029   while (!inFile.eof()) {
0030     for (unsigned eta = 0; eta < L1CaloRegionDetId::N_ETA; ++eta) {
0031       inFile >> et;
0032       // Make an input region
0033       // Arguments to named ctor are (et, overflow, finegrain, mip, quiet, eta, phi)
0034       L1CaloRegion temp = L1CaloRegion::makeRegionFromGctIndices(et, false, true, false, false, eta, phi);
0035       temp.setBx(bx);
0036       result.push_back(temp);
0037     }
0038     inFile >> phi;
0039   }
0040 
0041   // Tidy the input file
0042   inFile.close();
0043 
0044   // And finish
0045   return result;
0046 }