CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
TreeProducerCalibSimul Class Reference
Inheritance diagram for TreeProducerCalibSimul:
edm::one::EDAnalyzer< edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
 TreeProducerCalibSimul (const edm::ParameterSet &)
 
 ~TreeProducerCalibSimul () override=default
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

std::string EBRecHitCollection_
 
std::string eventHeaderCollection_
 
std::string eventHeaderProducer_
 
std::string hodoRecInfoCollection_
 
std::string hodoRecInfoProducer_
 
std::unique_ptr< TreeMatrixCalibmyTree_
 
int noHeader_
 
int noHits_
 
int noHodo_
 
int noTdc_
 
double posCluster_
 
std::string RecHitProducer_
 
std::string rootfile_
 
std::string tdcRecInfoCollection_
 
std::string tdcRecInfoProducer_
 
edm::EDGetTokenT< EBRecHitCollectiontokEBRecHit_
 
edm::EDGetTokenT< EcalTBHodoscopeRecInfotokEcalHodo_
 
edm::EDGetTokenT< EcalTBTDCRecInfotokEcalTDC_
 
edm::EDGetTokenT< EcalTBEventHeadertokEventHeader_
 
int tot_events_
 
int tot_events_ok_
 
std::string txtfile_
 
int xtalInBeam_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Detailed Description

Definition at line 54 of file TreeProducerCalibSimul.cc.

Constructor & Destructor Documentation

◆ TreeProducerCalibSimul()

TreeProducerCalibSimul::TreeProducerCalibSimul ( const edm::ParameterSet iConfig)
explicit

Definition at line 94 of file TreeProducerCalibSimul.cc.

References EBRecHitCollection_, eventHeaderCollection_, eventHeaderProducer_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hodoRecInfoCollection_, hodoRecInfoProducer_, ProducerED_cfi::InputTag, TFileService::kSharedResource, RecHitProducer_, rootfile_, AlCaHLTBitMon_QueryRunRegistry::string, tdcRecInfoCollection_, tdcRecInfoProducer_, tokEBRecHit_, tokEcalHodo_, tokEcalTDC_, tokEventHeader_, txtfile_, and xtalInBeam_.

94  {
95  usesResource(TFileService::kSharedResource);
96 
97  // now do what ever initialization is needed
98  xtalInBeam_ = iConfig.getUntrackedParameter<int>("xtalInBeam", -1000);
99  rootfile_ = iConfig.getUntrackedParameter<std::string>("rootfile", "mySimMatrixTree.root");
100  txtfile_ = iConfig.getUntrackedParameter<std::string>("txtfile", "mySimMatrixTree.txt");
101  EBRecHitCollection_ = iConfig.getParameter<std::string>("EBRecHitCollection");
102  RecHitProducer_ = iConfig.getParameter<std::string>("RecHitProducer");
103  hodoRecInfoCollection_ = iConfig.getParameter<std::string>("hodoRecInfoCollection");
104  hodoRecInfoProducer_ = iConfig.getParameter<std::string>("hodoRecInfoProducer");
105  tdcRecInfoCollection_ = iConfig.getParameter<std::string>("tdcRecInfoCollection");
106  tdcRecInfoProducer_ = iConfig.getParameter<std::string>("tdcRecInfoProducer");
107  eventHeaderCollection_ = iConfig.getParameter<std::string>("eventHeaderCollection");
108  eventHeaderProducer_ = iConfig.getParameter<std::string>("eventHeaderProducer");
109 
110  // summary
111  edm::LogVerbatim("GFlash") << "\nConstructor\n\nTreeProducerCalibSimul\nxtal in beam = " << xtalInBeam_;
112  edm::LogVerbatim("GFlash") << "Fetching hitCollection: " << EBRecHitCollection_.c_str() << " prod by "
113  << RecHitProducer_.c_str();
114  edm::LogVerbatim("GFlash") << "Fetching hodoCollection: " << hodoRecInfoCollection_.c_str() << " prod by "
115  << hodoRecInfoProducer_.c_str();
116  edm::LogVerbatim("GFlash") << "Fetching tdcCollection: " << tdcRecInfoCollection_.c_str() << " prod by "
117  << tdcRecInfoProducer_.c_str();
118  edm::LogVerbatim("GFlash") << "Fetching evHeaCollection: " << eventHeaderCollection_.c_str() << " prod by "
119  << eventHeaderProducer_.c_str() << "\n";
120 
121  tokEBRecHit_ = consumes<EBRecHitCollection>(edm::InputTag(RecHitProducer_, EBRecHitCollection_));
122  tokEcalHodo_ = consumes<EcalTBHodoscopeRecInfo>(edm::InputTag(hodoRecInfoProducer_, hodoRecInfoCollection_));
123  tokEcalTDC_ = consumes<EcalTBTDCRecInfo>(edm::InputTag(tdcRecInfoProducer_, tdcRecInfoCollection_));
124  tokEventHeader_ = consumes<EcalTBEventHeader>(edm::InputTag(eventHeaderProducer_));
125 }
static const std::string kSharedResource
Definition: TFileService.h:76
Log< level::Info, true > LogVerbatim
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< EcalTBTDCRecInfo > tokEcalTDC_
edm::EDGetTokenT< EcalTBEventHeader > tokEventHeader_
edm::EDGetTokenT< EcalTBHodoscopeRecInfo > tokEcalHodo_
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< EBRecHitCollection > tokEBRecHit_

◆ ~TreeProducerCalibSimul()

TreeProducerCalibSimul::~TreeProducerCalibSimul ( )
overridedefault

Member Function Documentation

◆ analyze()

void TreeProducerCalibSimul::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 161 of file TreeProducerCalibSimul.cc.

References filterRecHits_cfi::EBRecHits, HBHEDarkening_cff::energy, EBDetId::ETAPHIMODE, EcalTBEventHeader::eventNumber(), EBDetId::ic(), EBDetId::ieta(), iEvent, cuy::ii, EBDetId::iphi(), ecalpyutils::ism(), HcalResponse_cfi::maxEne, myTree_, noHeader_, noHits_, noHodo_, noTdc_, EcalTBTDCRecInfo::offset(), EcalTBHodoscopeRecInfo::posX(), EcalTBHodoscopeRecInfo::posY(), EcalTBHodoscopeRecInfo::qualX(), EcalTBHodoscopeRecInfo::qualY(), writedatasetfile::run, EcalTBHodoscopeRecInfo::slopeX(), EcalTBHodoscopeRecInfo::slopeY(), EBDetId::SMCRYSTALMODE, fftjetcommon_cfi::sx, fftjetcommon_cfi::sy, tokEBRecHit_, tokEcalHodo_, tokEcalTDC_, tokEventHeader_, tot_events_, tot_events_ok_, x, xtalInBeam_, and y.

161  {
162  // counting events
163  ++tot_events_;
164 
165  if (tot_events_ % 5000 == 0)
166  edm::LogVerbatim("GFlash") << "event " << tot_events_;
167 
168  // ---------------------------------------------------------------------
169  // taking what I need: hits
171 
172  // taking what I need: hodoscopes
173  const EcalTBHodoscopeRecInfo* recHodo = &iEvent.get(tokEcalHodo_);
174 
175  // taking what I need: tdc
176  const EcalTBTDCRecInfo* recTDC = &iEvent.get(tokEcalTDC_);
177 
178  // taking what I need: event header
179  const EcalTBEventHeader* evtHeader = &iEvent.get(tokEventHeader_);
180 
181  // checking everything is there and fine
182  if ((!EBRecHits) || (EBRecHits->size() == 0)) {
183  ++noHits_;
184  return;
185  }
186  if (!recTDC) {
187  ++noTdc_;
188  return;
189  }
190  if (!recHodo) {
191  ++noHodo_;
192  return;
193  }
194  if (!evtHeader) {
195  ++noHeader_;
196  return;
197  }
198  ++tot_events_ok_;
199 
200  // ---------------------------------------------------------------------
201  // info on the event
202  int run = -999;
203  int tbm = -999;
204  int event = evtHeader->eventNumber();
205 
206  // ---------------------------------------------------------------------
207  // xtal-in-beam
208  int nomXtalInBeam = -999;
209  int nextXtalInBeam = -999;
210 
211  EBDetId xtalInBeamId(1, xtalInBeam_, EBDetId::SMCRYSTALMODE);
212  if (xtalInBeamId == EBDetId(0)) {
213  return;
214  }
215  int mySupCry = xtalInBeamId.ic();
216  int mySupEta = xtalInBeamId.ieta();
217  int mySupPhi = xtalInBeamId.iphi();
218 
219  // ---------------------------------------------------------------------
220  // hodoscope information
221  double x = recHodo->posX();
222  double y = recHodo->posY();
223  double sx = recHodo->slopeX();
224  double sy = recHodo->slopeY();
225  double qx = recHodo->qualX();
226  double qy = recHodo->qualY();
227 
228  // ---------------------------------------------------------------------
229  // tdc information
230  double tdcOffset = recTDC->offset();
231 
232  // ---------------------------------------------------------------------
233  // Find EBDetId in a 7x7 Matrix
234  EBDetId Xtals7x7[49];
235  double energy[49];
236  int crystal[49];
237  int allMatrix = 1;
238  for (unsigned int icry = 0; icry < 49; icry++) {
239  unsigned int row = icry / 7;
240  unsigned int column = icry % 7;
241  Xtals7x7[icry] = EBDetId(xtalInBeamId.ieta() + column - 3, xtalInBeamId.iphi() + row - 3, EBDetId::ETAPHIMODE);
242 
243  if (Xtals7x7[icry].ism() == 1) {
244  energy[icry] = EBRecHits->find(Xtals7x7[icry])->energy();
245  crystal[icry] = Xtals7x7[icry].ic();
246  } else {
247  energy[icry] = -100.;
248  crystal[icry] = -100;
249  allMatrix = 0;
250  }
251  }
252 
253  // ---------------------------------------------------------------------
254  // Looking for the max energy crystal
255  double maxEne = -999.;
256  int maxEneCry = 9999;
257  for (int ii = 0; ii < 49; ii++) {
258  if (energy[ii] > maxEne) {
259  maxEne = energy[ii];
260  maxEneCry = crystal[ii];
261  }
262  }
263 
264  // Position reconstruction - skipped here
265  double Xcal = -999.;
266  double Ycal = -999.;
267 
268  // filling the tree
269  myTree_->fillInfo(run,
270  event,
271  mySupCry,
272  maxEneCry,
273  nomXtalInBeam,
274  nextXtalInBeam,
275  mySupEta,
276  mySupPhi,
277  tbm,
278  x,
279  y,
280  Xcal,
281  Ycal,
282  sx,
283  sy,
284  qx,
285  qy,
286  tdcOffset,
287  allMatrix,
288  energy,
289  crystal);
290  myTree_->store();
291 }
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< EcalTBTDCRecInfo > tokEcalTDC_
edm::EDGetTokenT< EcalTBEventHeader > tokEventHeader_
edm::EDGetTokenT< EcalTBHodoscopeRecInfo > tokEcalHodo_
int eventNumber() const
Returns the event number.
int iEvent
Definition: GenABIO.cc:224
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
static const int ETAPHIMODE
Definition: EBDetId.h:158
ii
Definition: cuy.py:589
float offset() const
std::unique_ptr< TreeMatrixCalib > myTree_
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
int ism(int ieta, int iphi)
Definition: EcalPyUtils.cc:49
Definition: event.py:1
edm::EDGetTokenT< EBRecHitCollection > tokEBRecHit_

◆ beginJob()

void TreeProducerCalibSimul::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 129 of file TreeProducerCalibSimul.cc.

References myTree_, noHeader_, noHits_, noHodo_, noTdc_, rootfile_, tot_events_, and tot_events_ok_.

129  {
130  edm::LogVerbatim("GFlash") << "\nBeginJob\n";
131 
132  // tree
133  myTree_ = std::make_unique<TreeMatrixCalib>(rootfile_.c_str());
134 
135  // counters
136  tot_events_ = 0;
137  tot_events_ok_ = 0;
138  noHits_ = 0;
139  noHodo_ = 0;
140  noTdc_ = 0;
141  noHeader_ = 0;
142 }
Log< level::Info, true > LogVerbatim
std::unique_ptr< TreeMatrixCalib > myTree_

◆ endJob()

void TreeProducerCalibSimul::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 146 of file TreeProducerCalibSimul.cc.

References noHeader_, noHits_, noHodo_, noTdc_, tot_events_, tot_events_ok_, and txtfile_.

146  {
147  edm::LogVerbatim("GFlash") << "\nEndJob\n";
148 
149  std::ofstream MyOut(txtfile_.c_str());
150  MyOut << "total events: " << tot_events_ << std::endl;
151  MyOut << "events skipped because of no hits: " << noHits_ << std::endl;
152  MyOut << "events skipped because of no hodos: " << noHodo_ << std::endl;
153  MyOut << "events skipped because of no tdc: " << noTdc_ << std::endl;
154  MyOut << "events skipped because of no header: " << noHeader_ << std::endl;
155  MyOut << "total OK events (passing the basic selection): " << tot_events_ok_ << std::endl;
156  MyOut.close();
157 }
Log< level::Info, true > LogVerbatim

Member Data Documentation

◆ EBRecHitCollection_

std::string TreeProducerCalibSimul::EBRecHitCollection_
private

Definition at line 66 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ eventHeaderCollection_

std::string TreeProducerCalibSimul::eventHeaderCollection_
private

Definition at line 72 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ eventHeaderProducer_

std::string TreeProducerCalibSimul::eventHeaderProducer_
private

Definition at line 73 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ hodoRecInfoCollection_

std::string TreeProducerCalibSimul::hodoRecInfoCollection_
private

Definition at line 68 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ hodoRecInfoProducer_

std::string TreeProducerCalibSimul::hodoRecInfoProducer_
private

Definition at line 69 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ myTree_

std::unique_ptr<TreeMatrixCalib> TreeProducerCalibSimul::myTree_
private

Definition at line 76 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and beginJob().

◆ noHeader_

int TreeProducerCalibSimul::noHeader_
private

Definition at line 89 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ noHits_

int TreeProducerCalibSimul::noHits_
private

Definition at line 86 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ noHodo_

int TreeProducerCalibSimul::noHodo_
private

Definition at line 87 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ noTdc_

int TreeProducerCalibSimul::noTdc_
private

Definition at line 88 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ posCluster_

double TreeProducerCalibSimul::posCluster_
private

Definition at line 74 of file TreeProducerCalibSimul.cc.

◆ RecHitProducer_

std::string TreeProducerCalibSimul::RecHitProducer_
private

Definition at line 67 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ rootfile_

std::string TreeProducerCalibSimul::rootfile_
private

Definition at line 64 of file TreeProducerCalibSimul.cc.

Referenced by beginJob(), and TreeProducerCalibSimul().

◆ tdcRecInfoCollection_

std::string TreeProducerCalibSimul::tdcRecInfoCollection_
private

Definition at line 70 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ tdcRecInfoProducer_

std::string TreeProducerCalibSimul::tdcRecInfoProducer_
private

Definition at line 71 of file TreeProducerCalibSimul.cc.

Referenced by TreeProducerCalibSimul().

◆ tokEBRecHit_

edm::EDGetTokenT<EBRecHitCollection> TreeProducerCalibSimul::tokEBRecHit_
private

Definition at line 78 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and TreeProducerCalibSimul().

◆ tokEcalHodo_

edm::EDGetTokenT<EcalTBHodoscopeRecInfo> TreeProducerCalibSimul::tokEcalHodo_
private

Definition at line 79 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and TreeProducerCalibSimul().

◆ tokEcalTDC_

edm::EDGetTokenT<EcalTBTDCRecInfo> TreeProducerCalibSimul::tokEcalTDC_
private

Definition at line 80 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and TreeProducerCalibSimul().

◆ tokEventHeader_

edm::EDGetTokenT<EcalTBEventHeader> TreeProducerCalibSimul::tokEventHeader_
private

Definition at line 81 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and TreeProducerCalibSimul().

◆ tot_events_

int TreeProducerCalibSimul::tot_events_
private

Definition at line 84 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ tot_events_ok_

int TreeProducerCalibSimul::tot_events_ok_
private

Definition at line 85 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), beginJob(), and endJob().

◆ txtfile_

std::string TreeProducerCalibSimul::txtfile_
private

Definition at line 65 of file TreeProducerCalibSimul.cc.

Referenced by endJob(), and TreeProducerCalibSimul().

◆ xtalInBeam_

int TreeProducerCalibSimul::xtalInBeam_
private

Definition at line 83 of file TreeProducerCalibSimul.cc.

Referenced by analyze(), and TreeProducerCalibSimul().