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.4 by pellicci, Wed Jan 30 14:42:51 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);
204 <    //cout << "ltcdigis " << ltcdigis << endl;
206 >    event.getByLabel("none",ltcdigis);
207  
208      for (std::vector<LTCDigi>::const_iterator ltc= ltcdigis->begin(); ltc!=
209           ltcdigis->end(); ++ltc) {
208      //if (debug) cout << (*ltc) << endl;
210        for (int i = 0; i < 6; i++)
211          if ((*ltc).HasTriggered(i)) {
212            LCT.set(i);
# Line 310 | Line 311 | void STAOfflineAnalyzer::analyzeSATrack(
311      Cylinder::RotationType rot0;
312      const Cylinder::CylinderPointer ecal = Cylinder::build(pos0, rot0,
313                                                             radiusECAL);
313    //cout << "Cyl " << ecal->radius() << endl;
314  
315      TrajectoryStateOnSurface tsosAtEcal =
316        thePropagator->propagate(*innerTSOS.freeState(), *ecal);
# Line 420 | Line 420 | void STAOfflineAnalyzer::analyzeSATrack(
420  
421        int nLay=0, nSL=0, nCh=0;
422        for (int c=1; c<=5;++c) {
423        // cout << "c, lh, fh " << c <<" " << firstHitSector << " " <<
424        //   lastHitSector << endl;
423          if (c==5 && firstHitSector==14) firstHitSector=10;
424          else if (c==5 && lastHitSector==14) lastHitSector=10;
425          else if (c==5 && firstHitSector==13) firstHitSector=4;
# Line 437 | Line 435 | void STAOfflineAnalyzer::analyzeSATrack(
435          const DTChamber * ch = dtGeom->chamber(chid);
436  
437          if (hitsPerChamber[chid]==0) {
440          //cout << "Hits missing in " << chid << endl;
438            missingHit(dtGeom, segs, ch, innerTSOS);
439          } else {
440            nCh++;
444          //cout << "Hits in " << chid << " = " << hitsPerChamber[chid]<< endl;
441          }
442          int nLayPerCh=0, nSLPerCh=0;
443 <        for (int sl=1; sl<=3; ++sl) {
444 <          if (sl==2 && cc==4) continue;
445 <          DTSuperLayerId slid(chid, sl);
443 >        for (int i=1; i<=3; ++i) {
444 >          if (i==2 && cc==4) continue;
445 >          DTSuperLayerId slid(chid, i);
446            const DTSuperLayer* sl = dtGeom->superLayer(slid);
447            if (hitsPerSL[slid]==0) {
452            //cout << "Hits missing in " << slid << endl;
448              missingHit(dtGeom, segs2d, sl, innerTSOS);
449            } else {
450              nSL++;
451              nSLPerCh++;
457            //cout << "Hits in " << slid << " = " << hitsPerSL[slid]<< endl;
452            }
453            int nLayPerSL=0;
454            for (int l=1; l<=4; ++l) {
455              DTLayerId lid(slid, l);
456              const DTLayer* lay = dtGeom->layer(lid);
457              if (hitsPerLayer[lid]==0) {
464              //cout << "Hits missing in " << lid << endl;
458                missingHit(dtGeom, hits1d, lay, innerTSOS);
459              } else {
460                nLay++;
461                nLayPerCh++;
462                nLayPerSL++;
470              //cout << "Hits in " << lid << " = " << hitsPerLayer[lid]<< endl;
463              }
464            }
465            histo("hSANLayersPerSL")->Fill(nLayPerSL);
# Line 543 | Line 535 | void STAOfflineAnalyzer::pippo(const DTR
535    histo("hHitsLostChamber")->Fill(nSegsCh);
536    if (nSegsCh) {
537      LocalPoint extrapPos=extraptsos.localPosition();
546    //cout << "Extrap pos " << extrapPos << endl;
538      double minDist=99999.;
539      for (DTRecSegment4DCollection::const_iterator hit=segsch.first; hit!=segsch.second;
540           ++hit) {
550      //cout << "Hit pos " << hit->localPosition() << endl;
541        LocalVector dist = hit->localPosition() - extrapPos;
552      //cout << "dist " << dist << " " << dist.perp() << endl;
542        if (dist.perp()<minDist) minDist=dist.perp();
543      }
544      histo("hMinDistChamber")->Fill(minDist);
# Line 563 | Line 552 | void STAOfflineAnalyzer::pippo(const DTR
552    histo("hHitsLostSL")->Fill(nSegsCh);
553    if (nSegsCh) {
554      LocalPoint extrapPos=extraptsos.localPosition();
566    //cout << "Extrap pos " << extrapPos << endl;
555      double minDist=99999.;
556      for (DTRecSegment2DCollection::const_iterator hit=segsch.first; hit!=segsch.second;
557           ++hit) {
570      //cout << "Hit pos " << hit->localPosition() << endl;
558        LocalVector dist = hit->localPosition() - extrapPos;
572      //cout << "dist " << dist << " " << dist.perp() << endl;
559        if (dist.perp()<minDist) minDist=dist.x();
560      }
561      histo("hMinDistSL")->Fill(minDist);
# Line 583 | Line 569 | void STAOfflineAnalyzer::pippo(const DTR
569    histo("hHitsLostLayer")->Fill(nSegsCh);
570    if (nSegsCh) {
571      LocalPoint extrapPos=extraptsos.localPosition();
586    //cout << "Extrap pos " << extrapPos << endl;
572      double minDist=99999.;
573      for (DTRecHitCollection::const_iterator hit=segsch.first; hit!=segsch.second;
574           ++hit) {
590      //cout << "Hit pos " << hit->localPosition() << endl;
575        LocalVector dist = hit->localPosition() - extrapPos;
592      //cout << "dist " << dist << " " << dist.perp() << endl;
576        if (dist.perp()<minDist) minDist=dist.x();
577      }
578      histo("hMinDistLayer")->Fill(minDist);
# Line 597 | Line 580 | void STAOfflineAnalyzer::pippo(const DTR
580   }
581  
582   TH1F* STAOfflineAnalyzer::histo(const string& name) const{
583 <  if (TH1F* h =  dynamic_cast<TH1F*>(theFile->Get(name.c_str())) ) return h;
584 <  else throw cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
583 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
584 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
585 >  TH1F* histo = me->getTH1F();
586 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH1F " << name;
587 >  return histo;
588   }
589  
590   TH2F* STAOfflineAnalyzer::histo2d(const string& name) const{
591 <  if (TH2F* h =  dynamic_cast<TH2F*>(theFile->Get(name.c_str())) ) return h;
592 <  else throw  cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
591 >  MonitorElement* me = theDQMStore->get(("DT/STAOfflineAnalyzer/"+name).c_str());
592 >  if (!me) throw cms::Exception("STAOfflineAnalyzer") << " ME not existing " << name;
593 >  TH2F* histo = me->getTH2F();
594 >  if (!histo)cms::Exception("STAOfflineAnalyzer") << " Not a TH2F " << name;
595 >  return histo;
596   }
597  
598   bool STAOfflineAnalyzer::getLCT(LCTType t) const {
# Line 654 | Line 643 | void STAOfflineAnalyzer::createTH1F(cons
643    stringstream hTitle;
644    hName << name << suffix;
645    hTitle << title << suffix;
646 <  TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
647 <  _h->SetDirectory(theFile); // Needed when the input is a root file
646 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
647 >  theDQMStore->book1D(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
648 > //   TH1F * _h = new TH1F(hName.str().c_str(), hTitle.str().c_str(), nbin,binMin,binMax);
649 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
650   }
651  
652   void STAOfflineAnalyzer::createTH2F(const std::string& name,
# Line 671 | Line 662 | void STAOfflineAnalyzer::createTH2F(cons
662    stringstream hTitle;
663    hName << name << suffix;
664    hTitle << title << suffix;
665 <  TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
666 <  _h->SetDirectory(theFile); // Needed when the input is a root file
665 >  theDQMStore->setCurrentFolder("DT/STAOfflineAnalyzer");
666 >  theDQMStore->book2D(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
667 > //   TH2F * _h = new TH2F(hName.str().c_str(), hTitle.str().c_str(), nBinX,binXMin,binXMax, nBinY,binYMin,binYMax);
668 > //   _h->SetDirectory(theFile); // Needed when the input is a root file
669  
670   }
671  
679 DEFINE_FWK_MODULE(STAOfflineAnalyzer);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines