ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/DTDPGAnalysis/src/STAOfflineAnalyzer.cc
(Generate patch)

Comparing UserCode/DTDPGAnalysis/src/STAOfflineAnalyzer.cc (file contents):
Revision 1.1 by giorgia, Fri Oct 10 11:00:31 2008 UTC vs.
Revision 1.5 by marycruz, Thu Jul 4 17:17:08 2013 UTC

# Line 23 | Line 23
23   #include "FWCore/ParameterSet/interface/ParameterSet.h"
24   #include "FWCore/Framework/interface/ESHandle.h"
25   #include "FWCore/Utilities/interface/Exception.h"
26 + #include "DQMServices/Core/interface/DQMStore.h"
27 + #include "DQMServices/Core/interface/MonitorElement.h"
28 + #include "FWCore/ServiceRegistry/interface/Service.h"
29  
30   using namespace edm;
31  
# Line 94 | Line 97 | STAOfflineAnalyzer::STAOfflineAnalyzer(c
97  
98    doSA = pset.getParameter<bool>("doSA");
99  
100 +  theDQMStore = edm::Service<DQMStore>().operator->();
101 +
102    init=false;
103    // Create the root file
104 <  theFile = new TFile(theRootFileName.c_str(), "RECREATE");
104 >  // theFile = new TFile(theRootFileName.c_str(), "RECREATE");
105  
106    // CosmicMuon
107    createTH1F("hNSA","Num SA tracks in events","", 6, -0.5, 5.5);
# Line 156 | Line 161 | STAOfflineAnalyzer::STAOfflineAnalyzer(c
161  
162   /* Destructor */
163   STAOfflineAnalyzer::~STAOfflineAnalyzer() {
164 <  theFile->cd();
160 <  theFile->Write();
161 <  theFile->Close();
164 >  theDQMStore->rmdir("DT/STAOfflineAnalyzer");
165   }
166  
167   /* Operations */
# Line 200 | Line 203 | void STAOfflineAnalyzer::analyze(const E
203  
204    if (!mc) {
205      Handle<LTCDigiCollection> ltcdigis;
206 <    event.getByType(ltcdigis);
207 <    //cout << "ltcdigis " << ltcdigis << endl;
206 >    //event.getByType(ltcdigis);  // Doesn't work after 62X
207 >    event.getByLabel("none",ltcdigis);
208  
209      for (std::vector<LTCDigi>::const_iterator ltc= ltcdigis->begin(); ltc!=
210           ltcdigis->end(); ++ltc) {
208      //if (debug) cout << (*ltc) << endl;
211        for (int i = 0; i < 6; i++)
212          if ((*ltc).HasTriggered(i)) {
213            LCT.set(i);
# Line 310 | Line 312 | void STAOfflineAnalyzer::analyzeSATrack(
312      Cylinder::RotationType rot0;
313      const Cylinder::CylinderPointer ecal = Cylinder::build(pos0, rot0,
314                                                             radiusECAL);
313    //cout << "Cyl " << ecal->radius() << endl;
315  
316      TrajectoryStateOnSurface tsosAtEcal =
317        thePropagator->propagate(*innerTSOS.freeState(), *ecal);
# Line 420 | Line 421 | void STAOfflineAnalyzer::analyzeSATrack(
421  
422        int nLay=0, nSL=0, nCh=0;
423        for (int c=1; c<=5;++c) {
423        // cout << "c, lh, fh " << c <<" " << firstHitSector << " " <<
424        //   lastHitSector << endl;
424          if (c==5 && firstHitSector==14) firstHitSector=10;
425          else if (c==5 && lastHitSector==14) lastHitSector=10;
426          else if (c==5 && firstHitSector==13) firstHitSector=4;
# Line 437 | Line 436 | void STAOfflineAnalyzer::analyzeSATrack(
436          const DTChamber * ch = dtGeom->chamber(chid);
437  
438          if (hitsPerChamber[chid]==0) {
440          //cout << "Hits missing in " << chid << endl;
439            missingHit(dtGeom, segs, ch, innerTSOS);
440          } else {
441            nCh++;
444          //cout << "Hits in " << chid << " = " << hitsPerChamber[chid]<< endl;
442          }
443          int nLayPerCh=0, nSLPerCh=0;
444 <        for (int sl=1; sl<=3; ++sl) {
445 <          if (sl==2 && cc==4) continue;
446 <          DTSuperLayerId slid(chid, sl);
444 >        for (int isl=1; isl<=3; ++isl) {
445 >          if (isl==2 && cc==4) continue;
446 >          DTSuperLayerId slid(chid, isl);
447            const DTSuperLayer* sl = dtGeom->superLayer(slid);
448            if (hitsPerSL[slid]==0) {
452            //cout << "Hits missing in " << slid << endl;
449              missingHit(dtGeom, segs2d, sl, innerTSOS);
450            } else {
451              nSL++;
452              nSLPerCh++;
457            //cout << "Hits in " << slid << " = " << hitsPerSL[slid]<< endl;
453            }
454            int nLayPerSL=0;
455            for (int l=1; l<=4; ++l) {
456              DTLayerId lid(slid, l);
457              const DTLayer* lay = dtGeom->layer(lid);
458              if (hitsPerLayer[lid]==0) {
464              //cout << "Hits missing in " << lid << endl;
459                missingHit(dtGeom, hits1d, lay, innerTSOS);
460              } else {
461                nLay++;
462                nLayPerCh++;
463                nLayPerSL++;
470              //cout << "Hits in " << lid << " = " << hitsPerLayer[lid]<< endl;
464              }
465            }
466            histo("hSANLayersPerSL")->Fill(nLayPerSL);
# Line 543 | Line 536 | void STAOfflineAnalyzer::pippo(const DTR
536    histo("hHitsLostChamber")->Fill(nSegsCh);
537    if (nSegsCh) {
538      LocalPoint extrapPos=extraptsos.localPosition();
546    //cout << "Extrap pos " << extrapPos << endl;
539      double minDist=99999.;
540      for (DTRecSegment4DCollection::const_iterator hit=segsch.first; hit!=segsch.second;
541           ++hit) {
550      //cout << "Hit pos " << hit->localPosition() << endl;
542        LocalVector dist = hit->localPosition() - extrapPos;
552      //cout << "dist " << dist << " " << dist.perp() << endl;
543        if (dist.perp()<minDist) minDist=dist.perp();
544      }
545      histo("hMinDistChamber")->Fill(minDist);
# Line 563 | Line 553 | void STAOfflineAnalyzer::pippo(const DTR
553    histo("hHitsLostSL")->Fill(nSegsCh);
554    if (nSegsCh) {
555      LocalPoint extrapPos=extraptsos.localPosition();
566    //cout << "Extrap pos " << extrapPos << endl;
556      double minDist=99999.;
557      for (DTRecSegment2DCollection::const_iterator hit=segsch.first; hit!=segsch.second;
558           ++hit) {
570      //cout << "Hit pos " << hit->localPosition() << endl;
559        LocalVector dist = hit->localPosition() - extrapPos;
572      //cout << "dist " << dist << " " << dist.perp() << endl;
560        if (dist.perp()<minDist) minDist=dist.x();
561      }
562      histo("hMinDistSL")->Fill(minDist);
# Line 583 | Line 570 | void STAOfflineAnalyzer::pippo(const DTR
570    histo("hHitsLostLayer")->Fill(nSegsCh);
571    if (nSegsCh) {
572      LocalPoint extrapPos=extraptsos.localPosition();
586    //cout << "Extrap pos " << extrapPos << endl;
573      double minDist=99999.;
574      for (DTRecHitCollection::const_iterator hit=segsch.first; hit!=segsch.second;
575           ++hit) {
590      //cout << "Hit pos " << hit->localPosition() << endl;
576        LocalVector dist = hit->localPosition() - extrapPos;
592      //cout << "dist " << dist << " " << dist.perp() << endl;
577        if (dist.perp()<minDist) minDist=dist.x();
578      }
579      histo("hMinDistLayer")->Fill(minDist);
# Line 597 | Line 581 | void STAOfflineAnalyzer::pippo(const DTR
581   }
582  
583   TH1F* STAOfflineAnalyzer::histo(const string& name) const{
584 <  if (TH1F* h =  dynamic_cast<TH1F*>(theFile->Get(name.c_str())) ) return h;
585 <  else throw cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
584 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
585 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
586 >  TH1F* histo = me->getTH1F();
587 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
588 >  return histo;
589   }
590  
591   TH2F* STAOfflineAnalyzer::histo2d(const string& name) const{
592 <  if (TH2F* h =  dynamic_cast<TH2F*>(theFile->Get(name.c_str())) ) return h;
593 <  else throw  cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
592 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
593 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
594 >  TH2F* histo = me->getTH2F();
595 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
596 >  return histo;
597   }
598  
599   bool STAOfflineAnalyzer::getLCT(LCTType t) const {
# Line 654 | Line 644 | void STAOfflineAnalyzer::createTH1F(cons
644    stringstream hTitle;
645    hName << name << suffix;
646    hTitle << title << suffix;
647 <  TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
648 <  _h->SetDirectory(theFile); // Needed when the input is a root file
647 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
648 >  theDQMStore->book1D(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
649 > //   TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
650 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
651   }
652  
653   void STAOfflineAnalyzer::createTH2F(const std::string& name,
# Line 671 | Line 663 | void STAOfflineAnalyzer::createTH2F(cons
663    stringstream hTitle;
664    hName << name << suffix;
665    hTitle << title << suffix;
666 <  TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
667 <  _h->SetDirectory(theFile); // Needed when the input is a root file
666 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
667 >  theDQMStore->book2D(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
668 > //   TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
669 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
670  
671   }
672  
679 DEFINE_FWK_MODULE(STAOfflineAnalyzer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines